OnPlayerInfoChange not working ?
#1

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 ?

Reply
#2

yes
Reply
#3

1.yes, its not working?


2.yes, i can help you?


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

I select 1
Reply
#5

1 =

SendClientmessage 'Thats bad there goes all the nice ideas'
Reply
#6

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.
Reply
#7

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;
	}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)