[PROBLEM] Making a person die when he enters an area
#1

I want a person to die when he enters a certain area
I know about timers and forwarding, and i'm not getting any compiling errors, the script just doesent work, I don't die when I enter the area
help plz ?

this is what I ahve

forward:
Код:
forward isPlayerInArea();
Timer:
Код:
SetTimer("isPlayerInArea", 1000, true);
function:
Код:
public isPlayerInArea()
  {
    new Float:X, Float:Y, Float:Z;
    for(new i=0; i < MAX_PLAYERS; i++)
    {
      GetPlayerPos(i, X, Y, Z);
      if (X <= 220.79951477051 && X >= 78.797210693359 && Y <= -2541.3955078125 && Y >= 23.323795318604){
        SetPlayerHealth(i, -999999.9);
      }
    }
  }
Anyone knows whats the problem or knows how to solve this ?
Reply
#2

Maybe
Код:
public isPlayerInArea()
  {
    new Float:X, Float:Y, Float:Z;
    for(new i=0; i < MAX_PLAYERS; i++)
    {
      GetPlayerPos(i, X, Y, Z);
      if (X <= 220.79951477051 && X >= 78.797210693359 && Y >= -2541.3955078125 && Y <= 23.323795318604){
        SetPlayerHealth(i, -999999.9);
      }
    }
  }
Cause
Код:
Y <= -2541.3955078125 && Y >= 23.323795318604
False anyway
Reply
#3

Add this function first:
Код:
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		tempposx = (oldposx -x);
		tempposy = (oldposy -y);
		tempposz = (oldposz -z);
		//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}
Then change a little your code:
Код:
public isPlayerInArea()
  {
    new Float:X, Float:Y, Float:Z;
    for(new i=0; i < MAX_PLAYERS; i++)
    {
      if (PlayerToPoint(25.0(for example its the cover distance), i, x(the x coord), y(the x coord), z(the z coord)){
        SetPlayerHealth(i, 0);
      }
    }
  }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)