Labels on the Head
#1

As you have heard previously from my topic "Rank System [Problem" i am creating a TDM server.
Now i have been receiving an issue of the labels for players, Apparently, the label only appears to ID 0 (results of the testing/do not rely on this though). The label disappears after the Spawn Protection (or it is never created)

Can someone help me up? Here is the code.

PHP код:
new Text3D:Label[MAX_PLAYERS];
// Stock function for my custom spawn
    // Admin On Duty
    
    
if(aDuty[playerid] == 1)
    {
        
Update3DTextLabelText(Label[playerid], COLOR_REALRED"* DO NOT ATTACK, ADMIN ON DUTY **");
        
SetPlayerColor(playeridCOLOR_PINK);
        
aDuty[playerid] = 1;
        
SetPlayerArmour(playerid100000);
        
SetPlayerHealth(playerid100000);
    }
    
    
// Label on Head
    
    
Update3DTextLabelText(Label[playerid], GetPlayerColor(playerid), GetRank(playerid));
// Rank Up function
Update3DTextLabelText(Label[playerid], GetPlayerColor(playerid), GetRank(playerid));
// Admin Duty
CMD:adminduty(playeridparams[])
{
    new 
string[135], skinid;
    if(
pInfo[playerid][Admin] >= 1)
    {
        if(
aDuty[playerid] == 0)
        {
            if(
sscanf(params"i"skinid)) return SendClientMessage(playeridCOLOR_PINK"USAGE: /adminduty [skinid]");
            if(
skinid || skinid == 74 || skinid 299) return SendClientMessage(playeridCOLOR_PINK"Invalid SkinID.");
        
            
Update3DTextLabelText(Label[playerid], COLOR_REALRED"* DO NOT ATTACK, ADMIN ON DUTY **");
            
SetPlayerColor(playeridCOLOR_PINK);
            
aDuty[playerid] = 1;
            
SetPlayerArmour(playerid100000);
            
SetPlayerHealth(playerid100000);
            
            
SetPlayerSkin(playeridskinid);
            
            
format(stringsizeof(string), "%s %s is now on admin-duty (Color Pink Marker - Admin Duty Label)"GetAdminRank(playerid), nameEx(playerid));
            
SendClientMessageToAll(COLOR_PINKstring);
        }
        else if(
aDuty[playerid] == 1)
        {
            
Update3DTextLabelText(Label[playerid], -1"SFW");
            
aDuty[playerid] = 0;
            
SpawnPlayer(playerid);
            
format(stringsizeof(string), "%s %s is now off admin-duty."GetAdminRank(playerid), nameEx(playerid));
            
SendClientMessageToAll(COLOR_PINKstring);
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_PINK"You do not have the permission to access this command.");
    }
    return 
1;
}
// On Player Connect
    
Delete3DTextLabel(Label[playerid]);
    
Label[playerid] = Create3DTextLabel("SWF", -10.00.00.07.00);
    
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.5);
// On Player Disconnect
    
Delete3DTextLabel(Label[playerid]);
// Spawn Protection OnPlayerSpawn
    
Update3DTextLabelText(Label[playerid], COLOR_LIME"* Spawn Protection *"); 
Any ideas?

Sorry if i have been positing threads with such simple problems, I just really need your help and i can assure you 100% that they are all scripted by me.
Reply
#2

Do you ever attach it when they are spawned? Or only when they connect?
Reply
#3

Have you tried debugging Label[..] and other variables if they're fine through printf()?
Reply
#4

I will be giving you an update about this issue in a few minutes, Re-testing it with a new re-worked code.
Reply
#5

Alright i have managed to fix it, But now the labels keeps on randoming hopping to other players. For example ID 0 has a spawn protection label, It will be assigned to a random player.
Reply
#6

B U M P
Reply
#7

Quote:
Originally Posted by JaKe Elite
Посмотреть сообщение
B U M P
The Code you have on OnPlayerConnect, write it to OnPlayerRequestClass...that should fix the problem
Reply
#8

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
The Code you have on OnPlayerConnect, write it to OnPlayerRequestClass...that should fix the problem
Please dont post something you dont have knowledge about.

@Jake: Is there any other code related to labels?
Reply
#9

That's all i have on my script (I just made them a shortcut on the forum code version)
Reply
#10

I'm not sure, but I think label ids are re-used. So you should set the value of the variable to INVALID_3DTEXT_ID after you've destroyed them. However, if you're not using the chat bubble thingy for anything else you might as well use that instead. Looks the same and is way easier to handle.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)