Attatch3DTextLabelToPlayer Error -
aoky - 28.05.2017
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] == 0 && killerid != INVALID_PLAYER_ID)
{
GetPlayerPos(playerid, BMPos[0], BMPos[1], BMPos[2]);
Character[playerid][BrutalM] = 1;
Character[playerid][CanAccept] = 0;
LegHit[playerid] = 0;
format(DTextS, sizeof(DTextS), "(( %s is currently injured, type /damages %i for more info. ))", GetName(playerid), playerid);
label[playerid] = Create3DTextLabel(DTextS, COLOR_RED, BMPos[0], BMPos[1], BMPos[2], 10.0, 0);
Attach3DTextLabelToPlayer(label[playerid], playerid, 0, 0, 0.7);
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
Delete3DTextLabel(label[playerid]);
Delete3DTextLabel(label2[playerid]);
There is more here, just hidden cus it's not neededd.
Revive command that has the removed label code
PHP код:
CMD:revive(playerid, params[])
{
new pID, str[128];
if(Account[playerid][Admin] >= 1)
{
if(sscanf(params, "u", pID)) return SendClientMessage(playerid, COLOR_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(pID, true);
ClearAnimations(pID);
format(str, sizeof(str), "Admin %s has just revived you.", GetRoleplayName(playerid));
SendClientMessage(pID, COLOR_SEAGREEN, str);
SetPlayerHealth(pID, 100.0);
}
else
{
SendErrorMessage(playerid, ERROR_ADMIN);
}
return 1;
}
The text stays above the players head sometimes which is annoying and only fixed after a server restart, why is this?
Re: Attatch3DTextLabelToPlayer Error -
Sew_Sumi - 28.05.2017
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.
Re: Attatch3DTextLabelToPlayer Error -
Swarn - 28.05.2017
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]);
Re: Attatch3DTextLabelToPlayer Error -
aoky - 28.05.2017
Thank you for the help, I believe I managed to fix this issue. Repped.