toribio

toribio

Jan 19th, 2009
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. public OnPlayerCommandText(playerid, cmdtext[])
  2. {
  3.     if(!strcmp(cmd, "/tickets", true))
  4.     {
  5.         new tmp[256];
  6.         tmp = strtok(cmdtext, idx); //voc� esqueceu de definir o valor string da vari�vel tmp.
  7.         new value = strval(tmp); //fica mais bonito
  8.         if(!strlen(tmp))
  9.             return SendClientMessage(playerid, 0xFFFFFFAA, "USE: /tickets [quantia]");
  10.         if(GetPlayerMoney(playerid) > 0)
  11.         {
  12.             new tickets = (GetPlayerMoney(playerid) < (value * 50)) ? (GetPlayerMoney(playerid) / 50) : value;
  13.             //n�o adianta tentar entender a express�o acima ^^
  14.             GivePlayerTickets(playerid, tickets);
  15.             GivePlayerMoney(playerid, -(tickets * 50));
  16.             format(string, sizeof(string), "Antes voc� tinha %d ticket%s, comprou %d ticket%s com %d reais e agora tem %d ticket%s",
  17.                 GetPlayerTickets(playerid)-tickets, GetPlayerTickets(playerid) > 1 ? ("s") : (""), tickets, tickets > 1 ? ("s") : (""), tickets*50, GetPlayerTickets(playerid));
  18.             SendClientMessage(playerid, COLOR_GREEN, string);
  19.         } else {
  20.             SendClientMessage(playerid, 0xFF0000AA, "Voc� n�o tem dinheiro!");
  21.         }
  22.         return 1; //pra n�o aparecer "SERVER: Unknown command."
  23.     }
  24.     //o resto dos comandos...
  25.     return 0; //pra apaerecer "SERVER: Unknown command." caso o comando n�o exista...
  26. }
Advertisement
Add Comment
Please, Sign In to add comment