Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #define dicatexto 0xFF8000AA
- #define Green 0x33AA33AA
- #define Yellow 0xFFFF00AA
- #define COLOR_RED 0xFF0000AA
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[128], idx;
- cmd = strtok(cmdtext, idx);
- if(strcmp(cmd, "/dica", true) == 0)
- {
- new length = strlen(cmdtext);
- while ((idx < length) && (cmdtext[idx] <= ' '))
- {
- idx++;
- }
- new offset = idx;
- new result[64];
- while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
- {
- result[idx - offset] = cmdtext[idx];
- idx++;
- }
- result[idx - offset] = EOS;
- if(!strlen(result))
- {
- SendClientMessage(playerid,dicatexto, "/dica [sua Dica]");
- return 1;
- }
- new
- stringdica[128],
- stringdicaver[128],
- pname[20],
- msgadmins[128];
- GetPlayerName(playerid, pname, sizeof(pname));
- new File:dicas=fopen("dicas.txt", io_append);
- format(stringdica, sizeof(stringdica), "Player: %s - Dica: %s\r\n", pname, (result));
- fwrite(dicas, stringdica);
- fclose(dicas);
- SendClientMessage(playerid, Green, "sua dica foi enviada no seguinte formato:");
- format(stringdicaver, sizeof(stringdicaver), "Player: %s - Dica: %s", pname, (result));
- SendClientMessage(playerid, Yellow, stringdicaver);
- SendClientMessage(playerid, Green, "Obrigado pela contribuição.");
- format(msgadmins, sizeof(msgadmins), "||Nova dica||Player: %s - Dica: %s", pname, (result));
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(IsPlayerAdmin(i))
- {
- SendClientMessage(i, Yellow, msgadmins);
- }
- }
- }
- return 1;
- }
- if(strcmp(cmd, "/dicas", true) == 0)
- {
- new stringw[512];
- new File:file=fopen("dicas.txt",io_read);
- new l;
- while(fread(file,stringw))
- {
- l++;
- if(l > 0)
- {
- SendClientMessage(playerid,COLOR_RED,stringw);
- }
- }
- fclose(file);
- return 1;
- }
- return 0;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement