Problems on saving user info -
leong124 - 03.03.2011
Hello everyone,
I currently created my gamemode and developed my admin system.
Players can get their weapons back after death/respawn and when rejoining the server.
I found that some of the players report that they lost all their weapons sometimes,
but for me everything works fine.
I use GetPlayerWeaponData in OnPlayerDeath and OnPlayerDisconnect to get their weapon data and save them.
I tried methods to save that to user file and read it again,or user file + array variable,
but there's still some reports about losing the weapons.
I previously used the DJson and now I'm using Double-O-Files,
and the problem is not solved(but using DOF have much less reports)
Is that the problem of network(ultra-high packet loss) or..?
Re: Problems on saving user info -
YungGee - 03.03.2011
post saving codes..
Re: Problems on saving user info -
leong124 - 03.03.2011
pawn Код:
//Global variable
new weapondata[13][2][MAX_PLAYERS] =
{
{{-1,...},{0,...}},{{-1,...},{0,...}},{{-1,...},{0,...}},{{-1,...},{0,...}},{{-1,...},{0,...}},
{{-1,...},{0,...}},{{-1,...},{0,...}},{{-1,...},{0,...}},{{-1,...},{0,...}},{{-1,...},{0,...}},
{{-1,...},{0,...}},{{-1,...},{0,...}},{{-1,...},{0,...}}
};//First array is for the 13 weapon slots and the second stores the weapons' ID and their ammo.
public OnPlayerDeath(playerid,killerid,reason)
{
new weapon[13],ammo[13];
new string[192],killername[MAX_PLAYER_NAME],playername[MAX_PLAYER_NAME];
for(new i = 0;i < 13;i++) GetPlayerWeaponData(playerid,i,weapon[i],ammo[i]);
for(new i = 0;i < 13;i++)
{
if(weapon[i] && ammo[i] > 0) weapondata[i][0][playerid] = weapon[i];
else if(weapondata[i][1][playerid] < 50) weapondata[i][0][playerid] = -1;
if(ammo[i] > 0) weapondata[i][1][playerid] = ammo[i];
else if(weapondata[i][1][playerid] < 50) weapondata[i][1][playerid] = 0;
}
//Some more here..
}
public OnPlayerSpawn(playerid)
{
if(!IsPlayerNPC(playerid))
{
SetTimerEx("GivePlayerWeaponsInData",80,false,"d",playerid);
//......
}
//Some more here..
}
public GivePlayerWeaponsInData(playerid)
{
for(new i = 0;i < 13;i++)
if(weapondata[i][0][playerid] != -1 && weapondata[i][1][playerid] > 0)
{
switch(weapondata[i][0][playerid])
{
case 9,18,35..38: continue;//Weapons that are legal
default: GivePlayerWeapon(playerid,weapondata[i][0][playerid],weapondata[i][1][playerid]);
}
}
SetPlayerArmedWeapon(playerid,0);
return 1;
}
Seems that there's nothing wrong here...
because I and some other players still get it work.
Weird:/
Re: Problems on saving user info -
Mike Garber - 03.03.2011
Try not to delay the saving with SetTimer(Ex).
public functions can be called with function(param);
So in your case, replace your SetTimerEx function with
pawn Код:
GivePlayerWeaponsInData(playerid);
Re: Problems on saving user info -
leong124 - 05.03.2011
Okay I'll try that.
Actually I used the timer to have a little delay so that it will not run a large code and freeze the server for a while.