/makeleader problem
#1

Hi, i want to ask what is wrong with this command?? When i write /makeleader [ID] [faction id] it just says: Invalid faction ID, but when i use not symbols, but letters - it works, but just says: You have given Armando De Luca the leadership-badge of the orgnizaiton.

http://pastebin.com/VGfUXake
Reply
#2

You don't need to add "[]" where it's the ID and Fation ID :3 Bro this is not any script's fault but yours because you type the command wrongly.
The wrong way you do it
Код:
/makeleader [1] [1]
The right way you should do it
Код:
/makeleader 1 1
Without the "[]"
Reply
#3

Quote:
Originally Posted by VladimirMark
Посмотреть сообщение
You don't need to add "[]" where it's the ID and Fation ID :3 Bro this is not any script's fault but yours because you type the command wrongly.
The wrong way you do it
Код:
/makeleader [1] [1]
The right way you should do it
Код:
/makeleader 1 1
Without the "[]"
I already know that -.-, but still - don't work.
Reply
#4

it would be easy when u use sscanf 2
Reply
#5

Quote:
Originally Posted by tandytanz
Посмотреть сообщение
it would be easy when u use sscanf 2
But like you see, I don't use sscanf
Reply
#6

anyone?
Reply
#7

Quote:
Originally Posted by freaxas
Посмотреть сообщение
anyone?
Tbh, I never used strtok before, but give this a try, will ya?
pawn Код:
if(strcmp(cmd, "/makeleader", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SyntaxMessage(playerid, "/makeleader [playerid/name] [number]");
                return 1;
            }
            new para1;
            para1 = ReturnUser(tmp);
            if(IsPlayerNPC(para1)) return 1;
            tmp2 = strtok(tmp, idx);
            if(!strlen(tmp2))
            {
                SyntaxMessage(playerid, "/makeleader [playerid/name] [number]");
                return 1;
            }
            new faction;
            faction = strval(tmp2);
            if(faction < 0 || faction > MAX_FACTIONS) { format(string, sizeof(string), "Faction ID can't be below 0 or above %d.", MAX_FACTIONS); SendClientMessage(playerid, GREY, string); return 1; }
            if(faction != 0 && !FactionInfo[faction][FactionExists]) return SendClientMessage(playerid, GREY, "Invalid faction ID.");
            if(PlayerInfo[playerid][pAdmin] >= 99999 || PlayerInfo[playerid][pFactionMod] > 0)
            {
                if(IsPlayerConnected(para1))
                {
                    if(para1 != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                        PlayerInfo[para1][pRank] = (faction) ? (6) : (0);
                        MakeLeaderOf(para1, faction);
                        format(string, sizeof(string), "WARNING :- You have given %s the leadership-badge of the %s orgnizaiton.", giveplayer,FactionInfo[faction][FactionName]);
                        SendClientMessage(playerid, LIGHTBLUE, string);
                        format(string, sizeof(string), "WARNING :- Adminstrator %s has given you the leadership-badge of the %s orgnization.",sendername,FactionInfo[faction][FactionName]);
                        SendClientMessage(para1, COLOR_LIGHTRED, string);
                        PlayerInfo[para1][pLeader] = faction;
                        PlayerInfo[para1][pMember] = faction;
                        PlayerInfo[para1][pDivision] = 0;
                        SetPlayerToTeamColor(para1);
                        OnPlayerSave(para1);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, GREY, "    You are not authorized to use that command.");
            }
        }
        return 1;
    }
Reply
#8

