help me Scrip - 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: help me Scrip (
/showthread.php?tid=655383)
help me Scrip -
nbx2000 - 20.06.2018
is this anti-weaps correct on my server I have the getplayerweaponEX function
or do not they connect anti weaps minigun and rpg that works?
public OnPlayerUpdate(playerid)
{
IlegalWeapons(playerid);
return 1;
}
stock IlegalWeapons(playerid)
{
if(GetPlayerWeapon(playerid) == 16 || GetPlayerWeapon(playerid) == 17 || GetPlayerWeapon(playerid) == 35 ||
GetPlayerWeapon(playerid) == 36 || GetPlayerWeapon(playerid) == 37 || GetPlayerWeapon(playerid) == 38 ||
GetPlayerWeapon(playerid) == 39 || GetPlayerWeapon(playerid) == 40 || GetPlayerWeapon(playerid) == 1
{
Kick(playerid);
return 1;
}
return 1;
}
Re: help me Scrip -
NaS - 20.06.2018
It would work but it's not very well done.
For example, you repeatedly call GetPlayerWeapon (which always returns the same value) but you could store the value in a variable and then compare it (it's a bit more efficient, not that this would make any noticable difference, but still).
Something like this:
Код:
new weaponid = GetPlayerWeapon(playerid);
And then use weaponid instead of GetPlayerWeapon.
Furthermore you can use a switch statement for things like these:
Код:
switch(weaponid)
{
case 16, 17, 35: // etc... You need to add the other IDs too
{
Kick(playerid);
}
}
Which makes it easier to code and to read.
You could also use the existing defines (like "WEAPON_MINIGUN") which is also easier to maintain because you will not have to look through Weapon IDs.