HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4.  
  5. #define PLUGIN "[POST] Uzenet"
  6. #define VERSION "2.0"
  7. #define AUTHOR "tuty"
  8.  
  9. #define ADVERTISE_TIME 10.0
  10.  
  11. new gPluginOn;
  12. new gAvertise;
  13. new gMessageCost;
  14. new gMessageSayText;
  15. new gMaxPlayers;
  16.  
  17. public plugin_init()
  18. {
  19. register_plugin(PLUGIN, VERSION, AUTHOR);
  20. gPluginOn = register_cvar("amx_postmessage", "1"); // 0 - disabled | 1 - enabled
  21. gAvertise = register_cvar("amx_postmessage_avertise", "1"); // enable advertise message in putinserver
  22. gMessageCost = register_cvar("amx_postmessage_cost", "1000"); // post message cost
  23. gMessageSayText = get_user_msgid("SayText");
  24. gMaxPlayers = get_maxplayers();
  25. register_clcmd("say", "hook_say_cmd");
  26. register_clcmd("say_team", "hook_say_cmd");
  27. register_dictionary("postmessage.txt");
  28. }
  29. public client_putinserver(id)
  30. {
  31. if(get_pcvar_num(gAvertise) == 1)
  32. {
  33. set_task(ADVERTISE_TIME, "show_message", id);
  34. }
  35. }
  36. public hook_say_cmd(id)
  37. {
  38. new check_prefix[6];
  39. read_argv(1, check_prefix, 5);
  40.  
  41. if(!equal(check_prefix, "/POST ", 5))
  42. return PLUGIN_CONTINUE;
  43.  
  44. if(!get_pcvar_num(gPluginOn))
  45. {
  46. client_print(id, print_chat, "%L", id, "MESSAGE_DISABLED");
  47. return PLUGIN_HANDLED;
  48. }
  49. new said[256], name[32];
  50. read_args(said, 255);
  51. remove_quotes(said);
  52. trim(said);
  53. replace(said, 255, check_prefix, "");
  54.  
  55. get_user_name(id, name , 31);
  56. if(!is_user_alive(id))
  57. {
  58. client_print(id, print_chat, "%L", id, "NOT_ALIVE");
  59. return PLUGIN_HANDLED;
  60. }
  61. new money = cs_get_user_money(id);
  62. new cost = get_pcvar_num(gMessageCost);
  63. if(money < cost)
  64. {
  65. client_print(id, print_chat, "%L", id, "DONT_HAVE_MONEY");
  66. return PLUGIN_HANDLED;
  67. }
  68. color_print(0, "^x01[%s]^x04 [ %s ]: [ %s ]", (get_user_team(id) == 1) ? "T" : "CT" , name, said);
  69. cs_set_user_money(id, money - cost);
  70. return PLUGIN_HANDLED;
  71. }
  72. public show_message(id)
  73. {
  74. client_print(id, print_chat, "%L", id, "ADVERTISE_MESSAGE");
  75. client_print(id, print_chat, "%L", id, "ADVERTISE_MESSAGE2", get_pcvar_num(gMessageCost));
  76. console_print(id, "%L", id, "ADVERTISE_MESSAGE");
  77. console_print(id, "%L", id, "ADVERTISE_MESSAGE2", get_pcvar_num(gMessageCost));
  78. }
  79. color_print(id, const message[], {Float,Sql,Result,_}:...)
  80. {
  81. new Buffer[128],Buffer2[128];
  82. formatex(Buffer2, sizeof Buffer2 - 1, "%s", message);
  83. vformat(Buffer, sizeof Buffer - 1, Buffer2, 3);
  84. if(id)
  85. {
  86. message_begin(MSG_ONE_UNRELIABLE, gMessageSayText, _, id);
  87. write_byte(id);
  88. write_string(Buffer);
  89. message_end();
  90. }
  91. else
  92. {
  93. for(new i = 1; i <= gMaxPlayers; i++)
  94. {
  95.  
  96. if(!is_user_connected(i))
  97. continue;
  98.  
  99. message_begin(MSG_ONE_UNRELIABLE, gMessageSayText, _, i);
  100. write_byte(i);
  101. write_string(Buffer);
  102. message_end();
  103. }
  104. }
  105. }
  106. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  107. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  108. */
  109.