[PROBLEM] Making a person die when he enters an area - 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: [PROBLEM] Making a person die when he enters an area (
/showthread.php?tid=123783)
[PROBLEM] Making a person die when he enters an area -
S1nn3r - 27.01.2010
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 ?
Re: [PROBLEM] Making a person die when he enters an area -
Norck - 27.01.2010
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
Re: [PROBLEM] Making a person die when he enters an area -
pierhs - 27.01.2010
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);
}
}
}