Bank Help
#1

I have the /balance cmds and stuff setup, but i was wondering if you guys could give me an example of how to make the deposit command. Like what i really mean is how would i do like if the money you type into to the deposit
cmd isn't enough then it won't let you put the money in. Like if it is higher than the ammount of money on you then it won't work.

Sorry for my bad grammar :O :/
Reply
#2

pawn Код:
//Shown here with ZCMD and sscanf:
CMD:deposit(playerid, params[])
{
     new cash, amt, bank;
     cash = GetPlayerMoney(playerid); //Get the amount of cash the player has
     if(sscanf(params, "i", amt)) return SendClientMessage(COLOR_RED, "Usage: /deposit [amount]");
     else if(amt > cash) return SendClientMessage(COLOR_RED, "You do not have this much cash to deposit!");//Check to see if it is more than what you have
     else
     {
          GivePlayerMoney(playerid, -amt);
          bank = PlayerInfo[playerid][pBank];// Substitute how you are storing the bank info
          PlayerInfo[playerid][pBank] = bank+amt; //Update Bank amount in pInfo enum or whatever you have
     }
     return 1;
}
Reply
#3

Quote:
Originally Posted by randomkid88
Посмотреть сообщение
pawn Код:
GivePlayerMoney(playerid, cash-amt);
This part should be..
pawn Код:
SetPlayerMoney(playerid, cash-amt);
:P
Reply
#4

Quote:
Originally Posted by [DM]Kane
Посмотреть сообщение
This part should be..
pawn Код:
SetPlayerMoney(playerid, cash-amt);
:P
Why should it be SetPlayerMoney instead of GivePlayerMoney?

SetPlayerMoney must be a custom function as it's not native.

Besides, if anything, it should be changed to
pawn Код:
GivePlayerMoney(playerid, - amt);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)