Advertisement
Guest User

Untitled

a guest
Mar 15th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.70 KB | None | 0 0
  1. #define FilterScript
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5. #include <sscanf2>
  6.  
  7. //DIALOG IDS
  8. #define DIALOG_COINS 69
  9.  
  10. //COLORS
  11. #define RED 0xFF0000AA
  12.  
  13. enum pInfo
  14. {
  15.     pCoins
  16. };
  17. new PlayerInfo[MAX_PLAYERS][pInfo];
  18.  
  19. IsNumeric(const string[])
  20. {
  21.         for (new i = 0, j = strlen(string); i < j; i++)
  22.         {
  23.                 if (string[i] > '9' || string[i] < '0') return 0;
  24.         }
  25.         return 1;
  26. }
  27. public OnPlayerConnect(playerid)
  28. {
  29.     PlayerInfo[playerid][pCoins] = 0;
  30.     return 1;
  31. }
  32.  
  33. CMD:convert(playerid,params[])
  34. {
  35.     ShowPlayerDialog(playerid,DIALOG_COINS,DIALOG_STYLE_INPUT,"Convert","Convert your money into coins.","Convert","Exit");
  36.     return 1;
  37. }
  38. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  39. {
  40.     if(dialogid == DIALOG_COINS)
  41.     {
  42.         if(response)
  43.         {
  44.             new money,pstring[128],coins;
  45.             coins = strval(inputtext);
  46.             money = GetPlayerMoney(playerid);
  47.             if(sscanf(inputtext,"%d",coins)) return SendClientMessage(playerid,RED,"ERROR: Please enter the ammount coins you wish to purchase.");
  48.             if(!IsNumeric(inputtext)) return SendClientMessage(playerid,RED,"ERROR: Please enter a numeric value.");
  49.             if(coins < 0) return SendClientMessage(playerid,RED,"ERROR: You cannot enter a negative ammount.");
  50.             if(coins > money/1000) return SendClientMessage(playerid,RED,"ERROR: You do not have enough money to purchase that ammount of coins.");
  51.             else
  52.             {
  53.                 GivePlayerMoney(playerid,coins*-1000);
  54.                 PlayerInfo[playerid][pCoins] = coins;
  55.                 format(pstring,sizeof(pstring),"COINS: You have received %d coins for $%d.",coins,coins*1000);
  56.                 SendClientMessage(playerid,RED,pstring);
  57.             }
  58.         }
  59.         return 1;
  60.     }
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement