Guest User

Filterscript: Sistema de SPIN

a guest
Jul 13th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.21 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define COLOR_ERRO 0x800000FF
  4. #define COLOR_VERDE 0x80FF00FF
  5.  
  6. forward SendMSG();
  7.  
  8. new bool:spinusar[MAX_PLAYERS];
  9. forward SpinUsar1(playerid);
  10.  
  11. #if defined FILTERSCRIPT
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     print("\n--------------------------------------");
  16.     print("> Sistema de SPIN: Ligado");
  17.     print("> Criado por Neto com ajuda de Cidiei");
  18.     print("--------------------------------------\n");
  19.     SetTimer("SendMSG", 300000, true);
  20.     return 1;
  21. }
  22.  
  23. public OnFilterScriptExit()
  24. {
  25.         KillTimer(SendMSG);
  26.         return 1;
  27. }
  28.  
  29. #endif
  30. public OnPlayerConnect(playerid)
  31. {
  32.     SendClientMessage(playerid,COLOR_VERDE, "Sistema de SPIN criado por Neto com ajuda de Cidiei!");
  33.     spinusar[playerid] = true;
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerCommandText(playerid, cmdtext[])
  38. {
  39.     new cmd[256];
  40.     new idx;
  41.     cmd = strtok(cmdtext, idx);
  42.     if(strcmp(cmd, "/spin", true) == 0)
  43.     {
  44.         new string[256];
  45.         new tmp[256];
  46.         new guito,playerguito;
  47.         new pname[24];
  48.         GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
  49.         tmp = strtok(cmdtext, idx);
  50.         if(!strlen(tmp))
  51.         {
  52.             SendClientMessage(playerid, COLOR_ERRO, "[ERRO:]{ffffff} Use /spin [dinheiro]");
  53.             return 1;
  54.         }
  55.         guito = strval(tmp);
  56.         if(guito < 1 || guito > 50000)
  57.         {
  58.             SendClientMessage(playerid, COLOR_ERRO, "[SPIN:]{ffffff} Quantia invΓ‘lida, tem que ser mais de 0 e menos de 50000");
  59.             return 1;
  60.         }
  61.         if(spinusar[playerid] == true)
  62.         {
  63.             playerguito = GetPlayerMoney(playerid);
  64.             if (guito > 0 && playerguito >= guito)
  65.             {
  66.                 new succeed = 1 + random(4);
  67.                 if(succeed == 1)
  68.                 {
  69.                     format(string, sizeof(string), "[SPIN:]{ffffff} %s tentou jogar no spin e ganhou {66ff00}%d", pname, guito);
  70.                     SendClientMessageToAll(COLOR_VERDE, string);
  71.                     GivePlayerMoney(playerid, guito);
  72.                     spinusar[playerid] = false;
  73.                     SetTimerEx("SpinUsar1", 30000, false, "d", playerid);
  74.                 }
  75.                 else if(succeed == 2 || succeed == 3 || succeed == 4)
  76.                 {
  77.                     format(string, sizeof(string), "[SPIN:]{ffffff} %s tentou jogar no spin e perdeu {A81C1C}%d", pname, guito);
  78.                     SendClientMessageToAll(COLOR_VERDE, string);
  79.                     GivePlayerMoney(playerid, -guito);
  80.                     spinusar[playerid] = false;
  81.                     SetTimerEx("SpinUsar1", 30000, false, "d", playerid);
  82.                 }
  83.             }
  84.             else
  85.             {
  86.                 SendClientMessage(playerid, COLOR_ERRO, "[SPIN:]{ffffff} NΓ£o tens esse dinheiro todo");
  87.             }
  88.         }
  89.         else
  90.         {
  91.             SendClientMessage(playerid, COLOR_ERRO, "[SPIN:]{ffffff} Espera 30 segundos para voltar a usar o comando");
  92.         }
  93.         return 1;
  94.     }
  95.     return 0;
  96. }
  97.  
  98. stock strtok(const string[], &index)
  99. {
  100.     new length = strlen(string);
  101.     while ((index < length) && (string[index] <= ' '))
  102.     {
  103.         index++;
  104.     }
  105.  
  106.     new offset = index;
  107.     new result[20];
  108.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  109.     {
  110.         result[index - offset] = string[index];
  111.         index++;
  112.     }
  113.     result[index - offset] = EOS;
  114.     return result;
  115. }
  116.  
  117. public SpinUsar1(playerid)
  118. {
  119.     spinusar[playerid] = true;
  120.     return 1;
  121. }
  122.  
  123. public SendMSG()
  124. {
  125.     new string[500];
  126.     format(string, sizeof(string), "Sistema de SPIN criado por Neto com ajuda de Cidiei!");
  127.     SendClientMessageToAll(COLOR_VERDE, string);
  128. }
Advertisement
Add Comment
Please, Sign In to add comment