What am I doing wrong?
#1

The command:
pawn Код:
CMD:suspect(playerid, params[])
{
    new Player, reason;
    if (sscanf(params, "us", Player, reason))
    {
        SendClientMessage(playerid, 0xFF0000AA, "[USAGE]/suspect [PlayerName/PlayerID] [Arrest Reason]");
    }
    else if(Player == INVALID_PLAYER_ID)
    {
        SendClientMessage(playerid, 0xFF0000AA, "Invalid PlayerName/PlayerID");
    }
    else if(gPlayerInfo[playerid][pDuty] != 1)
    {
        SendClientMessage(playerid, 0xFF0000AA, "You Are Not On Duty");
    }
    else
    {
        if(gPlayerInfo[playerid][pFaction] == 1)
        {
            if(GetDistanceBetweenPlayers(Player,playerid) > 10)
            {
                SendClientMessage(playerid, COLOR_GREY, "Suspect Is Not Near You...");
            }
            else
            {
                if(IsPlayerInRangeOfPoint(playerid, 5, 223.4862,121.5865,999.0526))
                {
                    if(GetPlayerWantedLevel(Player) == 0)
                    {
                        SetPlayerWantedLevel(Player, 1);
                        new string[128], dragger[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, dragger, sizeof(dragger));
                        TogglePlayerControllable(Player, true);
                        format(string, sizeof(string), "You've been charged with %s by officer %s", reason, dragger);
                        SendClientMessage(Player, COLOR_GREEN, string);
                        SendClientMessage(playerid, COLOR_GREEN, "Your charge has went through to the database");
                    }
                    else if(GetPlayerWantedLevel(Player) == 1)
                    {
                        SetPlayerWantedLevel(Player, 2);
                        new string[128], dragger[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, dragger, sizeof(dragger));
                        TogglePlayerControllable(Player, true);
                        format(string, sizeof(string), "You've been charged with %s by officer %s", reason, dragger);
                        SendClientMessage(Player, COLOR_GREEN, string);
                        SendClientMessage(playerid, COLOR_GREEN, "Your charge has went through to the database");
                    }
                    else if(GetPlayerWantedLevel(Player) == 2)
                    {
                        SetPlayerWantedLevel(Player, 3);
                        new string[128], dragger[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, dragger, sizeof(dragger));
                        TogglePlayerControllable(Player, true);
                        format(string, sizeof(string), "You've been charged with %s by officer %s", reason, dragger);
                        SendClientMessage(Player, COLOR_GREEN, string);
                        SendClientMessage(playerid, COLOR_GREEN, "Your charge has went through to the database");
                    }
                    else if(GetPlayerWantedLevel(Player) == 3)
                    {
                        SetPlayerWantedLevel(Player, 4);
                        new string[128], dragger[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, dragger, sizeof(dragger));
                        TogglePlayerControllable(Player, true);
                        format(string, sizeof(string), "You've been charged with %s by officer %s", reason, dragger);
                        SendClientMessage(Player, COLOR_GREEN, string);
                        SendClientMessage(playerid, COLOR_GREEN, "Your charge has went through to the database");
                    }
                    else if(GetPlayerWantedLevel(Player) == 4)
                    {
                        SetPlayerWantedLevel(Player, 5);
                        new string[128], dragger[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, dragger, sizeof(dragger));
                        TogglePlayerControllable(Player, true);
                        format(string, sizeof(string), "You've been charged with %s by officer %s", reason, dragger);
                        SendClientMessage(Player, COLOR_GREEN, string);
                        SendClientMessage(playerid, COLOR_GREEN, "Your charge has went through to the database");
                    }
                    else if(GetPlayerWantedLevel(Player) == 5)
                    {
                        SetPlayerWantedLevel(Player, 6);
                        new string[128], dragger[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, dragger, sizeof(dragger));
                        TogglePlayerControllable(Player, true);
                        format(string, sizeof(string), "You've been charged with %s by officer %s", reason, dragger);
                        SendClientMessage(Player, COLOR_GREEN, string);
                        SendClientMessage(playerid, COLOR_GREEN, "Your charge has went through to the database");
                    }
                    else if(GetPlayerWantedLevel(Player) == 6)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "Suspect has too many charges!");
                    }
                }
            }
        }
    }
    return 1;
}
In game though I type, /suspect [playerid or their name] [reason], if my reason is one letter, instead of charging another player it charges me... and then if I put more then one letter in the reason... EX: Evading, I get unknown command and nothing happens. Help me out please?
Reply
#2

Reason is created as a integer since you are not specifying a size to make it a 'string'. Obviously, 'reason' will be a text, not a number!

pawn Код:
new Player, reason[128];
    if (sscanf(params, "us[128]", Player, reason))
Reply
#3

Wow lol how did I miss that... thank you for that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)