SA-MP Forums Archive
OnPlayerInfoChange not working ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerInfoChange not working ? (/showthread.php?tid=88250)



OnPlayerInfoChange not working ? - boelie - 25.07.2009

Hello,

I was trying some stuff with OnPlayerStateInfo;
Код:
public OnPlayerInfoChange(playerid)
{

	new Float:health;
  GetPlayerHealth(playerid,health);
  if (health < 50.0)
  {
  new currentState = GetPlayerState(playerid);
  if (currentState == PLAYER_STATE_ONFOOT)
	{     	//
	SendClientMessage(playerid,0xDEEE20FF,"working now");
	}

}
	//
 
	return 1;
}
I wanted to code something that makes when a players health gets low. a Animation like 'injured' or handsup will be called.
As you can see i tried if playerinfo change works..i guess its not..i dont have compile warnings or errors though.

Maybe someone can tell me how i can make this work ?




Re: OnPlayerInfoChange not working ? - yezizhu - 25.07.2009

yes


Re: OnPlayerInfoChange not working ? - boelie - 25.07.2009

1.yes, its not working?


2.yes, i can help you?


if yes == 2
{
SendClientmessage Can you give me an example then ?



Re: OnPlayerInfoChange not working ? - yezizhu - 25.07.2009

I select 1


Re: OnPlayerInfoChange not working ? - boelie - 25.07.2009

1 =

SendClientmessage 'Thats bad there goes all the nice ideas'


Re: OnPlayerInfoChange not working ? - paytas - 25.07.2009

Use a timer (SetTimer or SetTimerEx) or OnPlayerUpdate(playerid), but be careful with this callback, it is called very often, every time the playerid's client send data to the server.


Re: OnPlayerInfoChange not working ? - boelie - 26.07.2009

I figured it out
This works..hope it ts not gonna be buggy when more players join

Код:
new Float:faPlayerHealth[MAX_PLAYERS];

public OnPlayerUpdate(playerid) //
{
	new Float:fHealth;

	GetPlayerHealth(playerid, fHealth);

	if(fHealth != faPlayerHealth[playerid])
	{
 	//SendClientMessage(playerid, 0xFF000096, "thingy1!");

	  // Player health has changed since last update from player -> server, so obviously thats the thing updated.
	  // Lets do further checks see if he've lost or gain health, anti health cheat? ;-)

	if(fHealth > faPlayerHealth[playerid])
 	{
  SendClientMessage(playerid, 0xFFFF0096, "You gained health!");
			/* He've gained health! Cheating? Write your own scripts here to figure how a player
			gained health! */
  	}
  else
  {
  new Float:health;
  
	if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
 	
  GetPlayerHealth(playerid,health);
  if (health < 70.0)
  {
  ApplyAnimation(playerid, "WUZI", "CS_Dead_Guy", 4.0, 0, 0, 0, 0, 0); // Dead Crawling
  SendClientMessage(playerid, 0xFF000096, "you better call an ambulance!"); /* He've lost health! */
  	//ApplyAnimation(playerid, "SWEET", "Sweet_injuredloop", 4.0, 0, 0, 0, 0, 0); // Injured
  }

 
	}

	faPlayerHealth[playerid] = fHealth;
	}


	return 1;
	}