How to make commands only if you on duty
#1

Hello I make command /aduty But I want to know how to make if you On Duty to can use admins command but
if you off duty to can't and to send this message
Код:
SendClientMessage(playerid, COLOR_GRAD1, "You are not Admin On Duty!")
Reply
#2

pawn Код:
new playerOnDuty[MAX_PLAYERS]; // global outside any callback

// Connect initializes variable:
OnPlayerConnect(playerid) {
playerOnDuty[playerid] = 0;
}

// Command sets player OnDuty
OnPlayerCommandText() {
    if(!strcmp("/onduty", cmdtext)) {
        playerOnDuty[playerid] = 1;
        return 1;
    }

// in a command that can only be used while on duty:
    if(!strcmp("/kick", cmdtext))
    {
        if(playerOnDuty[playerid] == 1) // can use
        else SendClientMessage(playerid, COLOR_GRAD1, "You are not Admin On Duty!");
    }
}
This code is purly for educational use and needs to be implemented rather than copy-paste. It give you a global overview of how it is done.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)