SA-MP Forums Archive
there is any way for that? - 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: there is any way for that? (/showthread.php?tid=476214)



there is any way for that? - Joe_Goro - 17.11.2013

hello in my gamemode there is more than 300+ cmd for admin
i wanna make them cant use while not /aduty
is there is anyway to do that without adding

pawn Код:
if(!PlayerInfo[playerid][pAdminDuty]) return SendClientMessageEx(playerid, COLOR_GRAD2, "You can't do this whilst your off Duty!");
before every cmd ?
as my /aduty cmd is

pawn Код:
CMD:aduty(playerid, params[]) {
    new string[128];
    if((PlayerInfo[playerid][pAdmin] >= 2) && GetPVarInt(playerid, "IsInArena") < 0 && !GetPVarInt(playerid, "EventToken")) {
        if(PlayerInfo[playerid][pAdminDuty]) {
            PlayerInfo[playerid][pAdminDuty] = 0;
            PlayerInfo[playerid][pTogReports] = 1;
            //SetPlayerToTeamColor(playerid);
            SendClientMessageEx(playerid, COLOR_WHITE, "You have clocked out from Admin Duty, you are now in Role Play Mode.");
            format(string, sizeof(string), "{AA3333}Admin Duty{FFFF00}: %s has clocked off and is now off duty.", GetPlayerNameEx(playerid));
            ABroadCast(COLOR_YELLOW,string, 2);
        }
        else {
            PlayerInfo[playerid][pAdminDuty] = 1;
            PlayerInfo[playerid][pTogReports] = 0;
            //SetPlayerToTeamColor(playerid);
            SendClientMessageEx(playerid, COLOR_WHITE, "You have clocked in to Admin Duty, you are no longer in Role play Mode.");
            format(string, sizeof(string), "{AA3333}Admin Duty{FFFF00}: %s has clocked in and is now on duty.", GetPlayerNameEx(playerid));
            ABroadCast(COLOR_YELLOW,string, 2);
        }
    }
    return 1;
}



Re: there is any way for that? - ]Rafaellos[ - 17.11.2013

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(!PlayerInfo[playerid][pAdminDuty]) return SendClientMessageEx(playerid, COLOR_GRAD2, "You can't do this whilst your off Duty!");
    return 1;
}



Re: there is any way for that? - Joe_Goro - 17.11.2013

but wait this will disable all commands in the script
there is commands for non-admins

Edit : Please Help Guys


Re: there is any way for that? - ]Rafaellos[ - 17.11.2013

You have right, the only way to do it then is manually.


AW: there is any way for that? - Skimmer - 17.11.2013

Make an array variable with admin commands.

Example
pawn Код:
new AdminCommands[][1] =
{
     {"/kick"},
     {"/ban"},
     {"/warn"},
     {"/announce"}
}
Then you can check the command.
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    for(new i = 0; i < sizeof(AdminCommands); i++)
    {
        if(!strcmp(cmdtext, AdminCommands[i], true)) // Used Admin Command
        {
            if(!PlayerInfo[playerid][pAdminDuty]) return SendClientMessageEx(playerid, COLOR_GRAD2, "You can't do this whilst your off Duty!");
        }
    }
    return 1;
}



Re: there is any way for that? - Konstantinos - 17.11.2013

Skimmer, it'd be /cmdname and he said that the gamemode has 300+ commands for admins. Both ways need a lot of time.


Re: there is any way for that? - iPrivate - 17.11.2013

Well, yes, there's a way but you must do it manually as Rafaellos said, you must add it into each admin command.

pawn Код:
CMD:ADMINCOMMANDHERE(playerid, params[])
{
      if(PlayerInfo[playerid][pAdminDuty])
      {
             // Code here
      }
      else SendClientMessage(playerid, 0xFFFFFFFF, "You must be in admin duty to use this admin command.");
      return 1;
}
That's the only way to do so.

EDIT: Just saw the 300 commands he has,, means that it will be hard to be done, both ways are hard.


Re: there is any way for that? - Joe_Goro - 17.11.2013

ok thanks for everyone
Код:
i would give rep but cant i gave alot last 24h
Edit : i wont make /aduty dafuq to add this line in all commands will take a day