[Help] Max 1
#1

hey there, i'm made some teams/families in my script and i want that admin can give the leader to a player with a command

till here it's not a problem, but i want that the leader can be only 1 and if admin tries to make leader another palyer, he can't because there is allready one (connected or not) and he must take the leader to the orther one (connected or not)
Reply
#2

*Bump*

please help
Reply
#3

*BUMP*

wtf can anyone answer at least
Reply
#4

Perhaps, show us some of the script to provide you aid.
Reply
#5

example:

PlayerInfo[playerid][LeaderOfFamily] = 1;

with this a player is the leader of a family, i want that NO ONE ELSE can be leader of that family
Reply
#6

pawn Код:
new FactionHasOwner;
for(new i; i <= MAX_PLAYERS; i++) {
    if(IsPlayerConnected(i)) {
        if(PlayerInfo[i][LeaderOfFamily]) {
            FactionHasOwner = 1;
        }
    }
}
if(FactionHasOwner) return SendClientMessage(playerid, COLOR_RED, "ERROR: This faction already has a leader.");
Use that in the command which gives the leader.
Reply
#7

thank you for help but check this

i used this:

pawn Код:
new HasLeaderFBI;

dcmd_giveleaderfbi(playerid,params[])
{
    new target,string[120];
    if(HasLeaderFBI == 1) return SendClientMessage(playerid,red,"The F.B.I. has allready a leader!");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,red,"You are NOT Authorized to use this command!");
    if(sscanf(params,"d",target)) return SendClientMessage(playerid,red,"USAGE: /giveleaderfbi [ID]");
    if(((PlayerInfo[playerid][LeaderFBI] == 1) || (PlayerInfo[playerid][LeaderVLA] == 1)) return SendClientMessage(playerid,red,"Player is allready leader of a team/family!");

    format(string,sizeof(string),"Congratz, you are now the Federal Bureau of Investigation Leader!");
    SendClientMessage(target,red,"------------------------");
    SendClientMessage(target,lightblue,string);
    SendClientMessage(target,red,"------------------------");
    PlayerInfo[playerid][LeaderFBI] = 1;
    HasLeaderFBI = 1;
    return 1;
}
but when the player disconnects? or when the game mode restarts? how can i save the HasLeaderFBI?
Reply
#8

You don't need to save HasLeaderFBI.


Save the player enum "LeaderFBI".
Reply
#9

so with this will work?

pawn Код:
public OnPlayerDisconnect(playerid,reason)
{
    if (PlayerInfo[playerid][LoggedIn])
    {
    dUserSetINT(PlayerName(playerid)).("LeaderFBI",PlayerInfo[playerid][LeaderFBI]);
    dUserSetINT(PlayerName(playerid)).("LeaderVLA",PlayerInfo[playerid][LeaderVLA]);
    }
    return 1;
}
Reply
#10

Maybe.

Maybe if you saved it you can check if the player has the value then set "HasLeaderFBI" again.

btw it should be "HasLeaderFBI[playerid]" instead of "HasLeaderFBI"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)