[Help] error 017: undefined symbol "label" -
ApolloScripter - 30.11.2018
I created a command for my administrators to enter and exit the "duty" mode, I put a 3DTextLabel connected to the player, to appear "Admin" on top of his name, if he is in duty mode, but is giving error, does anyone know why?
My Command:
PHP код:
ACMD:admin[1](playerid, params[])
{
if(GetPlayerAdminLevel(playerid) < 2)
return Msg(playerid, RED, "[ > ] Vocк nгo tem permissгo para usar este comando.");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
{
Msg(playerid, RED, "[ > ] Vocк nгo pode fazer isso enquanto estб espiando!");
return 1;
}
if(!IsPlayerOnAdminDuty(playerid))
{
TogglePlayerAdminDuty(playerid, true);
MsgAdminsF(1, NovoA, "[ > ] O(a) Administrador(a){FFFFFF} %s {00c0ff}saiu do modo jogador!", name);
Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.2);
}
else
{
TogglePlayerAdminDuty(playerid, false);
MsgAdminsF(1, NovoA, "[ > ] O(a) Administrador(a){FFFFFF} %s {00c0ff}entrou no modo jogador!", name);
Delete3DTextLabel(label);
}
return 1;
}
My 3D Label Definition, under of OnPlayerConnect
PHP код:
hook OnPlayerConnect(playerid)
{
new Text3D:label = Create3DTextLabel("Admin", 0x33CCFFFF, 30.0, 40.0, 50.0, 10.0, 0);
}
Errors
Код:
SS/Core/Admin/Admin-1CMD.pwn(80) : error 017: undefined symbol "label"
SS/Core/Admin/Admin-1CMD.pwn(86) : error 017: undefined symbol "label"
Line of error 1:
PHP код:
Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.2);
Line of error 2:
PHP код:
Delete3DTextLabel(label);
If Someone can help, i'll be very grateful.
Re: [Help] error 017: undefined symbol "label" -
v1k1nG - 30.11.2018
Define the label variable outside functions
Re: [Help] error 017: undefined symbol "label" -
Revy - 30.11.2018
This is called "local variable", this kinda runs in the name. You can't access a local variable from "OnPlayerConnect" to a command. Because it's closed down in the callback. Create it however outside a callback/function/command, it becomes a global variable, this you can access through the whole script anytime you'd like.
Take a look at this:
SS/Core/Admin/Admin-1CMD.pwn(86) : error 017: undefined symbol "label"
undefined symbol, because it doesn't find "label". Create it on the top of your script as a global, then you are good to go.