SA-MP Forums Archive
Simple Mistakes, Could someone tell me why? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Simple Mistakes, Could someone tell me why? (/showthread.php?tid=394513)



Simple Mistakes, Could someone tell me why? - Dokins - 22.11.2012

This is a silly mistake, I tried to take out $1,000 and it set the money to -$1000 in the house.


pawn Код:
if(!(strcmp(item, "money", true)))
            {
                PlayerMoney[playerid] = GetPlayerMoney(playerid);
                if(sscanf(params, "s[24]s[32]d",usage,item,slot))
                {
                    SendClientMessage(playerid, COLOUR_GREY, "Usage: /house get money [amount]");
                    return 1;

                }
                if(HouseMoney[houseid] < slot) return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money stored in your house.");
                if(slot < 1 || slot  > 100000) return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $100,000");
                HouseMoney[houseid] = HouseMoney[playerid] -= slot;
                PlayerMoney[playerid] = PlayerMoney[playerid] + slot;
                GivePlayerMoney(playerid, PlayerMoney[playerid]);
                MySQL_SetInteger(houseid, "HouseMoney", HouseMoney[houseid], "houses");
                MySQL_SetInteger(PlayerSQLID[playerid], "Money", PlayerMoney[playerid], "accounts");
                format(string, sizeof(string), "You have taken $%d from your house,you now have a total of: $%d in your house", slot, HouseMoney[houseid]);
                SendClientMessage(playerid, COLOUR_BLUE, string);
                format(string, sizeof(string), "* %s has taken some money from their house.", GetNameEx(playerid));
                ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
            }



Re: Simple Mistakes, Could someone tell me why? - Babul - 22.11.2012

hm...
Код:
HouseMoney[houseid] = HouseMoney[playerid] - slot;
PlayerMoney[playerid] = PlayerMoney[playerid] + slot;
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerMoney[playerid]);
or
Код:
HouseMoney[houseid] -= slot;
PlayerMoney[playerid] += slot;
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerMoney[playerid]);