Hello i have download one bank system but here is one bug example if i deposit money and join with other account and see my balance i can see and the money that I put with my last account here is and code
pawn Код:
#include <a_samp>
#include <dini>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
forward Update(playerid);
enum pInfo
{
Banka
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnFilterScriptInit()
{
SetTimer("Update",900000,1);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#endif
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, 0xF0F0F0FF, ">> This server use Bank System from ExtremePower/DarkPower <<");
new file[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"%s.ini",name);
if(!fexist(file))
{
dini_Create(file);
dini_IntSet(file,"Banka", PlayerInfo[playerid][Banka]);
}
if(fexist(file))
{
PlayerInfo[playerid][Banka] = dini_Int(file,"Banka");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new file[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"%s.ini",name);
if(fexist(file))
{
dini_IntSet(file,"Banka", PlayerInfo[playerid][Banka]);
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/deposit", cmdtext, true, 7) == 0)
{
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof string, "Account: %s\n\nType amount of money you wanna deposit in bank:", name);
ShowPlayerDialog(playerid, 2000, DIALOG_STYLE_INPUT, "Bank system | ExtremePower", string, "Deposit", "Cancel");
return 1;
}
if (strcmp("/withdraw", cmdtext, true, 8) == 0)
{
new string2[128];
new name2[MAX_PLAYER_NAME];
GetPlayerName(playerid, name2, sizeof(name2));
format(string2, sizeof string2, "Account: %s\n\nBalance: %d$\n\nType amount of money you wanna withdraw from bank:", name2,PlayerInfo[playerid][Banka]);
ShowPlayerDialog(playerid, 2001, DIALOG_STYLE_INPUT, "Bank system | ExtremePower", string2, "Withdraw", "Cancel");
return 1;
}
if (strcmp("/balance", cmdtext, true, 7) == 0)
{
new name3[MAX_PLAYER_NAME];
GetPlayerName(playerid, name3, sizeof(name3));
new string3[128];
format(string3, sizeof string3, "Account: %s\n\nMoney in bank: %d$",name3, PlayerInfo[playerid][Banka]);
ShowPlayerDialog(playerid,2003,DIALOG_STYLE_MSGBOX ,"Bank system | ExtremePower",string3,"OK","Cancel");
return 1;
}
if (strcmp("/bankhelp", cmdtext, true, 8) == 0)
{
ShowPlayerDialog(playerid,2004,DIALOG_STYLE_LIST,"Bank system | ExtremePower","Deposit\nWithdraw\nBalance","Select","Cancel");
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 2000)
{
if(response)
{
new file[128];
new string[128];
new stringdeposit[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(strlen(inputtext) == 0)
{
format(string, sizeof string, "Account: %s\n\nType amount of money you wanna deposit in bank:", name);
ShowPlayerDialog(playerid, 2000, DIALOG_STYLE_INPUT, "Bank system | ExtremePower", string, "Deposit", "Cancel");
return 0;
}
format(file,sizeof(file),"%s.ini",name);
if(fexist(file))
{
dini_IntSet(file,"Banka",strlen(inputtext));
if(strval(inputtext)>0){
if(GetPlayerMoney(playerid) < strval(inputtext)) return SendClientMessage(playerid, 0xFF0005FF, "You dont have that money in your pocket.");
GivePlayerMoney(playerid,-strval(inputtext));
PlayerInfo[playerid][Banka]+=strval(inputtext);
format(stringdeposit, sizeof stringdeposit, "You just deposit: %d$ | New Balance: %d$", strval(inputtext),PlayerInfo[playerid][Banka]);
SendClientMessage(playerid, 0xFFD200FF, stringdeposit);
}
}
}
}
if(dialogid == 2001)
{
if(response)
{
new file[128];
new name[MAX_PLAYER_NAME];
new stringwithdraw[128];
GetPlayerName(playerid, name, sizeof(name));
if(strlen(inputtext) == 0)
{
new string2[128];
new name2[MAX_PLAYER_NAME];
GetPlayerName(playerid, name2, sizeof(name2));
format(string2, sizeof string2, "Account: %s\n\nBalance: %d$\n\nType amount of money you wanna withdraw from bank:", name2,PlayerInfo[playerid][Banka]);
ShowPlayerDialog(playerid, 2001, DIALOG_STYLE_INPUT, "Bank system | ExtremePower", string2, "Withdraw", "Cancel");
return 0;
}
format(file,sizeof(file),"%s.ini",name);
if(fexist(file))
{
dini_IntSet(file,"Banka",strlen(inputtext));
if(strval(inputtext)>0)
{
if(PlayerInfo[playerid][Banka] < strval(inputtext)) return SendClientMessage(playerid, 0xFF0005FF, "You dont have that money in your bank account.");
GivePlayerMoney(playerid,strval(inputtext));
PlayerInfo[playerid][Banka]-=strval(inputtext);
format(stringwithdraw, sizeof stringwithdraw, "You just withdraw: %d$ | New balance: %d", strval(inputtext),PlayerInfo[playerid][Banka]);
SendClientMessage(playerid, 0xFFD200FF, stringwithdraw);
}
}
}
}
if(dialogid == 2004 && response)
{
switch(listitem)
{
case 0:
{
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof string, "Account: %s\n\nType amount of money you wanna deposit in bank:", name);
ShowPlayerDialog(playerid, 2000, DIALOG_STYLE_INPUT, "Bank system | ExtremePower", string, "Deposit", "Cancel");
}
case 1:
{
new string2[128];
new name2[MAX_PLAYER_NAME];
GetPlayerName(playerid, name2, sizeof(name2));
format(string2, sizeof string2, "Account: %s\n\nBalance: %d$\n\nType amount of money you wanna withdraw from bank:", name2,PlayerInfo[playerid][Banka]);
ShowPlayerDialog(playerid, 2001, DIALOG_STYLE_INPUT, "Bank system | ExtremePower", string2, "Withdraw", "Cancel");
}
case 2:
{
new name3[MAX_PLAYER_NAME];
GetPlayerName(playerid, name3, sizeof(name3));
new string3[128];
format(string3, sizeof string3, "Account: %s\n\nMoney in bank: %d$",name3, PlayerInfo[playerid][Banka]);
ShowPlayerDialog(playerid,2003,DIALOG_STYLE_MSGBOX ,"Bank system | ExtremePower",string3,"OK","Cancel");
}
}
}
return 1;
}
public Update(playerid)
{
new file[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"%s.ini",name);
if(fexist(file))
{
dini_IntSet(file,"Banka", PlayerInfo[playerid][Banka]);
SendClientMessage(playerid, 0xFFFFFFF, "Your bank account is update.");
}
return 1;
}
Try resetting the PlayerInfo[playerid][Banka] variable under OnPlayerConnect before your dini code.
try this,just copy the things and paste it in the gamemode,which ur using,and then change [Banka] to the player account's saving [..]