Check if player is near the door
#1

Hello, I've made a command which lets you break a window of a car, but you can only break the driver's window. Is it possible to check if the player is at the driver's door? I need that because it doesn't look too good if you are behind a car, then you do /breakwindow and it breaks the driver's window while you are not even near the driver's door. I've ******d and found that GetVehicleModelInfo function, but I've got no clue what to do with that. Anyways would that be possible to do?
Reply
#2

deleted
Reply
#3

http://forum.sa-mp.com/showpost.php?...18&postcount=7

or try to get PlayerPosition and Is payer on driver seat!
Reply
#4

Closest thing you can get to driver's door is front seat on GetVehicleModelInfo function, so you can write:

new Float, Float:y, Float:z;
GetVehicleModelInfo(yourvehmodel, VEHICLE_MODEL_INFO_FRONTSEAT, x, y, z);

I have never used this function, I'm just trying to get you on the road, try test that function, what it returns...

https://sampwiki.blast.hk/wiki/Vehicle_information_types
Here's types of that function.

After you get that window position, do IsPlayerInRangeOfPoint.
Reply
#5

Well, I don't really know what is sine and cosine, because I haven't learned that yet so I guess I don't know how to do that lol.

EDIT:
Quote:
Originally Posted by lollypap54
Посмотреть сообщение
Closest thing you can get to driver's door is front seat on GetVehicleModelInfo function, so you can write:

new Float, Float:y, Float:z;
GetVehicleModelInfo(yourvehmodel, VEHICLE_MODEL_INFO_FRONTSEAT, x, y, z);

I have never used this function, I'm just trying to get you on the road, try test that function, what it returns...

https://sampwiki.blast.hk/wiki/Vehicle_information_types
Here's types of that function.

After you get that window position, do IsPlayerInRangeOfPoint.
Wait I guess that's exactly what I need... Let me try.
Reply
#6

OK, but if I'd use GetVehicleModelInfo and get the position of the front seat, what would I need to do so I could use IsPlayerInRangeOfPoint with it? Like get the coordinates of the vehicle's front seat seat in the world. You got the idea, like you could set player's position to the coordinates and all that stuff.
Reply
#7

Try it?
Reply
#8

Try what? It's getting the position of the model's front seat, not the vehicle's.
Reply
#9

Yes, you need to translate the relative coordinates to absolute coordinates but you must also take into account the current facing angle of the vehicle.

PHP код:
worldX floatsin(-adegrees) * offset_x;
worldY floatcos(-adegrees) * offset_y;
worldZ offset_z
Where x, y and z are retrieved from GetVehiclePos, a is retrieved from GetVehicleZAngle and offset_x, offset_y and offset_z are the relative coordinates for the drivers seat retrieved from GetVehicleModelInfo. I made some calculations on paper and I think this is correct.
Reply
#10

offset_x would have to be the information retrieved from info types VEHICLE_MODEL_INFO_FRONTSEAT and VEHICLE_MODEL_INFO_SIZE. (Half the vehicle width because you will be calculating from the centre of the vehicle)

Basically
PHP код:
offset_x frontseat_x - (width_x 2); 
Correct me if I'm wrong, but don't you need to account for the other offsets in X and Y calculations?
PHP код:
worldX + (floatsin(-adegrees) * offset_y) + (floatcos(-adegrees) * offset_x);
worldY + (floatcos(-adegrees) * offset_y) - (floatsin(-adegrees) * offset_x);
worldZ offset_z
Or have I completely failed in remembering how maths works? :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)