3dlabel -
alexanderjb918 - 06.06.2016
Код:
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.
Re: 3dlabel -
Sjn - 06.06.2016
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
Text3D: g_DutyLabel[MAX_PLAYERS];
// Inside public OnPlayerDisconnect(playerid, reason)
Delete3DTextLabel(g_DutyLabel[playerid]);
COMMAND:adminduty(playerid, params[])
{
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)");
new
msg[100];
switch(GetPVarInt(playerid, "AdminDuty"))
{
case 0:
{
SetPlayerColor(playerid, 0x4e6c8200);
SetPVarInt(playerid, "AdminDuty", 1);
g_DutyLabel[playerid] = Create3DTextLabel("ADMIN DUTY", 0x00BFFFAA, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(g_DutyLabel[playerid], playerid, 0.0, 0.0, 0.7);
format(msg, sizeof(msg), "*** %s %s is now on duty as an administrator.", GetAdminRank(playerid), GetNameWithSpace(playerid));
AdminMessageLog(msg, playerid, "Admin Duty");
}
case 1:
{
Delete3DTextLabel(g_DutyLabel[playerid]);
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;
}
Re: 3dlabel -
Vince - 06.06.2016
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.