OnPlayerUpdate & GetPlayerWeapon -
Hanger - 05.09.2014
If server restarts and player held a weapon before gmx was called then OnPlayerUpdate will return the same weaponid regardless of re-connection.
To test, simply give yourself a weapon in game and restart your server by using rcon gmx. You will notice that just after the restart, weaponid in console output will remain the same for some period of time.
*Subject to circumstance where you will have the same playerid after restart - (0) in this case.
Код:
COMMAND:restart(playerid, params[])
{
SendRconCommand("gmx");
return 1;
}
public OnPlayerUpdate(playerid)
{
static weaponid;
weaponid = GetPlayerWeapon(playerid);
if(46 >= weaponid >= 0)
{
printf("weaponid %d", weaponid);
}
#if defined weapons_OnPlayerUpdate
return weapons_OnPlayerUpdate(playerid);
#else
return 1;
#endif
}
#if defined _ALS_OnPlayerUpdate
#undef OnPlayerUpdate
#else
#define _ALS_OnPlayerUpdate
#endif
#define OnPlayerUpdate weapons_OnPlayerUpdate
#if defined weapons_OnPlayerUpdate
forward weapons_OnPlayerUpdate(playerid);
#endif
Edit:
If instructions above give no results to approve this bug then try to pause the player and then restart the server via console box.
Re: OnPlayerUpdate & GetPlayerWeapon -
Abagail - 05.09.2014
pawn Код:
public OnGameModeExit()
{
ResetPlayerWeapons(playerid);
SetPlayerArmedWeapon(playerid, 0);
}
Not sure if this would work, though. You could do it like this as-well assuming you use commands for restarting,
(In the command, I.E /restart...)
foreach(Player, i) {
pawn Код:
ResetPlayerWeapons(i);
SetPlayerArmedWeapon(i, 0);
}
I've never personally encountered this though.
Re: OnPlayerUpdate & GetPlayerWeapon -
Hanger - 05.09.2014
Just tested it again. Apparently this occurs when you use ALS hook method with your OnPlayerUpdate. With y_hooks it seems to skip the problem.
Will try your solution, thanks for advice.
Edit:
Nope, does not work and re-initialising variables to 0 also produces no results.
Re: OnPlayerUpdate & GetPlayerWeapon -
Pottus - 05.09.2014
GMX is known to cause a lot of bugs the best thing to do is always shut down your server and restart it don't rely on GMX.
Re: OnPlayerUpdate & GetPlayerWeapon -
Abagail - 05.09.2014
pawn Код:
Hm. Maybe kick all players before restarting the server? I.E,
CMD:restart(playerid, params[])
{
foreach(Player, i) { Kick(i); }
// Restarting codes.
}
Re: OnPlayerUpdate & GetPlayerWeapon -
Lordzy - 05.09.2014
Kicking all might not cause player related issues but using GMX has got other issues too. I'd go for what Pottus has posted.
Re: OnPlayerUpdate & GetPlayerWeapon - Emmet_ - 05.09.2014
Confirmed:
I was testing a weapon anticheat a while back and noticed that after a "GMX" restart, I would sometimes be banned for weapon hacks upon connecting. It detected the weapon that I was holding prior to the restart.
Re: OnPlayerUpdate & GetPlayerWeapon -
Hanger - 08.09.2014
Got it patched.
Код:
if(GetPlayerWeaponState(playerid) == -1 && !IsPlayerInAnyVehicle(playerid))
{
#if defined yourals_OnPlayerUpdate
return yourals_OnPlayerUpdate(playerid);
#else
return 1;
#endif
}