bank save - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: bank save (
/showthread.php?tid=153446)
bank save -
[1corp]vlad - 08.06.2010
How to make that the bank account remained at an exit of the player?
Re: bank save -
Maxips2 - 08.06.2010
Use Dini/MySQL
I can help you with Dini, but I can't help you with MySQL
At top of the mod:
Quote:
enum Info
{
Bank
}
new PlayerInfo[MAX_PLAYERS][Info];
|
Make a command to bank the money, like:
Quote:
if (strcmp(cmd, "/deposit", true) == 0)
{
new pmoney;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /deposit [Amount]");
pmoney=strval(tmp);
pmoney = dini_IntSet(file, "Bank", (GetPlayerMoney(playerid));
GivePlayerMoney(playerid,-pmoney);
return 1;
}
|
And a command to withdraw:
Quote:
if (strcmp(cmd, "/withdraw", true) == 0)
{
new pmoney;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /withdraw [Amount]");
pmoney=strval(tmp);
pmoney = dini_Int(file, "Bank");
if(dini_Int(file, "Bank",) < pmoney)
{
SendClientMessage(playerid,COLOR_WHITE,"You don't have enough cash!");
}
else
{
GivePlayerMoney(playerid,pmoney);
}
return 1;
}
|
I HAVNT TESTED IT, DONT BLAME ME IF IT BLOWS UP
Re: bank save -
[1corp]vlad - 09.06.2010
thanks =)
Re: bank save -
Ignas1337 - 09.06.2010
well one thing: don't use enum for 1 value, it's a waste of lines, really... you would probably be better off with doing
, however instead of MAX_PLAYERS i suggest using the max number of connections to your sever, not the theorical maximum player count (if your server has a limit of 200 players, why should one use the other 300 which are never used? waste of memory)
Re: bank save - WackoX - 09.06.2010
Then put this also on top of your script:
Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 30 // if your server has 30 slots, how less how better.