Problem with /setdiv
#1

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
Reply
#2

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.
Reply
#3

Oh boy didn't realized this

Thanks a lot <3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)