Attatch3DTextLabelToPlayer Error
#1

So basically, when a player dies it places text above their head but there is chance that it will stay even when you /revive them or they accept death. I have a feeling that it's got to do with when someone dies it updates in the database. Here is all the code that's got to do with the labels.

There is two modes: Brutally Wounded and Deathmode.

PHP код:
new Text3D:label[MAX_PLAYERS];
new 
Text3D:label2[MAX_PLAYERS]; 
PHP код:
  if(Character[playerid][BrutalM] == && killerid != INVALID_PLAYER_ID)
        {
            
GetPlayerPos(playeridBMPos[0], BMPos[1], BMPos[2]);
            
Character[playerid][BrutalM] = 1;
            
Character[playerid][CanAccept] = 0;
            
LegHit[playerid] = 0;
            
format(DTextSsizeof(DTextS), "(( %s is currently injured, type /damages %i for more info. ))"GetName(playerid), playerid);
            
label[playerid] = Create3DTextLabel(DTextSCOLOR_REDBMPos[0], BMPos[1], BMPos[2], 10.00);
            
Attach3DTextLabelToPlayer(label[playerid], playerid000.7); 
PHP код:
public OnPlayerDisconnect(playeridreason)
{
    
Delete3DTextLabel(label[playerid]);
    
Delete3DTextLabel(label2[playerid]);
        
There is more herejust hidden cus it's not neededd. 
Revive command that has the removed label code

PHP код:
CMD:revive(playeridparams[])
{
    new 
pIDstr[128];
    if(
Account[playerid][Admin] >= 1)
    {
        if(
sscanf(params"u"pID)) return SendClientMessage(playeridCOLOR_GRAY"/revive [id]");
        
Delete3DTextLabel(label[playerid]);
        
Delete3DTextLabel(label2[playerid]);
        
Character[pID][BrutalM] = 0;
        
Character[pID][Dead] = 0;
        
ResetPlayerDamages(pID);
        
LegHit[pID] = 0;
        
KillTimer(DeathT);
        
KillTimer(RTimer);
        
TogglePlayerControllable(pIDtrue);
        
ClearAnimations(pID);
        
format(strsizeof(str), "Admin %s has just revived you."GetRoleplayName(playerid));
        
SendClientMessage(pIDCOLOR_SEAGREENstr);
        
SetPlayerHealth(pID100.0);
    }
    else
    {
        
SendErrorMessage(playeridERROR_ADMIN);
    }
    return 
1;

The text stays above the players head sometimes which is annoying and only fixed after a server restart, why is this?
Reply
#2

Where you've got the second block of code here, what callback/function is that under?

You could use
Код:
if(!label[playerid]&&!label2[playerid])
to avoid that if the labels exist.


It may be creating more than one 3DText, and simply deleting the latest one that's tracked by the variable.
Reply
#3

I think what you are doing is when you execute the revive command, you are removing the text label for the person executing the revive command as it's set to [playerid] and not pID.

Change
Код:
Delete3DTextLabel(label[playerid]); 
Delete3DTextLabel(label2[playerid]);
to
Код:
Delete3DTextLabel(label[pID]); 
Delete3DTextLabel(label2[pID]);
Reply
#4

Thank you for the help, I believe I managed to fix this issue. Repped.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)