got problem with command
#1

Hi i get a punch of errors when i add this command


Код:
(line 357) if(strcmp(cmdtext, "/makeleader", true) == 0)
{
	if(IsPlayerConnected(playerid))
 	{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makeleader [playerid/PartOfName] [Number(1-10)]");
				return 1;
			}
			new para1;
			new level;
			para1 = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			level = strval(tmp);
			if(level > 0 || level < 1) { SendClientMessage(playerid, COLOR_GREY, "ERROR: Dont go below number 0 nor above number 1!"); return 1; }
			if (PlayerInfo[playerid][pAdmin] >= 1337)
			{
			    if(IsPlayerConnected(para1))
			    {
			        if(para1 != INVALID_PLAYER_ID)
			        {
						GetPlayerName(para1, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						PlayerInfo[para1][pLeader] = level;
						format(string, sizeof(string), "NOTICE: You have been promoted to Leader of a faction by Admin %s", sendername);
						SendClientMessage(para1, COLOR_LIGHTBLUE, string);
						format(string, sizeof(string), "NOTICE: You have given %s control to run Faction Number %d.", giveplayer,level);
						SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
						format(string, 256, "[ADMIN]: %s has promoted %s to Leader of faction %d.", sendername, giveplayer, level);
						ABroadCast(COLOR_LIGHTRED,string,1);
						if(level == 0) { PlayerInfo[para1][pChar] = 0; }
						else if(level == 3) { PlayerInfo[para1][pChar] = 287; }
					    gTeam[para1] = 11;
					    PlayerInfo[para1][pTeam] = 11;
					    SetPlayerSkin(para1, PlayerInfo[para1][pChar]);
					}
				}//not connected
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "ERROR: You are not authorized to use that command!");
			}
		}
		return 1;
	}

(357) : error 010: invalid function or declaration
(359) : error 010: invalid function or declaration
(362) : error 010: invalid function or declaration
(365) : error 010: invalid function or declaration
(369) : error 010: invalid function or declaration
(372) : error 010: invalid function or declaration
(373) : error 010: invalid function or declaration
(375) : error 010: invalid function or declaration
(377) : error 010: invalid function or declaration
(38 : error 010: invalid function or declaration
(389) : error 010: invalid function or declaration
(396) : error 010: invalid function or declaration
(401) : error 010: invalid function or declaration
(632) : warning 203: symbol is never used: "level"
(632) : warning 203: symbol is never used: "para1"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

thanks , hope get help
Reply
#2

uhh make sure you have all the brackets and a noob mistake ive seen is people not placing there codes under onplayercommandtext
Reply
#3

Quote:
Originally Posted by farris
Посмотреть сообщение
uhh make sure you have all the brackets and a noob mistake ive seen is people not placing there codes under onplayercommandtext
And make sure you defined em aswell, here try this


pawn Код:
if(strcmp(cmd, "/makeleader", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makeleader [playerid/PartOfName] [Number(1-20)]");
                return 1;
            }
            new para1;
            new level;
            para1 = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            level = strval(tmp);
            if(level >= SCRIPT_OPENFACTIONS || level < 0) { SendClientMessage(playerid, COLOR_GREY, "   Dont go below number 0, or above!"); return 1; }
            if (PlayerInfo[playerid][pAdmin] >= 4)
            {
                if(IsPlayerConnected(para1))
                {
                    if(para1 != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        GiveNameSpace(sendername);
                        GiveNameSpace(giveplayer);
                        PlayerInfo[para1][pMember] = level;
                        format(string, sizeof(string), "   You have been promoted to Leader to your requested Faction by Admin %s", sendername);
                        SendClientMessage(para1, COLOR_WHITE, string);
                        format(string, sizeof(string), "   You have given %s control to run Faction Number %d.", giveplayer,level);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        if(level == 0) { PlayerInfo[para1][pRank] = 0; gTeam[para1] = 3; PlayerInfo[para1][pTeam] = 0; return 1; }
                        else if(level == 1) { PlayerInfo[para1][pModel] = 288; } //Police Force
                        else if(level == 2) { PlayerInfo[para1][pModel] = 286; } //FBI/ATF
                        else if(level == 3) { PlayerInfo[para1][pModel] = 26; } // Goverment
                        else if(level == 4) { PlayerInfo[para1][pModel] = 228; } //Fire/Ambulance
                        else if(level >= 7) { PlayerInfo[para1][pModel] = FamilyInfo[level][FamilySkin6]; } // Open Faction
                        PlayerInfo[playerid][pFactionIden]=FamilyInfo[PlayerInfo[playerid][pMember]][FamilyIden]; //just to make sure its synced
                       
                        if(level == 0)
                        {
                            gTeam[para1] = 3;
                            PlayerInfo[para1][pTeam] = 3;
                        }
                        else if(level == 1 || level == 2 || level == 3)
                        {
                            gTeam[para1] = 2;
                            PlayerInfo[para1][pTeam] = 2;
                        }
                        else if(level == 4)
                        {
                            gTeam[para1] = 1;
                            PlayerInfo[para1][pTeam] = 1;
                        }
                        else
                        {
                            gTeam[para1] = 15;
                            PlayerInfo[para1][pTeam] = 15;
                        }

                        SetPlayerSkinEx(para1, PlayerInfo[para1][pModel]);

                        if(level == 0)
                        {
                            PlayerInfo[para1][pRank] = 0;
                        }
                        else if(level == 1)
                        {
                            PlayerInfo[para1][pRank] = 16;
                        }
                        else if(level == 3)
                        {
                            PlayerInfo[para1][pRank] = 16;
                        }
                        else if(level >= 7)
                        {
                            PlayerInfo[para1][pRank] = 6;
                            SendClientMessage(para1,COLOR_WHITE,"[INFO]: Type /factionhelp to learn how to build your faction.");
                        }
                        else
                        {
                            PlayerInfo[para1][pRank] = 6;
                        }
                    }
                }//not connected
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
            }
        }
        return 1;
    }
Reply
#4

As the others above have said, somewhere above that code you may be missing a } somewhere.
This can be found easily by commenting out (see below for example) sections of code, in this case, other commands, until you don't get errors.

Example of commenting out code
pawn Код:
print("Hello world!");
//print("This will not be said!");

public OnPlayerCommandText(playerid,cmdtext[]){
    if(!strcmp(cmdtext,"/Rawr",true)){
        SendClientMessage(playerid,0xFF0000FF,"You typed /Rawr!");
        return 1;
    }/*
    if(!strcmp(cmdtext,"/Nope",true)){
        SendClientMessage(playerid,0xFF0000FF,"This command will not work!");
        return 1;
    }*/

    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)