How to return an error message?
#1

I have this /duty command here for admins on duty:

pawn Код:
dcmd_duty(playerid,params[]){
    #pragma unused params
    if(PlayerInfo[playerid][LoggedIn] == 1) {
        if(PlayerInfo[playerid][Level] >= 1|| IsPlayerAdmin(playerid)) {
            if(!IsPlayerAdmin(playerid))
            {
//              SendClientMessage(playerid,MSGFAIL_COLOR,"Command not available.");
            }
            new player1;
            SetPlayerSkin(playerid,294);
            SetPlayerHealth(playerid,99999999);
            SetPlayerArmour(playerid,99999999);
            SetPlayerColor(playerid,0xABCDEF66);
            ResetPlayerWeapons(player1);
//          GivePlayerWeapon(playerid,36,13337);
//          GivePlayerWeapon(playerid,37,13337);
            GivePlayerWeapon(playerid,38,13337);
            GivePlayerWeapon(playerid,39,13337);
            GivePlayerWeapon(playerid,40,13337);
            GameTextForPlayer(playerid,"~p~On Duty As Admin", 3000, 1);
            SendClientMessage(playerid,0xFF66FFAA,"You Are Now ON DUTY - Spawned With Admin Skin, Godmode And Unlimited Minigun Ammo.");
            SendClientMessage(playerid,0xFF0000AA,"DO NOT ATTACK / ABUSE POWERS ON INNOCENT PLAYERS - You Will Be Punished!");
            new string[128],
            name[MAX_PLAYER_NAME];
            GetPlayerName(playerid,name,MAX_PLAYER_NAME);
            format(string,sizeof string,"***ON DUTY: %s (%d) (ADMIN DUTY) This Admin Is ON DUTY.", name,playerid);
            SendClientMessageToAll(COLOR_PINK, string);
        } else return SendClientMessage(playerid,red,"You Are Already On Duty.");
    }
//  new Color=GetPlayerColor(playerid);
    return 1;
}
and a /dutyoff to respawn the player to regular class:

pawn Код:
dcmd_dutyoff(playerid,params[]) {
    #pragma unused params
    if(PlayerInfo[playerid][LoggedIn] == 1) {
        if(PlayerInfo[playerid][Level] >= 1 || IsPlayerAdmin(playerid)) {
            GameTextForPlayer(playerid,"~r~Off Duty - ~p~Respawned", 3000, 1);
            SendClientMessage(playerid,0xFF0000AA,"You Are Now OFF DUTY - Respawned At Four Dragons Casino.");
            SetPlayerHealth(playerid, 100);
            SetPlayerTeam(playerid, 1);
            SetPlayerColor(playerid,0xFF0000AA);
//          SpawnPlayer(playerid);
//          ForceClassSelection(playerid);
//          SetPlayerHealth(playerid,0);
            new string[128],
            name[MAX_PLAYER_NAME];
            GetPlayerName(playerid,name,MAX_PLAYER_NAME);
            format(string,sizeof string,"***OFF DUTY: %s (%d) (ADMIN DUTY) This Admin Is OFF DUTY.", name,playerid);
            SendClientMessageToAll(COLOR_PINK, string);
            SetSpawnInfo(playerid, 0, 20, 2028.1997,1007.8245,10.8203,270.6008, 4, 0, 18, 20, 26, 500);
            //SetPlayerColor(playerid,0xFF0000AA);

            return SpawnPlayer(playerid);
        } else return SendClientMessage(playerid,red,"ERROR: Command unavalible"); //idk how to spell that
    } else return SendClientMessage(playerid,red,"ERROR: You are not logged in");
}
What I need is an error message to be returned when the admin types /duty again to say "You are already on duty" and one for /dutyoff that says "You are already off duty", because right now, I can spam /duty and /dutyoff even though I am already on duty and off duty, what should I add to make it so it can return that using:
pawn Код:
else return
just like below ?
pawn Код:
} else return SendClientMessage(playerid,red,"ERROR: You Are Already On Duty / (Off Duty)");
thanks
Reply
#2

Try something like

new AdminDuty[MAX_PLAYERS];

if(AdminDuty[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"ERROR: Your ALready on Duty!");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)