SA-MP Forums Archive
How to make commands only if you on duty - 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: How to make commands only if you on duty (/showthread.php?tid=334959)



How to make commands only if you on duty - RenSoprano - 16.04.2012

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!")



Re: How to make commands only if you on duty - mamorunl - 16.04.2012

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.