Need help regarding 3d labels
#1

Код:
public hpcheck(playerid)
{
  new Float:health;
  GetPlayerHealth(playerid,health);
  if (health < 18.0)
  {
    SetPlayerDrunkLevel(playerid,10000);
    new wounded = Create3DTextLabel("Wounded",COLOR_YELLOW,0.0,0.0,0.0,40.0,0);
    Attach3DTextLabelToPlayer(wounded, playerid, 0, 0, 0, 0);
    return 1;
  }
  else if (health < 9.0)
  {
    SetPlayerDrunkLevel(playerid,50000);
    new hwounded = Create3DTextLabel("HEAVILY Wounded",COLOR_RED,30.0,40.0,50.0,40.0,0);
    Attach3DTextLabelToPlayer(hwounded, playerid, 0, 0, 0, 0);
    return 1;
  }
  else if (health > 18.0)
  {
    SetPlayerDrunkLevel(playerid,0);
  }


	return 1;
}
Problem here is - it attaches the label to all players. Why?
Reply
#2

you need SetTimerEx

https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#3

I have this at OnPlayerConnect:

SetTimerEx("hpcheck",2000,true,"i",playerid);
Reply
#4

1st of all if you have that public on a timer i'm sure somebody's game will eventually crash as every time you call it and their health is below what you have set it will create a new 3d text everytime so why not just create 1 3dtext like

new 3DText:Player[MAX_PLAYERS]

then on player spawn just create their 3dtext and just give it a blank name so you can't see it untill necessary and just update their 3d text instead of creating new ones..

also change the public from playerid to
Код:
for(new i=0; i < MAX_PLAYERS; i++)
	{
so then it will call upon every player but set it to those only with hp less than wat ever
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)