Variable Not Increasing
#1

Well, I have a command setup to where the variable will increase but it doesn't here's the script, no errors, just doesn't work.


First command to increase it.
Код:
//------[Makeleader]-------
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;
}
Second command to test your leader
Код:
COMMAND:Invite(playerid, params[])
{
    if(FactionLeader[playerid] <= 1) return 0;
   	new targetid;
   	new giveplayerid;
 	if(sscanf(params, "is[24]", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "[SYNTAX]: /invite [PlayerID/PartOfName]");
 	else if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid,WHITE,"[ERROR] Player Is Not Connected");
 	else
 	{
 	    SendClientMessage(targetid,COLOR_GREEN, "Your faction has been set to LSPD!");
 	    LSPDMember[targetid] += 1;
	}
    return 1;
}
Where I kept my define

Код:
public OnPlayerConnect(playerid)
{
    FactionLeader[playerid] = 0;
Reply
#2

Try to change += to ++.

So, for example,
pawn Код:
FactionLeader[targetid] += 1;
would change to
pawn Код:
FactionLeader[targetid] ++;
All looks fine, but you can always try this.

EDIT: on second thought, why do you check if the players faction is less then or equal to 1? Shouldn't it be 0?

Also, why do you add onto the variable. Why not set it to a number, like 1 or something.
Reply
#3

try instead this :

HE SAID IT FIRST
Reply
#4

I changed it all to this

Код:
//------[Makeleader]-------
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] ++;
   	}
    return 1;
}
Код:
//---[invite]----
COMMAND:Invite(playerid, params[])
{
    if(FactionLeader[playerid] < 1) return 0;
   	new targetid;
   	new giveplayerid;
 	if(sscanf(params, "is[24]", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "[SYNTAX]: /invite [PlayerID/PartOfName]");
 	else if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid,WHITE,"[ERROR] Player Is Not Connected");
 	else
 	{
 	    SendClientMessage(targetid,COLOR_GREEN, "Your faction has been set to LSPD!");
 	    LSPDMember[targetid] ++;
	}
    return 1;
}
Reply
#5

Are you typing part of the name or their id? because if you're typing their name, the way you did sscanf is wrong, instead of "i" you want to use "u" .. i means integer, where as u means user.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)