Is there any more efficient way to make this work ?
#1

Hey guys, as the title says, is there a better way ?

OnGameModeInit
PHP код:
SetTimer("WeaponChange"10001); 
WeaponChange
PHP код:
// Weapon Change
forward WeaponChange();
public 
WeaponChange()
{
    foreach(new 
playerid Player) if(LastWeapon[playerid] != GetPlayerWeapon(playerid)) OnPlayerSwitchWeapon(playeridLastWeapon[playerid], GetPlayerWeapon(playerid));
    return 
1;

Thanks in advice
Reply
#2

OnPlayerWeaponChange(playerid, newweapon, oldweapon) ?

https://sampforum.blast.hk/showthread.php?tid=59771
Reply
#3

Quote:
Originally Posted by iLearner
Посмотреть сообщение
OnPlayerWeaponChange(playerid, newweapon, oldweapon) ?

https://sampforum.blast.hk/showthread.php?tid=59771
It uses OnPlayerUpdate, it will spam the hell out of the server.
Reply
#4

Depends on when you want to use the detection.

E.G. If you want it to detect the change immediately, you'd have to use a timer.
Reply
#5

Quote:
Originally Posted by NeXoR
Посмотреть сообщение
It uses OnPlayerUpdate, it will spam the hell out of the server.
Stuff like this is why that callback exists.
Reply
#6

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Depends on when you want to use the detection.

E.G. If you want it to detect the change immediately, you'd have to use a timer.
Well, I am using a timer as you see
I am using it for attached weapons on body
When you switch to a gun which is attached on you, the object is removed and your old weapon is attached

@Vince so shall I actually use it even if it's called 30 times a sec ?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)