SA-MP Forums Archive
[HELP]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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]Unreachable Code? (/showthread.php?tid=274067)



[HELP]Unreachable Code? - Tigerbeast11 - 04.08.2011

This is the command:

Код:
dcmd_slap(playerid,params[]) {
    if(IsPlayerCommandLevel(playerid,"slap")) {
   		if(!strlen(params)) return SendClientMessage(playerid,red,"Usage: /slap [playerid] [reason]");
        new tmp[256],Index; tmp = strtok(params,Index);
	   	new id; if(!IsNumeric(tmp)) id = ReturnPlayerID(tmp); else id = strval(tmp);
		if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID && id != playerid) {
			    new string[256],name[24],ActionName[24]; GetPlayerName(playerid,name,24); GetPlayerName(id,ActionName,24);
			    if(!strlen(params[strlen(tmp)+1])) format(string,256,"[INFO]: %s [ID:%d] has been slapped by %s [ID:%d] for: No Reason Given",ActionName,id,name,playerid);
				else format(string,256,"[INFO]: %s [ID:%d] has been slapped by %s [ID:%d] for: %s)",ActionName,id,name,playerid,params[strlen(tmp)+1]);
		    	return SendClientMessageToAll(yellow,string);
		    	new Float:x, Float:y, Float:z;GetPlayerPos(id, x,y,z); //Line 374
		    	return SetPlayerPos(id, x,y,z+5);
		} else return SendClientMessage(playerid,red,"ERROR: You cannot slap yourself or a disconnected player.");
	} else return SendLevelErrorMessage(playerid,"slap");
}
And this is the error I get:
Код:
C:\Users\User\Documents\samp\filterscripts\XtremeAdmin2test.pwn(374) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:           2456 bytes
Code size:           153480 bytes
Data size:           205888 bytes
Stack/heap size:      16384 bytes; estimated max. usage=5316 cells (21264 bytes)
Total requirements:  378208 bytes

1 Warning.



Re: [HELP]Unreachable Code? - RyDeR` - 04.08.2011

pawn Код:
dcmd_slap(playerid,params[])
{
    if(IsPlayerCommandLevel(playerid,"slap"))
    {
        if(!strlen(params)) return SendClientMessage(playerid,red,"Usage: /slap [playerid] [reason]");
        new tmp[256],Index; tmp = strtok(params,Index);
        new id; if(!IsNumeric(tmp)) id = ReturnPlayerID(tmp); else id = strval(tmp);
        if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID && id != playerid)
        {
                new string[256],name[24],ActionName[24]; GetPlayerName(playerid,name,24); GetPlayerName(id,ActionName,24);
                if(!strlen(params[strlen(tmp)+1]))
                    format(string,256,"[INFO]: %s [ID:%d] has been slapped by %s [ID:%d] for: No Reason Given",ActionName,id,name,playerid);
                else
                    format(string,256,"[INFO]: %s [ID:%d] has been slapped by %s [ID:%d] for: %s)",ActionName,id,name,playerid,params[strlen(tmp)+1]);
                SendClientMessageToAll(yellow,string);
               
                new Float:x, Float:y, Float:z;GetPlayerPos(id, x,y,z); //Line 374
                return SetPlayerPos(id, x,y,z+5);
               
        }
        else
            return SendClientMessage(playerid,red,"ERROR: You cannot slap yourself or a disconnected player.");
    }
    else
        return SendLevelErrorMessage(playerid,"slap");
}
Should work.


AW: [HELP]Unreachable Code? - Drebin - 04.08.2011

- nvm (see post above)


Re: [HELP]Unreachable Code? - Tigerbeast11 - 04.08.2011

Thanks, it worked! What was wrong with it?


Re: [HELP]Unreachable Code? - RyDeR` - 04.08.2011

Compare - The only thing I did was removing "return" from SendClientMessage.


Re: [HELP]Unreachable Code? - Tigerbeast11 - 04.08.2011

Oh! Thank mate!