warning 209: function "IsForbiddenWeap" should return a value - 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: warning 209: function "IsForbiddenWeap" should return a value (
/showthread.php?tid=439159)
warning 209: function "IsForbiddenWeap" should return a value -
Guest123 - 24.05.2013
hello i trying adding forbidden weapon on my script, but not work
code
pawn Код:
public OnPlayerUpdate(playerid){
if(IsForbiddenWeap(playerid)&& !IsPlayerAdmin(playerid))
{
ResetPlayerWeapons(playerid);
SendClientMessage(playerid, 0xFF0000FF, "You Cannot Have An Forbidden Weapon !");
return 1;
}
return 1;
}
pawn Код:
stock IsForbiddenWeap(playerid)
{
if(GetPlayerWeapon(playerid) == 38)
if(GetPlayerWeapon(playerid) == 44)
if(GetPlayerWeapon(playerid) == 45)
if(GetPlayerWeapon(playerid) == 42)
if(GetPlayerWeapon(playerid) == 41)
if(GetPlayerWeapon(playerid) == 39)
if(GetPlayerWeapon(playerid) == 37)
if(GetPlayerWeapon(playerid) == 36)
if(GetPlayerWeapon(playerid) == 35)
return 1;
}
help me
Re: warning 209: function "IsForbiddenWeap" should return a value -
Hoborific - 24.05.2013
pawn Код:
stock IsForbiddenWeap(playerid)
{
new WeapID = GetPlayerWeapon(playerid);
switch(WeapID)
{
case 35:
{
return 2;
}
case 36:
{
return 2;
}
case 37:
{
return 2;
}
case 38:
{
return 2;
}
case 39:
{
return 2;
}
case 41:
{
return 2;
}
case 42:
{
return 2;
}
case 44:
{
return 2;
}
case 45:
{
return 2;
}
}
return 1;
}
pawn Код:
public OnPlayerUpdate(playerid){
if(IsForbiddenWeap(playerid) == 2 && !IsPlayerAdmin(playerid))
{
ResetPlayerWeapons(playerid);
SendClientMessage(playerid, 0xFF0000FF, "You Cannot Have An Forbidden Weapon !");
return 1;
}
return 1;
}
Please put it on a timer not OnPlayerUpdate, OnPlayerUpdate is called a lot of times per second and can cause server and client desync
Re: warning 209: function "IsForbiddenWeap" should return a value -
Guest123 - 24.05.2013
and what is this
pawn Код:
if(IsForbiddenWeap(playerid) == 2
Re: warning 209: function "IsForbiddenWeap" should return a value -
Hoborific - 24.05.2013
the stock returns 2, if they have a forbidden weapon, == means equal to, if forbiddenweapon is equal to 2, remove weapon. that simple bro.
Re: warning 209: function "IsForbiddenWeap" should return a value -
SuperViper - 24.05.2013
pawn Код:
IsForbiddenWeap(playerid)
{
new playersWeapon = GetPlayerWeapon(playerid);
return ((playersWeapon >= 35 && playersWeapon <= 39) || playersWeapon == 41 || playersWeapon == 42 || playersWeapon == 44 || playersWeapon == 45);
}
Lot more efficient and smaller.
Re: warning 209: function "IsForbiddenWeap" should return a value -
Bakr - 24.05.2013
I'll one-up you:
pawn Код:
IsForbiddenWeapon(playerid)
{
switch(GetPlayerWeapon(playerid))
{
case 35..39, 41, 42, 44, 45:
return 1;
}
return 0;
}