server-beta icon indicating copy to clipboard operation
server-beta copied to clipboard

OnPlayerChangeWeapon

Open hiwyn opened this issue 1 year ago • 2 comments

A lot servers have to do it like me:

SetTimerEx("CheckIfPlayersChangedWeapon", 500, true, "i", playerid);


public CheckIfPlayersChangedWeapon(i) {
    new Now_WeaponInHands = GetPlayerWeapon(i);
    if(LastWeaponInHands[i] != Now_WeaponInHands) {
        OnPlayerChangeWeapon(i, LastWeaponInHands[i], Now_WeaponInHands);
        LastWeaponInHands[i] = Now_WeaponInHands;
    }
    return 1;
}

A infinite timer to check every 0.5 sec, to detect if player change weapon, to change weapons on skin and stuff like that

Would be possible on server side to detect and create a new callback OnPlayerChangeWeapon ???

hiwyn avatar Sep 27 '24 17:09 hiwyn

This is what OnPlayerUpdate was intended to be used for. A timer might not even catch all changes if the players scrolls fast.

Vince0789 avatar Sep 27 '24 18:09 Vince0789

Even OnPlayerUpdate can miss some fast scrolling so its accuracy is not ideal (and tbf it cannot be ideal if made serverside). It would be even more strange to see this as out-of-the-box callback which isn't accurate enough for people who imply that it should detect everything if it was allocated into a separate and "natively" done thing

NexiusTailer avatar Oct 02 '24 09:10 NexiusTailer