Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <colorvariables>
  3.  
  4. public Plugin:myinfo = {
  5. name = "Comandos4Frases",
  6. author = "SkippeR",
  7. description = "Imprime uma frase no chat.",
  8. url = ""
  9. };
  10.  
  11. Handle g_Comandos;
  12. Handle g_Frases;
  13.  
  14. char g_ServerIp [32];
  15. char g_ServerPort [16];
  16.  
  17. KeyValues g_hComandosfrase;
  18. ConVar gc_sURL;
  19. ConVar g_hEnabled;
  20. ConVar g_hFile;
  21.  
  22. public OnPluginStart()
  23. {
  24. CreateConVar("sm_comandos4frase_version", PLUGIN_VERSION, "", FCVAR_NOTIFY|FCVAR_REPLICATED);
  25. g_hEnabled = CreateConVar("sm_comandos_enabled", "1", "ligar o desligar esta merda.");
  26. g_hFile = CreateConVar("sm_comandos_file", "comandos.txt", "Para ler comando e frase");
  27.  
  28. g_hFile.AddChangeHook(ConVarChange_File);
  29.  
  30. RegConsoleCmd("say", OnSay);
  31. RegConsoleCmd("say_team", OnSay);
  32.  
  33. RegAdminCmd("sm_cff", Command_Comandos, ADMFLAG_GENERIC,"Abre frase no chat");
  34.  
  35.  
  36. g_Comandos = CreateArray(32);
  37. g_Frases = CreateArray(64);
  38.  
  39. Handle cvar = FindConVar("hostip");
  40. int hostip = GetConVarInt(cvar);
  41. FormatEx(g_ServerIp, sizeof(g_ServerIp), "%u.%u.%u.%u",
  42. (hostip >> 24) & 0x000000FF, (hostip >> 16) & 0x000000FF, (hostip >> 8) & 0x000000FF, hostip & 0x000000FF);
  43.  
  44. cvar = FindConVar("hostport");
  45. GetConVarString(cvar, g_ServerPort, sizeof(g_ServerPort));
  46.  
  47. LoadComandos4Frase();
  48. }
  49.  
  50. public OnMapStart()
  51. {
  52. LoadComandos4Frase();
  53. }
  54.  
  55. LoadComandos4Frase()
  56. {
  57. char buffer [1024];
  58. BuildPath(Path_SM, buffer, sizeof(buffer), "configs/comandos.txt");
  59.  
  60. if (!FileExists(buffer))
  61. {
  62. return;
  63. }
  64.  
  65. Handle f = OpenFile(buffer, "r");
  66. if (f == INVALID_HANDLE)
  67. {
  68. LogError("[SM] Could not open file: %s", buffer);
  69. return;
  70. }
  71.  
  72. ClearArray(g_Comandos);
  73. ClearArray(g_Frases);
  74.  
  75. char comando [32];
  76. char frase [256];
  77. while (!IsEndOfFile(f) && ReadFileLine(f, buffer, sizeof(buffer)))
  78. {
  79. TrimString(buffer);
  80. if (buffer[0] == '\0' || buffer[0] == ';' || (buffer[0] == '/' && buffer[1] == '/'))
  81. {
  82. continue;
  83. }
  84.  
  85. int pos = BreakString(buffer, comando, sizeof(comando));
  86. if (pos == -1)
  87. {
  88. continue;
  89. }
  90.  
  91. int frasePos = BreakString(buffer[pos], frase, sizeof(frase));
  92. if (frasePos == -1)
  93. {
  94. continue;
  95. }
  96.  
  97. strcopy(frase, sizeof(frase), buffer[frasePos+pos]);
  98. TrimString(link);
  99.  
  100. PushArrayString(g_Comandos, comando);
  101. PushArrayString(g_Frases, frase);
  102. }
  103.  
  104. CloseHandle(f);
  105. }
  106.  
  107. public Action Command_Comandos(int client, int args)
  108. {
  109. if (args < 2)
  110. {
  111. ReplyToCommand(client, "[SM] Usage: !cff ");
  112. return Plugin_Handled;
  113. }
  114. char pattern[96], buffer[64], frase[512];
  115. GetCmdArg(1, pattern, sizeof(pattern));
  116. GetCmdArg(2, frase, sizeof(frase));
  117. int targets[129];
  118. bool ml = false;
  119.  
  120. int count = ProcessTargetString(pattern, client, targets, sizeof(targets), 0, buffer, sizeof(buffer), ml);
  121.  
  122. if(StrContains(frase, "", false) != 0) Format(frase, sizeof(frase), "", frase);
  123.  
  124. if (count <= 0) ReplyToCommand(client, "Bad target");
  125.  
  126. return Plugin_Handled;
  127. }
  128.  
  129. public comandofrase(char [] comando, char [] frase, int client)
  130. {
  131. Handle Radio = CreateKeyValues("data");
  132. KvSetString(Radio, "comando", comando);
  133. KvSetString(Radio, "frase", frase);
  134. CloseHandle(Radio);
  135. }
  136.  
  137. stock void comandosfrases(char [] web, char [] title)
  138. {
  139. char frase[64];
  140. gc_sfrase.GetString(frase, sizeof(frase));
  141. Format(frase, 512, "%s/skipperbom%s!skipper;", frase, comando);
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement