3d text label disappearing
#1

Hey guys i am in some trouble... I made a simple onduty/offduty system for admins, which shows if an admin is on or off duty in /admins (cmd that shows online admins), But i also wanted to add 3dtext labels above player's head when the commands are being used.

The problem is that when another admin uses the command, the 3d text label disappears from above the first admin's head. For example if they are 2 admins online and the first admin types /offduty its all ok, but when the second one then types /offduty, the 3d text label which says "Off Duty" disappears from above the first player. I really dont know whats wrong, but i tought maybe one of you does?

Here's the code:

Код:
CMD:onduty(playerid,params[]) {
	new string[128],playername[MAX_PLAYER_NAME];
	if(PlayerInfo[playerid][Level] >= 1) {
	    ONDUTY[playerid] = Create3DTextLabel("On Duty", 0x00FFFFAA, 0.0, 0.0, 2.0, 40, 0, 0);
	    Delete3DTextLabel(OFFDUTY[playerid]);
 	    Attach3DTextLabelToPlayer(ONDUTY[playerid],playerid,0.0, 0.0, 0.4);
	    SendCommandToAdmins(playerid,"ONDUTY");
		GetPlayerName(playerid, playername, sizeof(playername));
		format(string,128,"You are now on duty");
		SendClientMessage(playerid,blue,string);
		dUserSetINT(PlayerName2(playerid)).("OnDuty",(1));
		PlayerInfo[playerid][OnDuty] = 1;
	} else	{
		SendClientMessage(playerid,COLOR_RED,"ERROR: You need to be admin to use this command");
	}
	return 1;
}

CMD:offduty(playerid,params[]) {
	new string[128],playername[MAX_PLAYER_NAME];
	if(PlayerInfo[playerid][Level] >= 1) {
	    OFFDUTY[playerid] = Create3DTextLabel("Off Duty", 0x00FFFFAA, 0.0, 0.0, 2.0, 40, 0, 0);
	    Delete3DTextLabel(ONDUTY[playerid]);
 	    Attach3DTextLabelToPlayer(OFFDUTY[playerid],playerid,0.0, 0.0, 0.4);
		SendCommandToAdmins(playerid,"OFFDUTY");
		GetPlayerName(playerid, playername, sizeof(playername));
		format(string,128,"You are now off duty");
		SendClientMessage(playerid,blue,string);
		dUserSetINT(PlayerName2(playerid)).("OnDuty",(0));
		PlayerInfo[playerid][OnDuty] = 0;
	} else	{
		SendClientMessage(playerid,COLOR_RED,"ERROR: You need to be admin to use this command");
	}
	return 1;
}
and this on the top:

Код:
new Text3D: ONDUTY[MAX_PLAYERS];
new Text3D: OFFDUTY[MAX_PLAYERS];
Thank you in advance
Reply
#2

Well try this:
(maybe set DUTY[playerid] on -1 or something under OnPlayerConnect)
PHP код:
new Text3DDUTY[MAX_PLAYERS]; 
PHP код:
CMD:onduty(playerid,params[]) {
    new 
string[128],playername[MAX_PLAYER_NAME];
    if(
PlayerInfo[playerid][Level] >= 1) {
            
Delete3DTextLabel(DUTY[playerid]);
        
DUTY[playerid] = Create3DTextLabel("On Duty"0x00FFFFAA0.00.02.04000);
         
Attach3DTextLabelToPlayer(DUTY[playerid],playerid,0.00.00.4);
        
SendCommandToAdmins(playerid,"ONDUTY");
        
GetPlayerName(playeridplayernamesizeof(playername));
        
format(string,128,"You are now on duty");
        
SendClientMessage(playerid,blue,string);
        
dUserSetINT(PlayerName2(playerid)).("OnDuty",(1));
        
PlayerInfo[playerid][OnDuty] = 1;
    } else    {
        
SendClientMessage(playerid,COLOR_RED,"ERROR: You need to be admin to use this command");
    }
    return 
1;
}
CMD:offduty(playerid,params[]) {
    new 
string[128],playername[MAX_PLAYER_NAME];
    if(
PlayerInfo[playerid][Level] >= 1) {
            
Delete3DTextLabel(DUTY[playerid]);
        
DUTY[playerid] = Create3DTextLabel("Off Duty"0x00FFFFAA0.00.02.04000);
         
Attach3DTextLabelToPlayer(DUTY[playerid],playerid,0.00.00.4);
        
SendCommandToAdmins(playerid,"OFFDUTY");
        
GetPlayerName(playeridplayernamesizeof(playername));
        
format(string,128,"You are now off duty");
        
SendClientMessage(playerid,blue,string);
        
dUserSetINT(PlayerName2(playerid)).("OnDuty",(0));
        
PlayerInfo[playerid][OnDuty] = 0;
    } else    {
        
SendClientMessage(playerid,COLOR_RED,"ERROR: You need to be admin to use this command");
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)