error when pawning.... with IfPlayerAdmin
#1

not an really error. it is a warning. here's the error"

C:\Program Files (x86)\Rockstar Games\SAMP server\filterscripts\kill_command.pwn(102) : warning 225: unreachable code
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.

command:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/kill", cmdtext, true, 5) == 0)
	{
		SetPlayerHealth(playerid, 0);
		return 1;
	}
	if (strcmp("/heal", cmdtext, true, 5) == 0)
        if (IsPlayerAdmin(playerid)) return 1;
	{
		SetPlayerHealth(playerid, 100);
		return 1;
	}
	return 0;
}
the error is in the /heal command in if (IsPlayerAdmin(playerid)) return 1;
Reply
#2

You don't need to "return 1;" after IsPlayerAdmin. Try this
Код:
if (strcmp("/heal", cmdtext, true, 5) == 0)
{
	if(IsPlayerAdmin(playerid))
	{
	    SetPlayerHealth(playerid, 100);
	}
	return 1;
}
Also you missed an opening bracket after the "if(strcmp..."
Reply
#3

here it is
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/kill"cmdtexttrue5) == 0)
    {
        
SetPlayerHealth(playerid0);
        return 
1;
    }
    if (
strcmp("/heal"cmdtexttrue5) == 0)
    {
           if(
IsPlayerAdmin(playerid))
    {
        
SetPlayerHealth(playerid100);
    }
    return 
1;
    }
    return 
0;

Reply
#4

Quote:
Originally Posted by LZLo
Посмотреть сообщение
here it is
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/kill"cmdtexttrue5) == 0)
    {
        
SetPlayerHealth(playerid0);
        return 
1;
    }
    if (
strcmp("/heal"cmdtexttrue5) == 0)
    {
           if(
IsPlayerAdmin(playerid))
    {
        
SetPlayerHealth(playerid100);
    }
    return 
1;
    }
    return 
0;

wtf? when i make that it appeared 26 errors!!!
Reply
#5

Did you try mine?
Reply
#6

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/kill",cmdtext,true))
    {
        SetPlayerHealth(playerid, -10);
        return 1;
    }
    if(!strcmp("/heal", cmdtext, true))
    {
        if(!IsPlayerAdmin(playerid)) return 0;
        {
            SetPlayerHealth(playerid, 100);
            return 1;
        }
    }
    return 0;
}
It's not that hard

Remember: To kill a player, always set health lower than 0, because it would just stand there with no health left, unable to do anything.
Reply
#7

Quote:
Originally Posted by .:Kaos:.
Посмотреть сообщение
Did you try mine?
yea ur one is perfect but the other user post was with 26 errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)