Problem with adminduty command.
#1

Hello guys, I have an irritating thing with my /adminduty command. When i type it once ill get into admin suty. Thats okay. But when i want to get off dut and type i agaon, It is defined to kill. Heres the code

Код:
CMD:adminduty(playerid,params[])
{
   if(PlayerInfo[playerid][Level] >= 1)
   {
         if(PlayerInfo[playerid][OnDuty] == 0) {
         PlayerInfo[playerid][OnDuty] = 1;
	     new str[128], AdminName[28];
         GetPlayerName(playerid, AdminName, sizeof(AdminName));
         format(str, sizeof(str), "Administrator %s is now on Admin duty.!", AdminName);
         SendClientMessageToAll(0xF600F6FF, str);
         SetPlayerSkin(playerid,217);
         SetPlayerTeam(playerid,6);
         SetVehicleHealth(VID[playerid], 9999999999.0);
         Duty[playerid] = Create3DTextLabel("On Duty Admin\n!!Do Not Attack!!", 0xF600F6FF, 30.0, 40.0, 50.0, 40.0, 0);
         Attach3DTextLabelToPlayer(Duty[playerid], playerid, 0.0, 0.0, 0.5);
   	     SetPlayerColor(playerid, 0xF600F6FF);
         SetPlayerHealth(playerid, 100000000000);
         SetPlayerArmour(playerid, 100000000000);
		 ResetPlayerWeapons(playerid);
         GivePlayerWeapon(playerid, 38,999999999);
         Update3DTextLabelText(RankLabel[playerid], 0xFFFFFFFF, " ");
         Update3DTextLabelText(DM[playerid], 0xFFFFFFFF, " ");
         Update3DTextLabelText(GG[playerid], 0xFFFFFFFF, " ");
         UpdateTextdraw(playerid);
         gTeam[playerid] = TEAM_NONE;
         gClass[playerid] = CLASS;
         }
         else if(PlayerInfo[playerid][OnDuty] == 1) {
         PlayerInfo[playerid][OnDuty] = 0;
         new str[128], AdminName[28];
         GetPlayerName(playerid, AdminName, sizeof(AdminName));
         format(str, sizeof(str), "Administrator %s is now off Admin duty.", AdminName);
         SendClientMessageToAll(0xFD01FDAA, str);
         SetPlayerHealth(playerid, 0);
         Update3DTextLabelText(RankLabel[playerid], 0xFFFFFFFF, " ");
         Update3DTextLabelText(Duty[playerid], 0xFFFFFFFF, " ");
         ForceClassSelection(playerid);
	     SetPlayerHealth(playerid, 0);
	     SetPlayerArmour(playerid, 0);
         new rand = random(sizeof(PlayerColors));
         SetPlayerColor(playerid, PlayerColors[rand]);
            }
   } else return 0;
   return 1;
}
Please help me. I want to get off duty directly when i type it again by resetting my weapons and skin if my team.
Reply
#2

use this /aduty
pawn Код:
if (strcmp("/aduty", cmdtext, true, 10) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            if(PlayerInfo[playerid][AdminDuty] == 1)return SendClientMessage(playerid, -1, "{9ACD32}[CL:RP]: "BELA"(( Vec si na Admin Duty, /adutyoff. ))");
            new str[128];
            SetPlayerChatBubble(playerid, "Admin na Duty", -1, 20, 1000000);
            SetPlayerColor(playerid, -1);
            SendClientMessage(playerid, -1, "{9ACD32}[CL:RP]: "BELA"(( Sada si Admin na Duty! ))");
            format(str, sizeof(str), "{9ACD32}[CL:RP]: "BELA"(( Admin %s je sada na duty, sva pitanja /pitaj. ))", imeigraca(playerid));
            SetPlayerHealth(playerid, 99999);
            SetPlayerArmour(playerid, 99999);
            SetPlayerSkin(playerid, 294);
            ResetPlayerWeapons(playerid);
            SendClientMessageToAll(-1, str);
            PlayerInfo[playerid][AdminDuty]++;
        }
        else
        {
            SendClientMessage(playerid, -1, "{9ACD32}[CL:RP]: "BELA"(( Niste ovlasceni da koristite ovu komandu! ))");
        }
        return 1;
    }
    if (strcmp("/adutyoff", cmdtext, true, 10) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            if(PlayerInfo[playerid][AdminDuty] == 0)return SendClientMessage(playerid, -1, "{9ACD32}[CL:RP]: "BELA"(( Ti nisi na Duty, /aduty. ))");
            new str[128];
            SetPlayerChatBubble(playerid, "Admin", -1, 20, 1000000);
            SetPlayerHealth(playerid, 100.0);
            SetPlayerArmour(playerid, 100.0);
            SendClientMessage(playerid, -1, "{9ACD32}[CL:RP]: "BELA"(( Sada vise nisi Admin na Duty! ))");
            format(str, sizeof(str), "{9ACD32}[CL:RP]: "BELA"(( Admin %s vise nije na Duty. ))", imeigraca(playerid));
            SendClientMessageToAll(-1, str);
            PlayerInfo[playerid][AdminDuty]--;
        }
        else
        {
            SendClientMessage(playerid, -1, "{9ACD32}[CL:RP]: "BELA"(( Niste ovlasceni da koristite ovu komandu! ))");
        }
        return 1;
   } //Working and maked and tested by me.
Reply
#3

You're setting the health values to zero, this will kill the player. So do this....
pawn Код:
SetPlayerHealth(playerid, 0);
SetPlayerArmour(playerid, 0);
Needs to become

pawn Код:
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
Or whatever you want the values to be.
Reply
#4

But even though, Will it returns the team skin back without dying?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)