help me Scrip
#1

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;
}
Reply
#2

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


Forum Jump:


Users browsing this thread: 2 Guest(s)