Is there any more efficient way to make this work ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Is there any more efficient way to make this work ? (
/showthread.php?tid=621779)
Is there any more efficient way to make this work ? -
NeXoR - 14.11.2016
Hey guys, as the title says, is there a better way ?
OnGameModeInit
PHP код:
SetTimer("WeaponChange", 1000, 1);
WeaponChange
PHP код:
// Weapon Change
forward WeaponChange();
public WeaponChange()
{
foreach(new playerid : Player) if(LastWeapon[playerid] != GetPlayerWeapon(playerid)) OnPlayerSwitchWeapon(playerid, LastWeapon[playerid], GetPlayerWeapon(playerid));
return 1;
}
Thanks in advice
Re: Is there any more efficient way to make this work ? - iLearner - 14.11.2016
OnPlayerWeaponChange(playerid, newweapon, oldweapon) ?
https://sampforum.blast.hk/showthread.php?tid=59771
Re: Is there any more efficient way to make this work ? -
NeXoR - 14.11.2016
Quote:
Originally Posted by iLearner
|
It uses OnPlayerUpdate, it will spam the hell out of the server.
Re: Is there any more efficient way to make this work ? -
SickAttack - 14.11.2016
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.
Re: Is there any more efficient way to make this work ? -
Vince - 14.11.2016
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.
Re: Is there any more efficient way to make this work ? -
NeXoR - 15.11.2016
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 ?