SA-MP Forums Archive
Detecting fall - 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)
+--- Thread: Detecting fall (/showthread.php?tid=409173)



Detecting fall - Problem solved for now - jibileu - 20.01.2013

As title says, I need help detecting when a player falls for example from a building to a street.

I've tried to detect changes in player Z, I've tried to detect ground level by using MapAndreas and I've tried to use IsPlayerInArea.

I've failed using this 3 techniques, can somebody enlighten me, please?

P.S - I deleted all the code I've used, don't ask for it.

Thank you.

Post #6 clarifies the solution found to the problem.


AW: Detecting fall - IPrototypeI - 20.01.2013

Quote:
Originally Posted by jibileu
Посмотреть сообщение
As title says, I need help detecting when a player falls for example from a building to a street.

I've tried to detect changes in player Z, I've tried to detect ground level by using MapAndreas and I've tried to use IsPlayerInArea.

I've failed using this 3 techniques, can somebody enlighten me, please?

P.S - I deleted all the code I've used, don't ask for it.

Thank you.
Pls can you describe more what you want to do and from which hight he should fall ?
Because from a special high he change his animation


Re: AW: Detecting fall - jibileu - 20.01.2013

Quote:
Originally Posted by IPrototypeI
Посмотреть сообщение
Pls can you describe more what you want to do and from which hight he should fall ?
Because from a special high he change his animation
I forgot to say that the player should be inside a vehicle when he falls.

Imagine a derby on a building and a player falls from it inside his car. How can I detect it?


Re: Detecting fall - Vince - 20.01.2013

I was going to suggest checking the falling animation, but since this concerns vehicles that won't work.
You could try getting the vehicles velocity and checking if the vehicle has a negative Z velocity.


Re: Detecting fall - B-Matt - 20.01.2013

pawn Код:
OnPlayerUpdate(playerid)
{
    new Float:Velocity[3];
    GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
    if ( Velocity[2] < building height)
    {
         //your code
    }
    return 1;
}
Try this code..


Re: Detecting fall - jibileu - 20.01.2013

Problem solved for now.

It was easy to do, but without your help I would be blind and stuck there.

Solution

Auxiliary script
Main script

Код:
timer calls callback

callback()
{
	loop through all players
	{
		gets playerid Z value
		checks if Z < highest ground level for that building
		{
			script does something to playerid
		}
	}
	returns
}
This is working fine for my problem at my test server, but I don't know if it is the way to similar problems. (January 20, 2013 @ 20:00)

Thank you Vince and B-Matt.


Re: Detecting fall - B-Matt - 20.01.2013

OPU is called everytime player (client) make update to the server (like moving etc). So you don't need loops.


Re: Detecting fall - jibileu - 20.01.2013

Quote:
Originally Posted by B-Matt
Посмотреть сообщение
OPU is called everytime player (client) make update to the server (like moving etc). So you don't need loops.
I've used your idea, but I've created a custom callback because I'll only use it sometimes.

My script isn't a sumo or a derby script which in my opinion needs constant updating/checking.