SA-MP Forums Archive
Problem with /setdiv - 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: Problem with /setdiv (/showthread.php?tid=424227)



Problem with /setdiv - MarTaTa - 21.03.2013

Hello everyone,
I have a small problem with my /setdiv command. So the problem is that, when a faction leader type /setdiv, it sends him the usage message and the available division numbers in his faction, but it also sends him the messages, that are supposed to be sent after the division is changed.

Here's the code :
pawn Код:
CMD:setdiv(playerid, params[])
{
    if(PlayerInfo[playerid][pFactionLeader] == 1 && IsPlayerConnected(playerid))
    {
        new string[128], targetid, divID;
        if(sscanf(params, "ui", targetid, divID))
        {
            SendClientMessage(playerid, COLOR_GRAD1, "USAGE: {FFFFFF}/setdiv [playerid] [div number]");
            switch(PlayerInfo[playerid][pFaction])
            {
                case 1:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "(1) GD | (2) IA | (3) FTO | (4) SWAT");
                }
                case 2:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "(1) GD | (2) CID | (3) IA | (4) FTO");
                }
                case 3:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "(1) GD | (2) T&R | (3) IA");
                }
                case 4:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "(1) GD | (2) LAB | (3) DEF | (4) TRE");
                }
                case 5:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "(1) GD | (2) Instructor | (3) IA | (4) Command");
                }
                default:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "Invalid faction.");
                }
            }
        }
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GRAD2, "Invlaid player specified !");
        if(PlayerInfo[playerid][pFaction] == PlayerInfo[targetid][pFaction])
        {
            format(string, sizeof(string), "* Your division has been changed by %s.", RPName(playerid));
            SendClientMessage(targetid, COLOR_LIGHTBLUE, string);
            format(string, sizeof(string), "* You have changed %s's division.", RPName(targetid));
            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
            PlayerInfo[targetid][pFacDiv] = divID;
        }
    }
    return 1;
}
I'm trying to fix this problem now for few days ....
Much appreciated, thanks in advantage


Re: Problem with /setdiv - JhnzRep - 21.03.2013

pawn Код:
CMD:setdiv(playerid, params[])
{
    if(PlayerInfo[playerid][pFactionLeader] == 1 && IsPlayerConnected(playerid))
    {
        new string[128], targetid, divID;
        if(sscanf(params, "ui", targetid, divID))
        {
            SendClientMessage(playerid, COLOR_GRAD1, "USAGE: {FFFFFF}/setdiv [playerid] [div number]");
            switch(PlayerInfo[playerid][pFaction])
            {
                case 1:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "(1) GD | (2) IA | (3) FTO | (4) SWAT");
                }
                case 2:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "(1) GD | (2) CID | (3) IA | (4) FTO");
                }
                case 3:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "(1) GD | (2) T&R | (3) IA");
                }
                case 4:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "(1) GD | (2) LAB | (3) DEF | (4) TRE");
                }
                case 5:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "(1) GD | (2) Instructor | (3) IA | (4) Command");
                }
                default:
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "Invalid faction.");
                }
            }
            return 1;// <---- You needed this return..
        }
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GRAD2, "Invlaid player specified !");
        if(PlayerInfo[playerid][pFaction] == PlayerInfo[targetid][pFaction])
        {
            format(string, sizeof(string), "* Your division has been changed by %s.", RPName(playerid));
            SendClientMessage(targetid, COLOR_LIGHTBLUE, string);
            format(string, sizeof(string), "* You have changed %s's division.", RPName(targetid));
            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
            PlayerInfo[targetid][pFacDiv] = divID;
        }
    }
    return 1;
}
Missing a return.


Re: Problem with /setdiv - MarTaTa - 21.03.2013

Oh boy didn't realized this

Thanks a lot <3