/makeleader command, need help
#1

Well, this is the code, it doesn't seem to work, I don't know whats wrong

Код:
//------[Makeleader]-------
FactionLeader[playerid] = 0;

COMMAND:makeleader(playerid, params[])
{
   	if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You are not authorized to use this command ");
   	new targetid;
   	new giveplayerid;
 	if(sscanf(params, "is[24]", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "[SYNTAX]: /makeleader [PlayerID/PartOfName]");
 	else if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid,WHITE,"[ERROR] Player Is Not Connected");
 	else
 	{
		SendClientMessage(targetid,COLOR_GREEN, "You have been made a faction leader!");
		FactionLeader[targetid] += 1;
 		
     }
    return 1;
}
My errors that Iam getting

Код:
C:\Users\GTW\BaseNorton V2\gamemodes\Gamemode.pwn(1018) : error 010: invalid function or declaration
C:\Users\GTW\BaseNorton V2\gamemodes\Gamemode.pwn(1030) : error 028: invalid subscript (not an array or too many subscripts): "FactionLeader"
C:\Users\GTW\BaseNorton V2\gamemodes\Gamemode.pwn(1030) : warning 215: expression has no effect
C:\Users\GTW\BaseNorton V2\gamemodes\Gamemode.pwn(1030) : error 001: expected token: ";", but found "]"
C:\Users\GTW\BaseNorton V2\gamemodes\Gamemode.pwn(1030) : error 029: invalid expression, assumed zero
C:\Users\GTW\BaseNorton V2\gamemodes\Gamemode.pwn(1030) : fatal error 107: too many error messages on one line
Line 1030

Код:
FactionLeader[targetid] += 1;
Line 1018

Код:
FactionLeader[playerid] = 0;
Reply
#2

Uhh, how is FactionLeader defined?
Reply
#3

//------[Makeleader]-------
FactionLeader[playerid] = 0;
Quote:

COMMAND:makeleader(playerid, params[])
{
if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You are not authorized to use this command ")
new targetid;
new giveplayerid;
if(sscanf(params, "is[24]", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "[SYNTAX]: /makeleader [PlayerID/PartOfName]")
else if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid,WHITE,"[ERROR] Player Is Not Connected");
else
{
SendClientMessage(targetid,COLOR_GREEN, "You have been made a faction leader!");
FactionLeader[targetid] += 1;

}
return 1;
}

Reply
#4

Quote:
Originally Posted by Burn_
Посмотреть сообщение
//------[Makeleader]-------
FactionLeader[playerid] = 0;
I'm pretty sure he already got that.
Reply
#5

I realized my mistake and I'm getting just one error now, this one

The define etc.

Код:
new FactionLeader[MAX_PLAYERS];
This is where the error line is

Код:
FactionLeader[playerid] = 0;
My error

Код:
C:\Users\GTW\BaseNorton V2\gamemodes\Gamemode.pwn(1018) : error 010: invalid function or declaration
Reply
#6

You can't just have "FactionLeader = 0;" anywhere in the script, as playerid is not defined. You need to put it under a command or under a function.
Reply
#7

Hmmm..If I understand what you mean you want me to add

Код:
new FactionLeader[MAX_PLAYERS];
under my command? That's probably the wrong idea that Iam getting, how extactly should I define playerid?
Reply
#8

No, no, no...

But "FactionLeader[playerid] = 0;", but be for example on OnPlayerConnect, or under a command. It cannot just be anywhere in the script, because playerid is not defined.
Reply
#9

It worked, thanks!
Reply
#10

pawn Код:
if(sscanf(params, "is[24]", targetid))
The sscanf specifiers you are using do not match the command you are making.
If you want the command layout like.
Код:
/makeleader [playerid/PartOfName]
Then use the u specifier.

pawn Код:
COMMAND:makeleader(playerid, params[])
{
    if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You are not authorized to use this command ");
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "[SYNTAX]: /makeleader [PlayerID/PartOfName]");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid,WHITE,"[ERROR] Player Is Not Connected");
    else
    {
        SendClientMessage(targetid,COLOR_GREEN, "You have been made a faction leader!");
        FactionLeader[targetid] += 1;
    }
    return 1;
}
You also included two variables for no reason when you only needed one.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)