12.03.2012, 18:45
For some reason, Players are logging out with $1 in their bank, I've tried it, I've put $4 in, come and login in $1.
SavePlayerStats
Withdraw and Bank
SavePlayerStats
pawn Код:
dUserSetINT(PlayerName2(playerid)).("Money",GetPlayerMoney(playerid));
dUserSetINT(PlayerName2(playerid)).("Kills",AccInfo[playerid][Kills]);
dUserSetINT(PlayerName2(playerid)).("Deaths",AccInfo[playerid][Deaths]);
dUserSetINT(PlayerName2(playerid)).("WantedLevel",GetPlayerWantedLevel(playerid));
dUserSetINT(PlayerName2(playerid)).("clan",AccInfo[playerid][clan]);
dUserSetINT(PlayerName2(playerid)).("clanleader",AccInfo[playerid][clanleader]);
dUserSetINT(PlayerName2(playerid)).("bank",AccInfo[playerid][bank]);
pawn Код:
dcmd_bank(playerid,params[])
{
#pragma unused params
{
new tmp[128];
new string[128];
new idx;
if(!IsPlayerInRangeOfPoint(playerid, 50.0, 1422.7039,-988.4125,1639.7843))
{
SendClientMessage(playerid, grey, " You are not at the bank !");
return 1;
}
tmp = strtok(params, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bank [amount]");
format(string, sizeof(string), " You have $%d in your bank account.", AccInfo[playerid][bank]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
new cashdeposit = strvalEx(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bank [amount]");
format(string, sizeof(string), " You have $%d in your bank account.", AccInfo[playerid][bank]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
if(cashdeposit > GetPlayerMoney(playerid) || cashdeposit < 1)
{
SendClientMessage(playerid, COLOR_WHITE, " You don't have that much !");
return 1;
}
new curfunds = AccInfo[playerid][bank];
GivePlayerMoney(playerid,-cashdeposit);
AccInfo[playerid][bank] = cashdeposit+AccInfo[playerid][bank];
format(string, sizeof(string), " Old Balance: $%d", curfunds);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " Deposit: $%d",cashdeposit);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " New Balance: $%d", AccInfo[playerid][bank]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
return 1;
}
dcmd_withdraw(playerid,params[])
{
#pragma unused params
{
new tmp[128];
new string[128];
new idx;
if(!IsPlayerInRangeOfPoint(playerid, 50.0, 1422.7039,-988.4125,1639.7843))
{
SendClientMessage(playerid, grey, " You are not at the bank !");
return 1;
}
tmp = strtok(params, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /withdraw [amount]");
format(string, sizeof(string), " You have $%d in your bank account.", AccInfo[playerid][bank]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
new cashdeposit = strvalEx(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /withdraw [amount]");
format(string, sizeof(string), " You have $%d in your bank account.", AccInfo[playerid][bank]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
if(cashdeposit > AccInfo[playerid][bank] || cashdeposit < AccInfo[playerid][bank])
{
SendClientMessage(playerid, COLOR_WHITE, " You don't have that much !");
return 1;
}
new curfunds = AccInfo[playerid][bank];
GivePlayerMoney(playerid,cashdeposit);
AccInfo[playerid][bank] = cashdeposit-AccInfo[playerid][bank];
format(string, sizeof(string), " Old Balance: $%d", curfunds);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " Withdraw: $%d",cashdeposit);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " New Balance: $%d", AccInfo[playerid][bank]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
return 1;
}