GetPlayerHealth bugged?
#4

I have a server with 100+ players sometimes 200+. If you have a very good game hosting (a good processor) will be just a piece of cake, because yeah maybe the public will be called 5 times ~ in the same time, or the public will be called by the same playerid two times in 1 sec. But you can get out it, using a variable as in the following example:
PHP код:
new smmh[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
   
smmh[playerid]=0;
   return 
1;
}
public 
OnPlayerDisconnect(playerid)
{
  
smmh[playerid]=0;
  return 
1;
}
forward ShowMeMyHealth(playerid); 
public 
ShowMeMyHealth(playerid

    
GetPlayerHealth(playerid,health); 
    
printf("HP in HPBar %f",health); 
    
smmh[playerid]=0;

public 
OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart

    
Account[playerid][Health] -= amount
    
SetPlayerHealth(playerid,Account[playerid][Health]); 
    new 
Float:health
    
printf("HP in Acc %f",Account[playerid][Health]); 
    if(!
smmh[playerid]){ smmh[playerid]=1SetTimerEx("ShowMeMyHealth",1000,"i",0,playerid); } 
        return 
1

Try it, I use timers in order to detect Invulnerable, for instance I check and every each 10 second each player using the following algorithm: I set its hp-1 and after 1 sec I check if its hp is -1 if it is not it means that it use invulnerable.. and it works.. (I also check about ping etc..)
Reply


Messages In This Thread
GetPlayerHealth bugged? - by BloodyRP - 21.04.2016, 12:33
Re: GetPlayerHealth bugged? - by AdrianG - 21.04.2016, 13:03
Re: GetPlayerHealth bugged? - by BloodyRP - 21.04.2016, 13:08
Re: GetPlayerHealth bugged? - by AdrianG - 21.04.2016, 14:09

Forum Jump:


Users browsing this thread: 1 Guest(s)