Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <colorvariables>
- public Plugin:myinfo = {
- name = "Comandos4Frases",
- author = "SkippeR",
- description = "Imprime uma frase no chat.",
- url = ""
- };
- Handle g_Comandos;
- Handle g_Frases;
- char g_ServerIp [32];
- char g_ServerPort [16];
- KeyValues g_hComandosfrase;
- ConVar gc_sURL;
- ConVar g_hEnabled;
- ConVar g_hFile;
- public OnPluginStart()
- {
- CreateConVar("sm_comandos4frase_version", PLUGIN_VERSION, "", FCVAR_NOTIFY|FCVAR_REPLICATED);
- g_hEnabled = CreateConVar("sm_comandos_enabled", "1", "ligar o desligar esta merda.");
- g_hFile = CreateConVar("sm_comandos_file", "comandos.txt", "Para ler comando e frase");
- g_hFile.AddChangeHook(ConVarChange_File);
- RegConsoleCmd("say", OnSay);
- RegConsoleCmd("say_team", OnSay);
- RegAdminCmd("sm_cff", Command_Comandos, ADMFLAG_GENERIC,"Abre frase no chat");
- g_Comandos = CreateArray(32);
- g_Frases = CreateArray(64);
- Handle cvar = FindConVar("hostip");
- int hostip = GetConVarInt(cvar);
- FormatEx(g_ServerIp, sizeof(g_ServerIp), "%u.%u.%u.%u",
- (hostip >> 24) & 0x000000FF, (hostip >> 16) & 0x000000FF, (hostip >> 8) & 0x000000FF, hostip & 0x000000FF);
- cvar = FindConVar("hostport");
- GetConVarString(cvar, g_ServerPort, sizeof(g_ServerPort));
- LoadComandos4Frase();
- }
- public OnMapStart()
- {
- LoadComandos4Frase();
- }
- LoadComandos4Frase()
- {
- char buffer [1024];
- BuildPath(Path_SM, buffer, sizeof(buffer), "configs/comandos.txt");
- if (!FileExists(buffer))
- {
- return;
- }
- Handle f = OpenFile(buffer, "r");
- if (f == INVALID_HANDLE)
- {
- LogError("[SM] Could not open file: %s", buffer);
- return;
- }
- ClearArray(g_Comandos);
- ClearArray(g_Frases);
- char comando [32];
- char frase [256];
- while (!IsEndOfFile(f) && ReadFileLine(f, buffer, sizeof(buffer)))
- {
- TrimString(buffer);
- if (buffer[0] == '\0' || buffer[0] == ';' || (buffer[0] == '/' && buffer[1] == '/'))
- {
- continue;
- }
- int pos = BreakString(buffer, comando, sizeof(comando));
- if (pos == -1)
- {
- continue;
- }
- int frasePos = BreakString(buffer[pos], frase, sizeof(frase));
- if (frasePos == -1)
- {
- continue;
- }
- strcopy(frase, sizeof(frase), buffer[frasePos+pos]);
- TrimString(link);
- PushArrayString(g_Comandos, comando);
- PushArrayString(g_Frases, frase);
- }
- CloseHandle(f);
- }
- public Action Command_Comandos(int client, int args)
- {
- if (args < 2)
- {
- ReplyToCommand(client, "[SM] Usage: !cff ");
- return Plugin_Handled;
- }
- char pattern[96], buffer[64], frase[512];
- GetCmdArg(1, pattern, sizeof(pattern));
- GetCmdArg(2, frase, sizeof(frase));
- int targets[129];
- bool ml = false;
- int count = ProcessTargetString(pattern, client, targets, sizeof(targets), 0, buffer, sizeof(buffer), ml);
- if(StrContains(frase, "", false) != 0) Format(frase, sizeof(frase), "", frase);
- if (count <= 0) ReplyToCommand(client, "Bad target");
- return Plugin_Handled;
- }
- public comandofrase(char [] comando, char [] frase, int client)
- {
- Handle Radio = CreateKeyValues("data");
- KvSetString(Radio, "comando", comando);
- KvSetString(Radio, "frase", frase);
- CloseHandle(Radio);
- }
- stock void comandosfrases(char [] web, char [] title)
- {
- char frase[64];
- gc_sfrase.GetString(frase, sizeof(frase));
- Format(frase, 512, "%s/skipperbom%s!skipper;", frase, comando);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement