22.07.2012, 01:54
For some reason, once you spend money in my script, the funds are deducted then sent back to the player.
This happens with /shop and /pay
This happens with /shop and /pay
return 1;
}
if(dialogid == DIALOGID+4)
{
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <200)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough money to purchase this item!");
GivePlayerMoney(playerid, -200);
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, COLOR_GREEN, "Thank you for purchasing a Armour! ($200)");
ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "Shop", "Pistols\nSub-Machine Gun\nShotguns\nArmours\nSMG\nAssault", "Select", "Cancel");
}
CMD:pay(playerid, params[])
{
new Target, Amount;
if( !sscanf(params, "ui", Target, Amount) )
{
if( Amount < 1 ) return SendClientMessage(playerid, -1, "Minimum amount: 1"); // if amount is lower as 5
if( Target == INVALID_PLAYER_ID ) return SendClientMessage(playerid, -1, "Invalid playerid!"); // if target is an invalid playerid
if( Target == playerid ) return SendClientMessage(playerid, -1, "You cant pay yourself."); // if youre the target
if( GetPlayerMoney(playerid) < Amount ) return SendClientMessage(playerid, -1, "You dont have that amount of cash."); // if you dont have enough money you wanted to send to the player
GivePlayerMoney(playerid, -Amount); // removing the money from you
GivePlayerMoney(Target, Amount); // adding the money to you
} else return SendClientMessage(playerid, -1, "Usage: /pay <playerid> <money>");
return 1;
}