[Tutorial] [TUT]Admin Only Command for anything!!
#8

Can be way simpler:
Code:
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "This command can only be used by an admin!!");
Original code:
Code:
if (strcmp("/cctv", cmdtext, true) == 0)
{
  PlayerMenu[playerid] = 0;
  TogglePlayerControllable(playerid, 0);
  ShowMenuForPlayer(CCTVMenu[0], playerid);
  return 1;
}
Admin only:
Code:
if (strcmp("/cctv", cmdtext, true) == 0)
{
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "This command can only be used by an admin!!");

  PlayerMenu[playerid] = 0;
  TogglePlayerControllable(playerid, 0);
  ShowMenuForPlayer(CCTVMenu[0], playerid);
  return 1;
}
Saves a lot of code, saves messing with brackets/indentation and is simply cleaner.
Reply


Messages In This Thread
[TUT]Admin Only Command for anything!! - by DEJORDZTA - 11.08.2009, 06:08
Re: [TUT]Admin Only Command for anything!! - by CracK - 11.08.2009, 06:11
Re: [TUT]Admin Only Command for anything!! - by DarkClone - 11.08.2009, 06:14
Re: [TUT]Admin Only Command for anything!! - by ruarai - 11.08.2009, 06:29
Re: [TUT]Admin Only Command for anything!! - by Joe Staff - 11.08.2009, 06:32
Re: [TUT]Admin Only Command for anything!! - by CracK - 11.08.2009, 06:46
Re: [TUT]Admin Only Command for anything!! - by Joe Staff - 11.08.2009, 06:48
Re: [TUT]Admin Only Command for anything!! - by Woet - 11.08.2009, 07:26
Re: [TUT]Admin Only Command for anything!! - by CracK - 11.08.2009, 08:59
Re: [TUT]Admin Only Command for anything!! - by Burridge - 11.08.2009, 14:46

Forum Jump:


Users browsing this thread: 1 Guest(s)