Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FilterScript
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- //DIALOG IDS
- #define DIALOG_COINS 69
- //COLORS
- #define RED 0xFF0000AA
- enum pInfo
- {
- pCoins
- };
- new PlayerInfo[MAX_PLAYERS][pInfo];
- IsNumeric(const string[])
- {
- for (new i = 0, j = strlen(string); i < j; i++)
- {
- if (string[i] > '9' || string[i] < '0') return 0;
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- PlayerInfo[playerid][pCoins] = 0;
- return 1;
- }
- CMD:convert(playerid,params[])
- {
- ShowPlayerDialog(playerid,DIALOG_COINS,DIALOG_STYLE_INPUT,"Convert","Convert your money into coins.","Convert","Exit");
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_COINS)
- {
- if(response)
- {
- new money,pstring[128],coins;
- coins = strval(inputtext);
- money = GetPlayerMoney(playerid);
- if(sscanf(inputtext,"%d",coins)) return SendClientMessage(playerid,RED,"ERROR: Please enter the ammount coins you wish to purchase.");
- if(!IsNumeric(inputtext)) return SendClientMessage(playerid,RED,"ERROR: Please enter a numeric value.");
- if(coins < 0) return SendClientMessage(playerid,RED,"ERROR: You cannot enter a negative ammount.");
- if(coins > money/1000) return SendClientMessage(playerid,RED,"ERROR: You do not have enough money to purchase that ammount of coins.");
- else
- {
- GivePlayerMoney(playerid,coins*-1000);
- PlayerInfo[playerid][pCoins] = coins;
- format(pstring,sizeof(pstring),"COINS: You have received %d coins for $%d.",coins,coins*1000);
- SendClientMessage(playerid,RED,pstring);
- }
- }
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement