bank save
#1

How to make that the bank account remained at an exit of the player?
Reply
#2

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
Reply
#3

thanks =)
Reply
#4

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
pawn Код:
new pBank[MAX_PLAYERS];
, 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)
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)