/setleader cmd
#1

Hello!

trying to figure out how to "check" if the player is in a team or not. And if he is in a team you get a message that he is in a team already. how? i already have the text message in the code.

here is the code
pawn Код:
if(strcmp(cmd, "/setleader", true) == 0)
    {
        if(PlayerBase[playerid][pAdmin] == 1337)
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SCM(playerid, COLOR_GREEN, "Use: /setleader [playerid] [Combat Team]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SCM(playerid, COLOR_GREEN, "Use: /setleader [playerid][ Combat Team]");
                return 1;
            }
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendare, sizeof(sendare));
            points = strval(tmp);
            if(IsPlayerConnected(giveplayerid))
            {
                if(points == 0)
                {
                    SetPlayerSkin(giveplayerid, 272);
                    PlayerBase[giveplayerid][pLedare] = 0;
                    PlayerBase[giveplayerid][pRang] = 0;
                    PlayerBase[playerid][pMedlem] = 0;
                    SetPlayerPos(giveplayerid, 414.6559,2531.7651,19.1601);
                    SetPlayerTeam(playerid, 4);
                    SetPlayerColor(playerid, COLOR_WHITE);
                    format(text, sizeof(text), "You Are No Longer A Team Command Chief Master!");
                    SCM(giveplayerid, COLOR_RED, text);
                    format(text, sizeof(text), "You Just Took %s's Command Chief Master Permissions", giveplayer);
                    SCM(playerid, COLOR_RED, text);
                }
                if(points == 1)
                {
                    PlayerBase[giveplayerid][pLedare] = 1;
                    PlayerBase[giveplayerid][pRang] = 6;
                    PlayerBase[playerid][pMedlem] = 1;
                    SetPlayerColor(playerid, COLOR_BLUE);
                    SetPlayerTeam(playerid, 1);
                    UpdateRank(giveplayerid);
                    format(text, sizeof(text), "%s Just Made You To Command Chief Master Over Bluefoxes!", sendare);
                    SCM(giveplayerid, COLOR_GREEN, text);
                    format(text, sizeof(text), "You Just Made %s Command Chief Master Over Bluefoxes!", giveplayer);
                    SCM(playerid, COLOR_GREEN, text);
                }
                if(points == 2)
                {
                    PlayerBase[giveplayerid][pLedare] = 2;
                    PlayerBase[giveplayerid][pRang] = 6;
                    PlayerBase[playerid][pMedlem] = 2;
                    SetPlayerColor(playerid, COLOR_YELLOW);
                    SetPlayerTeam(playerid, 2);
                    UpdateRank(giveplayerid);
                    format(text, sizeof(text), "%s Just Made You To Command Chief Master Over Thunderbirds!", sendare);
                    SCM(giveplayerid, COLOR_GREEN, text);
                    format(text, sizeof(text), "You Just Made %s To Command Chief Master Over Thunderbirds!", giveplayer);
                    SCM(playerid, COLOR_GREEN, text);
                }
                if(points == 3)
                {
                    PlayerBase[giveplayerid][pLedare] = 3;
                    PlayerBase[giveplayerid][pRang] = 6;
                    PlayerBase[playerid][pMedlem] = 3;
                    SetPlayerColor(playerid, COLOR_GREY);
                    SetPlayerTeam(playerid, 3);
                    UpdateRank(giveplayerid);
                    format(text, sizeof(text), "%s Just Made You To Command Chief Master Over Airwolves!", sendare);
                    SCM(giveplayerid, COLOR_GREEN, text);
                    format(text, sizeof(text), "You Just Made %s To Command Chief Master Over Airwolves!", giveplayer);
                    SCM(playerid, COLOR_GREEN, text);
                }
            }
            else(SCM(playerid, COLOR_RED, "That Player Is Already In A Team!"));
        }
        else(SCM(playerid, COLOR_RED, "You Are Not An Admin!"));
        return 1;
    }
Reply
#2

your using gTeam?
Reply
#3

