unreachable code - 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: unreachable code (
/showthread.php?tid=571348)
unreachable code -
hoangtn219 - 18.04.2015
i have a error pawn. Help me. Thank
./includes/vn.pwn(98560) : warning 225: unreachable code
---------------------------------------------------------------------
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
if(issuerid != INVALID_PLAYER_ID && (weaponid == 34 ) )
{
SetPlayerHealth(playerid, 0.0);
new stringa[MAX_PLAYER_NAME+40];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(stringa, sizeof(stringa), "[ ! ]:[%s] He was killed by a shot to the head", name);
SendClientMessageToAll(0xFFFF00FF,stringa);
}
return 1;
if(GetPVarInt(playerid, "commitSuicide") == 1) //line 98560
{
SetPVarInt(playerid, "commitSuicide", 0);
}
Re: unreachable code -
ATGOggy - 18.04.2015
That is because you put that line after return 1; so there is no way that code can be executed.
Try this:
PHP код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
if(issuerid != INVALID_PLAYER_ID && (weaponid == 34 ) )
{
SetPlayerHealth(playerid, 0.0);
new stringa[MAX_PLAYER_NAME+40];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(stringa, sizeof(stringa), "[ ! ]:[%s] He was killed by a shot to the head", name);
SendClientMessageToAll(0xFFFF00FF,stringa);
}
if(GetPVarInt(playerid, "commitSuicide") == 1) //line 98560
{
SetPVarInt(playerid, "commitSuicide", 0);
}
return 1;
Also, if you want to make a headshot system, use bodypart parameter by putting it in OnPlayerGiveDamage:
https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
https://sampwiki.blast.hk/wiki/Body_Parts