Determine if a vehicle passes in front of a player... -
Scenario - 15.01.2013
As the title says;
Is it possible to determine if a vehicle passes the front of a player, and if so, how?
Re: Determine if a vehicle passes in front of a player... -
Glad2BeHere - 15.01.2013
what do u mean if a player is near a vehicle?
or
A vehicles drives into a player?
or
Vehicle is moving near a player?
Re: Determine if a vehicle passes in front of a player... -
Scenario - 15.01.2013
Quote:
if a vehicle passes the front of a player
|
I'm not sure how else to put that. Maybe...
If a vehicle drives in front of a player, can I determine if they drove IN FRONT of the player?
Re: Determine if a vehicle passes in front of a player... -
Glad2BeHere - 15.01.2013
Is called Physics ...... U need to get there angles..... and determine it from equations, basic physics is going to be needed to determine this
https://sampwiki.blast.hk/wiki/GetPlayerFacingAngle
https://sampwiki.blast.hk/wiki/GetVehicleZAngle
https://sampwiki.blast.hk/wiki/GetVehicleRotationQuat
http://en.wikipedia.org/wiki/Quatern...atial_rotation
These are very key and after alot of testing and tweeking i think you will be able to create a code where u will be able to find the vehicle position to the player
I thought it might of been something as easy
getting the player angle and vehicle and if the angle is near 180( the difference ) then you that the angle of the vehicle is opposite to the player......
But i am not to sure ... i do a little digging around for u see if i see something maybe even try to code and inbox u it.... But for now that my solution for solving your problem
Re: Determine if a vehicle passes in front of a player... -
Magic_Time - 15.01.2013
PHP код:
stock GetDistanceToCar(playerid, veh, Float: posX = 0.0, Float: posY = 0.0, Float: posZ = 0.0) {
new
Float: Floats[2][3];
if(posX == 0.0 && posY == 0.0 && posZ == 0.0) {
if(!IsPlayerInAnyVehicle(playerid)) GetPlayerPos(playerid, Floats[0][0], Floats[0][1], Floats[0][2]);
else GetVehiclePos(GetPlayerVehicleID(playerid), Floats[0][0], Floats[0][1], Floats[0][2]);
}
else {
Floats[0][0] = posX;
Floats[0][1] = posY;
Floats[0][2] = posZ;
}
GetVehiclePos(veh, Floats[1][0], Floats[1][1], Floats[1][2]);
return floatround(floatsqroot((Floats[1][0] - Floats[0][0]) * (Floats[1][0] - Floats[0][0]) + (Floats[1][1] - Floats[0][1]) * (Floats[1][1] - Floats[0][1]) + (Floats[1][2] - Floats[0][2]) * (Floats[1][2] - Floats[0][2])));
}
Re: Determine if a vehicle passes in front of a player... -
Scenario - 15.01.2013
Ah okay. I was really looking for an easier solution because I really don't even want to attempt to get into any of that kind of crap right now. Actually, I kind of figured someone had already made a piece of code that did this. Who knows.
Either way, thank you!
EDIT: @ Magic_Time: That isn't really going to determine if a vehicle passes in front of a player, though. Is it?
Re: Determine if a vehicle passes in front of a player... -
Magic_Time - 15.01.2013
Maybe you can modify this:
PHP код:
forward GetXYInFrontOfPlayer2(playerid, &Float, &Float:y, Float:distance, Float:angle);
public GetXYInFrontOfPlayer2(playerid, &Float, &Float:y, Float:distance, Float:angle) {
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
a += angle;
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
Re: Determine if a vehicle passes in front of a player... -
Scenario - 15.01.2013
Ah, very well.
Thank you.