Quote:
Originally Posted by greentarch
Посмотреть сообщение
Tbh, I never used strtok before, but give this a try, will ya?
pawn Код:
if(strcmp(cmd, "/makeleader", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SyntaxMessage(playerid, "/makeleader [playerid/name] [number]");
                return 1;
            }
            new para1;
            para1 = ReturnUser(tmp);
            if(IsPlayerNPC(para1)) return 1;
            tmp2 = strtok(tmp, idx);
            if(!strlen(tmp2))
            {
                SyntaxMessage(playerid, "/makeleader [playerid/name] [number]");
                return 1;
            }
            new faction;
            faction = strval(tmp2);
            if(faction < 0 || faction > MAX_FACTIONS) { format(string, sizeof(string), "Faction ID can't be below 0 or above %d.", MAX_FACTIONS); SendClientMessage(playerid, GREY, string); return 1; }
            if(faction != 0 && !FactionInfo[faction][FactionExists]) return SendClientMessage(playerid, GREY, "Invalid faction ID.");
            if(PlayerInfo[playerid][pAdmin] >= 99999 || PlayerInfo[playerid][pFactionMod] > 0)
            {
                if(IsPlayerConnected(para1))
                {
                    if(para1 != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                        PlayerInfo[para1][pRank] = (faction) ? (6) : (0);
                        MakeLeaderOf(para1, faction);
                        format(string, sizeof(string), "WARNING :- You have given %s the leadership-badge of the %s orgnizaiton.", giveplayer,FactionInfo[faction][FactionName]);
                        SendClientMessage(playerid, LIGHTBLUE, string);
                        format(string, sizeof(string), "WARNING :- Adminstrator %s has given you the leadership-badge of the %s orgnization.",sendername,FactionInfo[faction][FactionName]);
                        SendClientMessage(para1, COLOR_LIGHTRED, string);
                        PlayerInfo[para1][pLeader] = faction;
                        PlayerInfo[para1][pMember] = faction;
                        PlayerInfo[para1][pDivision] = 0;
                        SetPlayerToTeamColor(para1);
                        OnPlayerSave(para1);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, GREY, "    You are not authorized to use that command.");
            }
        }
        return 1;
    }
Do not work
Reply
#9

Please just use sscanf/2. strtok is so outdated and unnecessarily difficult to use.
Reply
#10

Try

pawn Код:
if(strcmp(cmd, "/makeleader", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SyntaxMessage(playerid, "/makeleader [playerid/name] [number]");
                return 1;
            }
            new para1;
            para1 = ReturnUser(tmp);
            if(IsPlayerNPC(para1)) return 1;
            tmp2 = strtok(tmp, idx);
            if(!strlen(tmp2))
            {
                SyntaxMessage(playerid, "/makeleader [playerid/name] [number]");
                return 1;
            }
            new faction;
            faction = strval(tmp);
            if(faction < 0 || faction > MAX_FACTIONS) { format(string, sizeof(string), "Faction ID can't be below 0 or above %d.", MAX_FACTIONS); SendClientMessage(playerid, GREY, string); return 1; }
            if(faction != 0 && !FactionInfo[faction][FactionExists]) return SendClientMessage(playerid, GREY, "Invalid faction ID.");
            if(PlayerInfo[playerid][pAdmin] >= 99999 || PlayerInfo[playerid][pFactionMod] > 0)
            {
                if(IsPlayerConnected(para1))
                {
                    if(para1 != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                        PlayerInfo[para1][pRank] = (faction) ? (6) : (0);
                        MakeLeaderOf(para1, faction);
                        format(string, sizeof(string), "WARNING :- You have given %s the leadership-badge of the %s orgnizaiton.", giveplayer,FactionInfo[faction][FactionName]);
                        SendClientMessage(playerid, LIGHTBLUE, string);
                        format(string, sizeof(string), "WARNING :- Adminstrator %s has given you the leadership-badge of the %s orgnization.",sendername,FactionInfo[faction][FactionName]);
                        SendClientMessage(para1, COLOR_LIGHTRED, string);
                        PlayerInfo[para1][pLeader] = faction;
                        PlayerInfo[para1][pMember] = faction;
                        PlayerInfo[para1][pDivision] = 0;
                        SetPlayerToTeamColor(para1);
                        OnPlayerSave(para1);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, GREY, "    You are not authorized to use that command.");
            }
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)