Quote:
Originally Posted by Marricio
Посмотреть сообщение
your using gTeam?
no im just using SetPlayerTeam(playerid, i think lol
And i also have problem that other teamleaders can fire,kick,giverank to non members.
Reply
#4

omg! u still using strcmp and strtok xD
Reply
#5

pawn Код:
if(strcmp(cmd, "/setleader", true) == 0)
    {
        if(PlayerBase[playerid][pAdmin] == 1337)
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SCM(playerid, COLOR_GREEN, "Use: /setleader [playerid] [Combat Team]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SCM(playerid, COLOR_GREEN, "Use: /setleader [playerid][ Combat Team]");
                return 1;
            }
            if(GetPlayerTeam(giveplayerid) != 0)
            {
                SCM(giveplayerid, COLOR_GREEN, "That player is already in a team! ");
                return 1;
            }
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendare, sizeof(sendare));
            points = strval(tmp);
            if(IsPlayerConnected(giveplayerid))
            {
                if(points == 0)
                {
                    SetPlayerSkin(giveplayerid, 272);
                    PlayerBase[giveplayerid][pLedare] = 0;
                    PlayerBase[giveplayerid][pRang] = 0;
                    PlayerBase[playerid][pMedlem] = 0;
                    SetPlayerPos(giveplayerid, 414.6559,2531.7651,19.1601);
                    SetPlayerTeam(playerid, 4);
                    SetPlayerColor(playerid, COLOR_WHITE);
                    format(text, sizeof(text), "You Are No Longer A Team Command Chief Master!");
                    SCM(giveplayerid, COLOR_RED, text);
                    format(text, sizeof(text), "You Just Took %s's Command Chief Master Permissions", giveplayer);
                    SCM(playerid, COLOR_RED, text);
                }
                if(points == 1)
                {
                    PlayerBase[giveplayerid][pLedare] = 1;
                    PlayerBase[giveplayerid][pRang] = 6;
                    PlayerBase[playerid][pMedlem] = 1;
                    SetPlayerColor(playerid, COLOR_BLUE);
                    SetPlayerTeam(playerid, 1);
                    UpdateRank(giveplayerid);
                    format(text, sizeof(text), "%s Just Made You To Command Chief Master Over Bluefoxes!", sendare);
                    SCM(giveplayerid, COLOR_GREEN, text);
                    format(text, sizeof(text), "You Just Made %s Command Chief Master Over Bluefoxes!", giveplayer);
                    SCM(playerid, COLOR_GREEN, text);
                }
                if(points == 2)
                {
                    PlayerBase[giveplayerid][pLedare] = 2;
                    PlayerBase[giveplayerid][pRang] = 6;
                    PlayerBase[playerid][pMedlem] = 2;
                    SetPlayerColor(playerid, COLOR_YELLOW);
                    SetPlayerTeam(playerid, 2);
                    UpdateRank(giveplayerid);
                    format(text, sizeof(text), "%s Just Made You To Command Chief Master Over Thunderbirds!", sendare);
                    SCM(giveplayerid, COLOR_GREEN, text);
                    format(text, sizeof(text), "You Just Made %s To Command Chief Master Over Thunderbirds!", giveplayer);
                    SCM(playerid, COLOR_GREEN, text);
                }
                if(points == 3)
                {
                    PlayerBase[giveplayerid][pLedare] = 3;
                    PlayerBase[giveplayerid][pRang] = 6;
                    PlayerBase[playerid][pMedlem] = 3;
                    SetPlayerColor(playerid, COLOR_GREY);
                    SetPlayerTeam(playerid, 3);
                    UpdateRank(giveplayerid);
                    format(text, sizeof(text), "%s Just Made You To Command Chief Master Over Airwolves!", sendare);
                    SCM(giveplayerid, COLOR_GREEN, text);
                    format(text, sizeof(text), "You Just Made %s To Command Chief Master Over Airwolves!", giveplayer);
                    SCM(playerid, COLOR_GREEN, text);
                }
            }
            else(SCM(playerid, COLOR_RED, "That Player Is Already In A Team!"));
        }
        else(SCM(playerid, COLOR_RED, "You Are Not An Admin!"));
        return 1;
    }
Reply
#6

Dude, it's better using zcmd or dcmd + sscanf. And you can check team by:

pawn Код:
if(GetPlayerTeam(playerid) == TEAM_ID) return . . .
Check if the player is on the TEAM_ID, and return related functions you put ther
Reply
#7

