Command problem
#1

Hi,

Problem is with "healall" comand, what's a wrong?
Код:
CMD:healall(playerid, params[])
{
	new
	    string[200]
	;

	LoginCheck(playerid);
	if(User[playerid][accountAdmin] >= 4)
	{
	   	foreach(new i : Player)
		{
			if(i != playerid && User[playerid][accountAdmin] < User[i][accountAdmin])
			{
				PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
				SetPlayerHealth(i, 100.0);
			}
		}
		SendPlayerMessage(COLOR_RED, "[HEAL] "white"Everyone has been healed by an admin.");
		format(string, 128, "[HEAL] "white"Everyone has been healed by %s.", GetName(playerid));
		SendAMessage(COLOR_RED, string);
	}
	else
	{
	    SendClientMessage(playerid, -1, "» "red"You are not authorized to use this command.");
	}
	return 1;
}
Reply
#2

It Shows Errors Or Something?
or It Dosent Work?
Reply
#3

Oops, I forgot to write.
It doesn't work.
Compiled without errors / warnings.
Reply
#4

try this
pawn Код:
CMD:healall(playerid,params[])
{
    new string[200];
    LoginCheck(playerid);
    if(User[playerid][accountAdmin] >= 4)
    {
        foreach(Player, i)
        {
        PlayerPlaySound(i,1057,0.0,0.0,0.0);
        SetPlayerHealth(i,100.0);
        }
        }
        format(string, 128, "[HEAL] "white"Everyone has been healed by %s.", GetName(playerid));
        SendAMessage(COLOR_RED, string);
    }
    else return SendClientMessage(playerid, -1, "» "red"You are not authorized to use this command.");
}
Hope it works
im not rly sure i didn't test ,
i made some changes so Please Friendly Replys
Reply
#5

I get error and warning:
Код:
C:\Documents and Settings\2012\Desktop\JaKes FuN GM_Linux\JaKe_Linux\gamemodes\blank.pwn(3348) : warning 209: function "cmd_healall" should return a value
C:\Documents and Settings\2012\Desktop\JaKes FuN GM_Linux\JaKe_Linux\gamemodes\blank.pwn(3349) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#6

aight Show me Line 3349
And ,
About the Should Return Value , use this
pawn Код:
CMD:healall(playerid,params[])
{
    new string[200];
    LoginCheck(playerid);
    if(User[playerid][accountAdmin] >= 4)
    {
        foreach(Player, i)
        {
        PlayerPlaySound(i,1057,0.0,0.0,0.0);
        SetPlayerHealth(i,100.0);
        }
        }
        format(string, 128, "[HEAL] "white"Everyone has been healed by %s.", GetName(playerid));
        SendAMessage(COLOR_RED, string);
    }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!"); // if not, send him only the following message
        }
        return 1;
    }
}
Remember : This should Fix THe Warning ,

About The Error , Show me line So i can know Wats Wrong
Reply
#7

Код:
C:\Documents and Settings\2012\Desktop\JaKes FuN GM_Linux\JaKe_Linux\gamemodes\blank.pwn(3348) : warning 209: function "cmd_healall" should return a value
C:\Documents and Settings\2012\Desktop\JaKes FuN GM_Linux\JaKe_Linux\gamemodes\blank.pwn(3349) : error 010: invalid function or declaration
C:\Documents and Settings\2012\Desktop\JaKes FuN GM_Linux\JaKe_Linux\gamemodes\blank.pwn(3353) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Line 3348:
Код:
}
Line 3349:
Код:
else
Line 3353:
Код:
return 1;
Full code:
Код:
CMD:healall(playerid,params[])
{
    new string[200];
    LoginCheck(playerid);
    if(User[playerid][accountAdmin] >= 4)
    {
        foreach(Player, i)
        {
        PlayerPlaySound(i,1057,0.0,0.0,0.0);
        SetPlayerHealth(i,100.0);
        }
    }
    format(string, 128, "[HEAL] "white"Everyone has been healed by %s.", GetName(playerid));
    SendAMessage(COLOR_RED, string);
    } //-> Warning 3348
    else //-> Error 3349
    {
    	SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!"); // if not, send him only the following message
     }
     return 1; //-> Error 3353
    }
}
Reply
#8

