CMD:adminduty(playerid,params[]) { new string[128],pName[MAX_PLAYER_NAME]; new Text3D:label[MAX_PLAYERS]; if(PInfo[playerid][Level] < 1) return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 1 to go on admin duty."); CMDMessageToAdmins(playerid,"ADMINDUTY"); if(PInfo[playerid][pAdminDuty] == 0) { PInfo[playerid][God] = 1; PInfo[playerid][GodCar] = 1; PInfo[playerid][pAdminDuty] = 1; SetPlayerHealth(playerid,100000); SetPlayerSkin(playerid,217); ResetPlayerWeapons(playerid); GivePlayerWeapon(playerid,38,99999); GetPlayerName(playerid,pName,sizeof pName); format(string,sizeof(string),"Administrator %s is now on Admin Duty.",pName); SendClientMessageToAll(COLOR_MENUHIGHLIGHT,string); label[playerid] = Create3DTextLabel("!!ADMIN ON DUTY\n DO NOT ATTACK!!!",COLOR_GREEN,30.0, 40.0, 50.0, 40.0, 0); Attach3DTextLabelToPlayer(label[playerid],playerid,0.0,0.0,0.7); } else { PInfo[playerid][God] = 0; PInfo[playerid][GodCar] = 0; PInfo[playerid][pAdminDuty] = 0; GetPlayerName(playerid,pName,sizeof pName); format(string,sizeof(string),"Administrator %s is now off Admin Duty.",pName); SendClientMessageToAll(COLOR_MENUHIGHLIGHT,string); SetPlayerHealth(playerid,0.0); Delete3DTextLabel(label[playerid]); } return 1; }
new Text3D:label[MAX_PLAYERS];
CMD:adminduty(playerid, params[])
{
if(!PInfo[playerid][Level]) return SendClientMessage(playerid, STEALTH_BLUE, "You need to be level 1 to go on admin duty.");
CMDMessageToAdmins(playerid, "ADMINDUTY");
new string[55], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
if(!PInfo[playerid][pAdminDuty])
{
PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 1;
SetPlayerHealth(playerid, 0x7F800000);
SetPlayerSkin(playerid, 217);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 38, 99999);
format(string, sizeof(string), "Administrator %s is now on Admin Duty.", pName);
label[playerid] = Create3DTextLabel("!!ADMIN ON DUTY\nDO NOT ATTACK!!!", COLOR_GREEN, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
}
else if(PInfo[playerid][pAdminDuty])
{
PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 0;
format(string, sizeof(string), "Administrator %s is now off Admin Duty.", pName);
SetPlayerHealth(playerid, 0.0); //Really? Why 0 health?
Delete3DTextLabel(label[playerid]);
}
SendClientMessageToAll(COLOR_MENUHIGHLIGHT, string);
return 1;
}
new variable = 0;
if(variable == 0)
{
variable = 1;
}
else
{
variable = 0;
}
pawn Код:
Also, you were using an 'else' statement, when you should have been using an 'else if' statement. Basically: pawn Код:
By using an 'else if' statement, this pretty much decides which one should be called at the time the first 'if' statement is called. References: https://sampwiki.blast.hk/wiki/Control_Structures |
new Text3D:label[MAX_PLAYERS];
new Float:OldHealth[MAX_PLAYERS];
CMD:adminduty(playerid, params[])
{
if(!PInfo[playerid][Level]) return SendClientMessage(playerid, STEALTH_BLUE, "You need to be level 1 to go on admin duty.");
CMDMessageToAdmins(playerid, "ADMINDUTY");
new string[55], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
if(!PInfo[playerid][pAdminDuty])
{
PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 1;
GetPlayerHealth(playerid, OldHealth[playerid]);
SetPlayerHealth(playerid, 0x7F800000);
SetPlayerSkin(playerid, 217);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 38, 99999);
format(string, sizeof(string), "Administrator %s is now on Admin Duty.", pName);
label[playerid] = Create3DTextLabel("!!ADMIN ON DUTY\nDO NOT ATTACK!!!", COLOR_GREEN, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
}
else if(PInfo[playerid][pAdminDuty])
{
PInfo[playerid][God] = PInfo[playerid][GodCar] = PInfo[playerid][pAdminDuty] = 0;
format(string, sizeof(string), "Administrator %s is now off Admin Duty.", pName);
SetPlayerHealth(playerid, OldHealth[playerid]); //Really? Why 0 health?
Delete3DTextLabel(label[playerid]);
}
SendClientMessageToAll(COLOR_MENUHIGHLIGHT, string);
return 1;
}