Money Glitch - 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: Money Glitch (
/showthread.php?tid=95531)
Money Glitch -
Rick_Jones - 03.09.2009
Hey,
I need some help fixing a glitch i cant seem to fix. Whenever you connect to the server, if your money is negative or positive it doubles.
Anyone no how to fix that?
Rick
Re: Money Glitch -
Zeromanster - 03.09.2009
Does it double when you die ? And give us some of your code btw.
Re: Money Glitch -
brett7 - 04.09.2009
what you using to store amounts?
Re: Money Glitch -
Rick_Jones - 04.09.2009
It doubles when u leave and reconnect, everytime.
What part of code u want? Im using a register system.
What part of the code do you need?
Rick
Re: Money Glitch -
brett7 - 04.09.2009
when you register how does it know how much money you have?
Re: Money Glitch -
Rick_Jones - 04.09.2009
It saves it to a file. I went in with 0 bought a gun then checked the file and it was correct. But for somereason it just keeps doubling....
Rick
Re: Money Glitch -
Chaprnks - 04.09.2009
Check what happens to the money on connect. Sometimes it can be unknowingly loaded twice, doubling it.
Re: Money Glitch -
Rick_Jones - 05.09.2009
Ok, I looked at it and couldnt see what was wrong. Im really noob with complex scripts, lol.
Here is the code for what happens when you login(Callback "OnPlayerLogin") I think this is were the problem is. When you login it doubles.
This is the code:
Код:
public OnPlayerLogin(playerid,const string[])
{
new pname2[MAX_PLAYER_NAME];
new pname3[MAX_PLAYER_NAME];
new string2[64];
new string3[128];
GetPlayerName(playerid, pname2, sizeof(pname2));
format(string2, sizeof(string2), "%s.cer", pname2);
new File: UserFile = fopen(string2, io_read);
if (UserFile)
{
new valtmp[128];
fread(UserFile, valtmp);strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
if ((strcmp(PlayerInfo[playerid][pPassword], string, true, strlen(valtmp)-1) == 0))
{
new key[128],val[128];
new Data[128];
while(fread(UserFile,Data,sizeof(Data)))
{
key = ini_GetKey(Data);
if( strcmp( key , "Kills" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pKills] = strval( val ); }
if( strcmp( key , "Deaths" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDeaths] = strval( val ); }
if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
if( strcmp( key , "Adminlevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdminlevel] = strval( val ); }
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
}
fclose(UserFile);
gPlayerLogged[playerid] = 1;
gPlayerAccount[playerid] = 1;
new kills = PlayerInfo[playerid][pKills];
SetPlayerScore(playerid, kills);
GetPlayerName(playerid, pname3, sizeof(pname3));
format(string3, sizeof(string3), "Welcome %s, you have been succesfully logged in!", pname3);
SendClientMessage(playerid, COLOR_WHITE,string3);
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Password does not match your name");
fclose(UserFile);
}
}
return 1;
}
PLease Help,
Rick