SA-MP Forums Archive
/makeleader problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /makeleader problem (/showthread.php?tid=522908)



/makeleader problem - freaxas - 29.06.2014

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


Re: /makeleader problem - VladimirMark - 29.06.2014

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 "[]"


Re: /makeleader problem - freaxas - 30.06.2014

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.


Re: /makeleader problem - tandytanz - 30.06.2014

it would be easy when u use sscanf 2


Re: /makeleader problem - freaxas - 30.06.2014

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


Re: /makeleader problem - freaxas - 30.06.2014

anyone?


Re: /makeleader problem - greentarch - 30.06.2014

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;
    }



Re: /makeleader problem - freaxas - 30.06.2014

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


Re: /makeleader problem - PrivatioBoni - 30.06.2014

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


Re: /makeleader problem - Stereotype - 30.06.2014

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;
    }