Admin Duty Help
#1

I Have Problem with this Command.
When I go "On Duty" I can't go to "off Duty"

Код:
dcmd_AdminDuty(playerid, cmdtext[]){
       #pragma unused cmdtext
       if(IsPlayerLAdmin(playerid))
       {
        if(Admin[playerid] == 0)
        {
         Admin[playerid] = 1;
         new str[128], AdminName[28];
         GetPlayerName(playerid, AdminName, sizeof(AdminName));
         format(str, sizeof(str), "%s Is Now On Admin Duty!", AdminName);
         SendClientMessageToAll(COLOR_RED2, str);
         SetPlayerSkin(playerid,217);
         SetPlayerTeam(playerid, 6);
   	     SetPlayerColor(playerid, COLOR_PINK);
         SetPlayerHealth(playerid, 10000000);
         SetPlayerArmour(playerid, 10000000);
         GivePlayerWeapon(playerid, 9, 999999999);
         GivePlayerWeapon(playerid, 38,999999999);
	     GivePlayerWeapon(playerid, 24,999999999);
	     GivePlayerWeapon(playerid, 26,999999999);
	     GivePlayerWeapon(playerid, 31,999999999);
	     GivePlayerWeapon(playerid, 34,999999999);
	     GivePlayerWeapon(playerid, 32,999999999);
         GivePlayerWeapon(playerid, 42,999999999);
         GivePlayerWeapon(playerid, 16,999999999);
         label2[playerid] = Create3DTextLabel("Admin On Duty Do Not Attack",COLOR_GREEN,40.0,60.0,80.0,60.0,0);
         Attach3DTextLabelToPlayer(label2[playerid], playerid, 0.0, 0.0, 0.7);
      }
      else if(Admin[playerid] == 1)
      {
      Admin[playerid] = 0;
      new str[128], AdminName[28];
      GetPlayerName(playerid, AdminName, sizeof(AdminName));
      format(str, sizeof(str), "%s Is Now Off Admin Duty!", AdminName);
      SendClientMessageToAll(COLOR_RED2, str);
      ForceClassSelection(playerid);
      SetPlayerHealth(playerid, 0);
      } Erorr1
      }
When Im "On Duty" and I type that command Nothing Happens
Reply
#2

mhm i am not the scripter but, you can copy it from RAVENS RP GM
Reply
#3

Try using a switch - just to iron out any bs

I can't really see anything wrong with your code imo

pawn Код:
switch (Admin[playerid])
{
  case 0:
  {
    Admin[playerid] = 1;
  }
  case 1:
  {
    Admin[playerid] = 0;
  }
}
Reply
#4

You do
pawn Код:
else if(Admin[playerid] == 1)
try doing
pawn Код:
else (Admin[playerid] == 1)
The script might assume there's another if clausule coming, and therefore ignores the else if, because there's no else in your script.
Reply
#5

Quote:
Originally Posted by MdeRooy
Посмотреть сообщение
You do
pawn Код:
else if(Admin[playerid] == 1)
try doing
pawn Код:
else (Admin[playerid] == 1)
The script might assume there's another if clausule coming, and therefore ignores the else if, because there's no else in your script.
You would just do else { }
Reply
#6

No, you can't do if - else if, and then nothing. You can only do if - else or if - else if - else if- else.
Reply
#7

Quote:
Originally Posted by MdeRooy
Посмотреть сообщение
No, you can't do if - else if, and then nothing. You can only do if - else or if - else if - else if- else.
that's NOT what I was saying...

you would do else { some shit here } instead of else (Admin[playerid] == 1)
Reply
#8

I Try This CODE
And Still Same Problem

PHP код:
 if(IsPlayerLAdmin(playerid))
       {
        if(
Admin[playerid] == 0)
        {
         
Admin[playerid] = 1;
         new 
str[128], AdminName[28];
         
GetPlayerName(playeridAdminNamesizeof(AdminName));
         
format(strsizeof(str), "%s Is Now On Admin Duty!"AdminName);
         
SendClientMessageToAll(COLOR_RED2str);
         
SetPlayerSkin(playerid,217);
         
SetPlayerTeam(playerid6);
            
SetPlayerColor(playeridCOLOR_PINK);
         
SetPlayerHealth(playerid10000000);
         
SetPlayerArmour(playerid10000000);
         
GivePlayerWeapon(playerid9999999999);
         
GivePlayerWeapon(playerid38,999999999);
         
GivePlayerWeapon(playerid24,999999999);
         
GivePlayerWeapon(playerid26,999999999);
         
GivePlayerWeapon(playerid31,999999999);
         
GivePlayerWeapon(playerid34,999999999);
         
GivePlayerWeapon(playerid32,999999999);
         
GivePlayerWeapon(playerid42,999999999);
         
GivePlayerWeapon(playerid16,999999999);
         
label2[playerid] = Create3DTextLabel("Admin On Duty Do Not Attack",COLOR_GREEN,40.0,60.0,80.0,60.0,0);
         
Attach3DTextLabelToPlayer(label2[playerid], playerid0.00.00.7);
         }
      }
      else
      {
      
Admin[playerid] = 0;
      new 
str[128], AdminName[28];
      
GetPlayerName(playeridAdminNamesizeof(AdminName));
      
format(strsizeof(str), "%s Is Now Off Admin Duty!"AdminName);
      
SendClientMessageToAll(COLOR_RED2str);
      
ForceClassSelection(playerid);
      
SetPlayerHealth(playerid0);
      }
      return 
1;

Reply
#9

use the switch Rob posted
Reply
#10

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
use the switch Rob posted
Fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)