3dlabel
#1

Код:
ALTCOMMAND:aduty->adminduty;
COMMAND:adminduty(playerid, params[])
{
	new Text3D:test = Create3DTextLabel("ADMIN DUTY", 0x00BFFFAA, 30.0, 40.0, 50.0, 40.0, 0); //Put this at the top.

	if(PlayerInfo[playerid][pAdminlevel] > 0)
	{
	    if(GetPVarInt(playerid, "StaffLogin") == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You must be logged into the staff panel to access administration commands. (/stafflogin)");
	    switch(GetPVarInt(playerid, "AdminDuty"))
		{
	        case 0:
			{
	            new msg[90];
				SetPlayerColor(playerid, 0x4e6c8200);
				SetPVarInt(playerid, "AdminDuty", 1);
				Attach3DTextLabelToPlayer(test, playerid, 0.0, 0.0, 0.7); // And put this where you want.
				format(msg, sizeof(msg), "*** %s %s is now on duty as an administrator.", GetAdminRank(playerid), GetNameWithSpace(playerid));
				AdminMessageLog(msg, playerid, "Admin Duty");
			}
			default: {
			    new msg[90];
			    Delete3DTextLabel(test);
				SetPVarInt(playerid, "AdminDuty", 0);
				UpdatePlayerColor(playerid);
    			format(msg, sizeof(msg), "*** %s %s is now off duty as an administrator.", GetAdminRank(playerid), GetNameWithSpace(playerid));
                AdminMessageLog(msg, playerid, "Admin Duty");
			}
		}
	} else {
		SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command.");
	}

	return 1;
}
does not remove when the player does /aduty to get of.
Reply
#2

Because, you are using local variable for the text label. Which creates only when the CMD:adminduty function has been called, means the var won't hold the same label ID therefore it's not getting deleted. You need to create a global variable instead.

PHP код:

// On top of your script
new
    
Text3Dg_DutyLabel[MAX_PLAYERS];
    
// Inside public OnPlayerDisconnect(playerid, reason)
    
Delete3DTextLabel(g_DutyLabel[playerid]);
COMMAND:adminduty(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdminlevel] > 0)
    {
        if(
GetPVarInt(playerid"StaffLogin") == 0) return SendClientMessage(playeridCOLOR_LIGHTRED"You must be logged into the staff panel to access administration commands. (/stafflogin)");
        new
            
msg[100];
        switch(
GetPVarInt(playerid"AdminDuty"))
        {
            case 
0:
            {
                
SetPlayerColor(playerid0x4e6c8200);
                
SetPVarInt(playerid"AdminDuty"1);
                
g_DutyLabel[playerid] = Create3DTextLabel("ADMIN DUTY"0x00BFFFAA30.040.050.040.00);
                
Attach3DTextLabelToPlayer(g_DutyLabel[playerid], playerid0.00.00.7);
                
format(msgsizeof(msg), "*** %s %s is now on duty as an administrator."GetAdminRank(playerid), GetNameWithSpace(playerid));
                
AdminMessageLog(msgplayerid"Admin Duty");
            }
            case 
1:
            {
                
Delete3DTextLabel(g_DutyLabel[playerid]);
                
SetPVarInt(playerid"AdminDuty"0);
                
UpdatePlayerColor(playerid);
                
format(msgsizeof(msg), "*** %s %s is now off duty as an administrator."GetAdminRank(playerid), GetNameWithSpace(playerid));
                
AdminMessageLog(msgplayerid"Admin Duty");
            }
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_LIGHTRED"You are not authorized to use this command.");
    }
    return 
1;

Reply
#3

You have a local variable that stores the 3DText id. Local variables get destroyed when the function ends. This means you lose the handle to said 3DText after the command is executed, making it impossible to destroy. You need either a static local or a global variable and it needs to be a MAX_PLAYER array.

Edit: ^ explained well.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)