Advertisement
Guest User

Untitled

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