SA-MP Forums Archive
Little bank system help - 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: Little bank system help (/showthread.php?tid=635623)



Little bank system help - RxErT - 10.06.2017

Hello so i created a little bank system in my script, the problem is when i type /withdraw <amount> it not showing a message that i have withdrawn or i don't have that much to withdraw and same thing in /deposit <amount>, and when i /checkbalance it says 0$..

PHP код:
CMD:deposit(playeridparams[])
{
    new 
string[256];
    new 
type;
    {
    if(
sscanf(params"i"type)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {f00f00}/deposit <amount>");
    if(
type == 0)
    if(
GetPlayerMoney(playerid) < type)
    {
    
GivePlayerMoney(playerid,-type);
    
PlayerInfo[playerid][pBankAccount] += type;
    
format(stringsizeof(string), "[BANK]: {Ffffff}You have successfully deposited {f00f00}$%d {FFFFFF}to your bank account."type);
    
SendClientMessage(playerid0xf8f8f8fffstring);
    }
    else 
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You do not have that much amount in your hand");
    }
    return 
1;
}
CMD:withdraw(playerid,params[])
{
   new 
string[256];
   new 
type;
   {
   if(
sscanf(params"i"type)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {f00f00}/withdraw <amount>");
   if(
type == 0)
   if(
PlayerInfo[playerid][pBankAccount] >= type)
   {
   
PlayerInfo[playerid][pBankAccount] -= type;
   
GivePlayerMoney(playeridtype);
   
format(stringsizeof(string), "[BANK]: {FFFFFF}You have successfully withdrawn {f00f00}$%d {FFFFFF}from your bank account."type);
   
SendClientMessage(playerid0xF8f8f8fffstring);
   }
   else 
SendClientMessage(playerid0xF8f8f8ffF"ERROR: {FFFFFF}You do not have that much amount in your account");
   }
   return 
1;
}
CMD:checkbalance(playerid,params[])
{
   new 
string[256];
   
format(stringsizeof(string), "[BANK] {FFFFFF}You currently have $%d In your bank account."PlayerInfo[playerid][pBankAccount]);
   
SendClientMessage(playerid,0xf8f8f8fff,string);
   return 
1;

Usiing Y_INI.


Re: Little bank system help - Vince - 10.06.2017

Quote:
PHP код:
if(type == 0
Why are those there? It makes it so that pretty much anything below those lines can only be reached if the amount to deposit or withdraw is 0. Moreover, why do you call it "type" instead of "money" or "cash" or "amount"?


Re: Little bank system help - RxErT - 10.06.2017

Quote:
Originally Posted by Vince
Посмотреть сообщение
Why are those there? It makes it so that pretty much anything below those lines can only be reached if the amount to deposit or withdraw is 0. Moreover, why do you call it "type" instead of "money" or "cash" or "amount"?
Do you suggest to change type to amount and remove if(type == 0)?


Re: Little bank system help - Bolex_ - 10.06.2017

Obviously you took it from ( https://sampforum.blast.hk/showthread.php?tid=377615 ). Just take a look a nd made it like this!


Re: Little bank system help - RxErT - 10.06.2017

Thank you Bolex_,

OT: i take it from a tut not from scripting help.