Detecting fall
#1

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

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

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?
Reply
#4

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

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

Problem solved for now.

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

Solution

Auxiliary script
  • MapAndreas returned highest ground level
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.
Reply
#7

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)