OnPlayerUpdate & GetPlayerWeapon
#1

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.
Reply
#2

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.
Reply
#3

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.
Reply
#4

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.
Reply
#5

pawn Код:
Hm. Maybe kick all players before restarting the server? I.E,

CMD:restart(playerid, params[])
{
foreach(Player, i) { Kick(i); }
// Restarting codes.
}
Reply
#6

Kicking all might not cause player related issues but using GMX has got other issues too. I'd go for what Pottus has posted.
Reply
#7

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.
Reply
#8

Got it patched.

Код:
if(GetPlayerWeaponState(playerid) == -1 && !IsPlayerInAnyVehicle(playerid))
{
	#if defined yourals_OnPlayerUpdate
		return yourals_OnPlayerUpdate(playerid);
	#else
		return 1;
	#endif
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)