pawn Код:
CMD:healall(playerid,params[])
{
    new string[200];
    LoginCheck(playerid);
    if(User[playerid][accountAdmin] >= 4)
    {
        foreach(Player, i)
        {
        PlayerPlaySound(i,1057,0.0,0.0,0.0);
        SetPlayerHealth(i,100.0);
        }
    }
    format(string, 128, "[HEAL] "white"Everyone has been healed by %s.", GetName(playerid));
    SendAMessage(COLOR_RED, string);
    } //-> Warning 3348
    else //-> Error 3349
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!"); // if not, send him only the following message
     }
    }
    return 1; // This needs to be at the last bracket, so it symbolizes the command
}
Read the warnings/errors, first the warning, the command should return a value.
Which means you should have a return 1 inside the commands brackets, like above.

And about the "else", you do not have an "if" to activate it?
You might have meant to do underneath.
pawn Код:
CMD:healall(playerid,params[])
{
    new string[200];
    LoginCheck(playerid);
    if(User[playerid][accountAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
    foreach(Player, i)
    {
        PlayerPlaySound(i,1057,0.0,0.0,0.0);
        SetPlayerHealth(i,100.0);
    }
    format(string, 128, "[HEAL] "white"Everyone has been healed by %s.", GetName(playerid));
    SendAMessage(COLOR_RED, string);
    return 1; // This needs to be at the last bracket, so it symbolizes the command
}
Because you closed the "if" with a bracket, therefore the "else" cannot refer back to it. Using "return (function)" is a much better method though, so i changed it to that.
Reply
#9

PHP код:
CMD:healall(playerid,params[])
{
    new 
string[200];
    
LoginCheck(playerid);
    if(
User[playerid][accountAdmin] >= 4)
    {
        foreach(
Playeri)
        {
        
PlayerPlaySound(i,1057,0.0,0.0,0.0);
        
SetPlayerHealth(i,100.0);
        }
    
format(string128"[HEAL] "white"Everyone has been healed by %s."GetName(playerid));
    
SendAMessage(COLOR_REDstring);
    }
    else 
    {
        
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use that command!"); 
     }
     return 
1
    } 
Reply
#10

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
pawn Код:
CMD:healall(playerid,params[])
{
    new string[200];
    LoginCheck(playerid);
    if(User[playerid][accountAdmin] >= 4)
    {
        foreach(Player, i)
        {
        PlayerPlaySound(i,1057,0.0,0.0,0.0);
        SetPlayerHealth(i,100.0);
        }
    }
    format(string, 128, "[HEAL] "white"Everyone has been healed by %s.", GetName(playerid));
    SendAMessage(COLOR_RED, string);
    } //-> Warning 3348
    else //-> Error 3349
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!"); // if not, send him only the following message
     }
    }
    return 1; // This needs to be at the last bracket, so it symbolizes the command
}
Read the warnings/errors, first the warning, the command should return a value.
Which means you should have a return 1 inside the commands brackets, like above.

And about the "else", you do not have an "if" to activate it?
You might have meant to do underneath.
pawn Код:
CMD:healall(playerid,params[])
{
    new string[200];
    LoginCheck(playerid);
    if(User[playerid][accountAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
    foreach(Player, i)
    {
        PlayerPlaySound(i,1057,0.0,0.0,0.0);
        SetPlayerHealth(i,100.0);
    }
    format(string, 128, "[HEAL] "white"Everyone has been healed by %s.", GetName(playerid));
    SendAMessage(COLOR_RED, string);
    return 1; // This needs to be at the last bracket, so it symbolizes the command
}
Because you closed the "if" with a bracket, therefore the "else" cannot refer back to it. Using "return (function)" is a much better method though, so i changed it to that.
Thanks bro fixed.
REP+
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)