20.12.2013, 19:40
First is my Shop, I'm trying to make it so if they don't have enough money they can't buy from the shop, I tried messing with GetPlayerMoney but to no success.
Код:
#if defined FILTERSCRIPT public OnFilterScriptInit() { print("Shop System"); return 1; } #endif public OnFilterScriptExit() { print("Shop System"); return 1; } public OnPlayerText(playerid, text[]) { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/shop", cmdtext, true, 10) == 0) { ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Shop Menu", "Deagle($250)\nAK-47($500)\nM4($500)\nGrenade($250)\nSniper($500)\nMP5($500)\nArmor($1000)", "Choose", "Exit"); return 1; } return 0; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 1) // Menu Help Dialog { if(!response) return SendClientMessage(playerid, 0xFFFFFFAA, "Selection Canceled!"); switch(listitem) { case 0: // Deagle { GivePlayerWeapon(playerid, 24, 50); GivePlayerMoney(playerid, -250); return 1; } case 1: // AK-47 { GivePlayerWeapon(playerid, 30, 200); GivePlayerMoney(playerid, -500); return 1; } case 2: // M4 { GivePlayerWeapon(playerid, 31, 150); GivePlayerMoney(playerid, -500); return 1; } case 3: // Grenade { GivePlayerWeapon(playerid, 16, 2); GivePlayerMoney(playerid, -250); return 1; } case 4: // Sniper { GivePlayerWeapon(playerid, 34, 25); GivePlayerMoney(playerid, -500); return 1; } case 5: // MP5 { GivePlayerWeapon(playerid, 29, 200); GivePlayerMoney(playerid, -500); return 1; } case 6: // Armor { SetPlayerArmour(playerid, 100.0); GivePlayerMoney(playerid, -1000); return 1; } } } }
My next question is about my /heal command (sorry I'm a noob)
Код:
{ if (strcmp("/heal", cmdtext, true, 10) == 0) { if(GetPlayerMoney(playerid) >= -250) SetPlayerHealth(playerid, 100); GivePlayerMoney(playerid, -250); } else { SendClientMessage(playerid, -1, "You don't have enough money!"); } }
Everytime someone types /heal or /shop and buys something, even if they don't have money, it lets them and if they have $0 they go negative. How do you check the players money so it doesn't give it to them if they don't have enough?
Credits to GhostPerk77 for the dialog menu