You only get that message if you try set your self as a leader when you already are a leader, and if you try to set leader on someone else who not is a leader, he got the message "That player is...."
so the cmd doesnt work this way
Quote:
Originally Posted by Marricio
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/setleader", true) == 0)
    {
        if(PlayerBase[playerid][pAdmin] == 1337)
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SCM(playerid, COLOR_GREEN, "Use: /setleader [playerid] [Combat Team]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SCM(playerid, COLOR_GREEN, "Use: /setleader [playerid][ Combat Team]");
                return 1;
            }
            if(GetPlayerTeam(giveplayerid) != 0)
            {
                SCM(giveplayerid, COLOR_GREEN, "That player is already in a team! ");
                return 1;
            }
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendare, sizeof(sendare));
            points = strval(tmp);
            if(IsPlayerConnected(giveplayerid))
            {
                if(points == 0)
                {
                    SetPlayerSkin(giveplayerid, 272);
                    PlayerBase[giveplayerid][pLedare] = 0;
                    PlayerBase[giveplayerid][pRang] = 0;
                    PlayerBase[playerid][pMedlem] = 0;
                    SetPlayerPos(giveplayerid, 414.6559,2531.7651,19.1601);
                    SetPlayerTeam(playerid, 4);
                    SetPlayerColor(playerid, COLOR_WHITE);
                    format(text, sizeof(text), "You Are No Longer A Team Command Chief Master!");
                    SCM(giveplayerid, COLOR_RED, text);
                    format(text, sizeof(text), "You Just Took %s's Command Chief Master Permissions", giveplayer);
                    SCM(playerid, COLOR_RED, text);
                }
                if(points == 1)
                {
                    PlayerBase[giveplayerid][pLedare] = 1;
                    PlayerBase[giveplayerid][pRang] = 6;
                    PlayerBase[playerid][pMedlem] = 1;
                    SetPlayerColor(playerid, COLOR_BLUE);
                    SetPlayerTeam(playerid, 1);
                    UpdateRank(giveplayerid);
                    format(text, sizeof(text), "%s Just Made You To Command Chief Master Over Bluefoxes!", sendare);
                    SCM(giveplayerid, COLOR_GREEN, text);
                    format(text, sizeof(text), "You Just Made %s Command Chief Master Over Bluefoxes!", giveplayer);
                    SCM(playerid, COLOR_GREEN, text);
                }
                if(points == 2)
                {
                    PlayerBase[giveplayerid][pLedare] = 2;
                    PlayerBase[giveplayerid][pRang] = 6;
                    PlayerBase[playerid][pMedlem] = 2;
                    SetPlayerColor(playerid, COLOR_YELLOW);
                    SetPlayerTeam(playerid, 2);
                    UpdateRank(giveplayerid);
                    format(text, sizeof(text), "%s Just Made You To Command Chief Master Over Thunderbirds!", sendare);
                    SCM(giveplayerid, COLOR_GREEN, text);
                    format(text, sizeof(text), "You Just Made %s To Command Chief Master Over Thunderbirds!", giveplayer);
                    SCM(playerid, COLOR_GREEN, text);
                }
                if(points == 3)
                {
                    PlayerBase[giveplayerid][pLedare] = 3;
                    PlayerBase[giveplayerid][pRang] = 6;
                    PlayerBase[playerid][pMedlem] = 3;
                    SetPlayerColor(playerid, COLOR_GREY);
                    SetPlayerTeam(playerid, 3);
                    UpdateRank(giveplayerid);
                    format(text, sizeof(text), "%s Just Made You To Command Chief Master Over Airwolves!", sendare);
                    SCM(giveplayerid, COLOR_GREEN, text);
                    format(text, sizeof(text), "You Just Made %s To Command Chief Master Over Airwolves!", giveplayer);
                    SCM(playerid, COLOR_GREEN, text);
                }
            }
            else(SCM(playerid, COLOR_RED, "That Player Is Already In A Team!"));
        }
        else(SCM(playerid, COLOR_RED, "You Are Not An Admin!"));
        return 1;
    }
Reply
#8

Quote:
Originally Posted by blackwave
Посмотреть сообщение
Dude, it's better using zcmd or dcmd + sscanf. And you can check team by:

pawn Код:
if(GetPlayerTeam(playerid) == TEAM_ID) return . . .
Check if the player is on the TEAM_ID, and return related functions you put ther
Then i have to script the server all over again, i guess?
Reply
#9

Quote:
Originally Posted by cruising
Посмотреть сообщение
Then i have to script the server all over again, i guess?
No you just gotta re-make all commands... It's not that hard if you're patient.
Reply
#10

Quote:
Originally Posted by Marricio
Посмотреть сообщение
No you just gotta re-make all commands... It's not that hard if you're patient.
Ah ok! but i can nothing about zcmd or dcmd,sscanf :/
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)