Could Someone please make a Banking system !
#1

Could Someone make a Banking system that uses the 24/7 shops that are all over San Andreas. i would like commands like withdraw, deposit. also it would be good if it remembers their money even when the server has been restarted.



Reply
#2

By the commands do you mean a dialog or menus?
Reply
#3

You will need a registration system to save the money when they disconnect. I won't write a temp code because it will mess up if you get a registration system.

Writen from scratch here, please report any errors, not tested!
This uses DCMD, a fast command processor. Use the SEARCH function to find the define for it.

Код:
// Top of script below your #includes
new money[MAX_PLAYERS];
new string[128];

#define MAX_BANK 200000000 // 2 Million dollars, change to your linking.

public OnPlayerCommandText(playerid, cmdtext[])
{
   dcmd(withdraw,8,cmdtext);
   dcmd(deposit,7,cmdtext);
   dcmd(bank,4,cmdtext);
   
   return 1;
}

dcmd_deposit(playerid,params)
{
   new m, p;
   m = GetPlayerMoney(playerid);
   p = strval(params);
   if(m < p) return SendClientMessage(playerid, color, "ERROR: You do not have that much cash.");
   if(p > MAX_MONEY) return SendClientMessage(playerid, color, "ERROR: You cannot put that much cash in the bank.");
   if(!strlen(params)) return SendClientMessage(playerid, color, "ERROR: Please enter a value!");
   money[playerid] = p+money[playerid];
   format(string,sizeof(string),"You've sucessfully put $%d into your bank account, your balance is now $%d.",p, money[playerid]);
   SendClientMessage(playerid, color, string);
   return 1;
}

dcmd_withdraw(playerid,params[])
{
   new m, p;
   m = GetPlayerMoney(playerid;
   p = strval(params);
   if(p > money[playerid]) return SendClientMessage(playerid, color, "ERROR: You do not have that much in your bank account.");
   if(!strlen(params)) return SendClientMessage(playerid, color, "ERROR: Please enter a value.");
   money[playerid] = money[playerid] - p;
   format(string,sizeof(string),"You've sucessfully taken $%d from your bank account. your balance is now $%d.", p, money[playerid]);
   SendClientMessage(playerid, color, string);
   return 1;
}

dcmd_bank(playerid, params[])
{
   format(string,sizeof(string),"You have $%d in your bank account.",money[playerid]);
   SendClientMessage(playerid, color, string);
   return 1;
}
REMEMBER: It's not tested! and it's not been writen in a pawn doc, so any errors, tell me, i'll fix them.
And you'll have to get the 24/7 locations yourself and use the

Код:
IsPlayerInRangeOfPoint
Function in an if( code.

By the way, is that picture in your sig -REALLY- necessary?
Reply
#4

Could you make it into a FS that saves the data into scriptfiles? I can't make that work as i cannot script very well.

(From XxJoexX on friends account)
Reply
#5

I'm currently very busy, so I can't keep writing code.

You can use DINI/DUDB by dracoblue.
OR use SA-MP's native (but slower) file functions.

SAMP File Functions: HERE

EDIT- There's some bank filterscripts out there too, you could have a look into those.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)