SA-MP Forums Archive
Need help knowing wich forward is... - 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: Need help knowing wich forward is... (/showthread.php?tid=72967)



Need help knowing wich forward is... - Shellegg - 11.04.2009

Anyoen can tell me where to make a public that read "if(playerhealth <= 20)"
To freeze him on the floor waiting an ambulance?

some1 told me that is OnPlayerUpdate.

Is he right? Can you tell me with forward/public is? And then the include.

Thank you

Shellegg


Re: Need help knowing wich forward is... - Backwardsman97 - 11.04.2009

You could use OnPlayerUpdate.

pawn Code:
public OnPlayerUpdate(playerid)
{
  new Float:Health;
  GetPlayerHealth(playerid,Health);
  if(Health <= 20)
  {
    TogglePlayerControllable(playerid,0);
    //And the rest or w/e
  }
  return 1;
}



Re: Need help knowing wich forward is... - 13th - 11.04.2009

I would make new function and call it.. lets say every 1 to 2 seconds. I don't know how often is OnPlayerUpdate is called, haven't tested.. but probably a lot. So, timer might be better way to go.


Re: Need help knowing wich forward is... - Shellegg - 11.04.2009

Quote:
Originally Posted by 13th
I would make new function and call it.. lets say every 1 to 2 seconds. I don't know how often is OnPlayerUpdate is called, haven't tested.. but probably a lot. So, timer might be better way to go.
an example?


Re: Need help knowing wich forward is... - 13th - 11.04.2009

Code:
forward CheckHealth();

public OnGameModeInit()
{
	SetTimer("CheckHealth",1500,true);
}

public CheckHealth()
{
	new Float: PlayerHealth;
	
	for( new playerid; playerid <= GetMaxPlayers(); playerid++ )
	{
	  if( IsPlayerConnected(playerid) )
	  {
			GetPlayerHealth(playerid, PlayerHealth);
			if( PlayerHealth < 20 )
			{
			  TogglePlayerControllable(playerid, false);
			}
	  }
	}
}