wheel Trigometry -
Pillhead2007 - 01.08.2014
hey guys
im trying to make a script that basically if your tires are defliated you get a tire out the boot and it will seta player maker to which detected tire burst
but the trigometry is wrong cause it doesn't detect the angle of the vehicle here is my code
PHP код:
public OnPlayerUpdate(playerid)
{
//new string[128];
new Float:PPos[3];
new Float:Offset[6];
new Float:LVPos[6], Float:LVA[1];
new panels,doors,lights,tires;
new vehicleid = LastVehicle[playerid];
GetPlayerPos(playerid, PPos[0], PPos[1], PPos[2]);
GetVehiclePos(LastVehicle[playerid], LVPos[0], LVPos[1], LVPos[2]);
GetVehicleZAngle(vehicleid, LVA[0]);
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
GetVehicleModelInfo(420, VEHICLE_MODEL_INFO_WHEELSFRONT, Offset[0], Offset[1], Offset[2]);
//format(string, sizeof(string), "X:%0.f, Y:%0.f, Z:%0.f, A:%0.f", LVPos[0], LVPos[1], LVPos[2], LVA[0]);
//SendClientMessage(playerid, -1, string);
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && tires == 15)
{
if(IsPlayerInRangeOfPoint(playerid, 5, LVPos[0], LVPos[1], LVPos[2]))
{
if(LVA[0] >= Offset[0]-2.4)
{
//if(LVPos[0] >= Offset[0]-2.4 && LVPos[0] <= Offset[0] && LVPos[1] >= Offset[1]-0.4 && LVPos[1]<= Offset[1]+0.4 && LVPos[2] >= Offset[2]-0.4 && LVPos[2] <= Offset[2]+0.4)
//{
SetPlayerCheckpoint(playerid, LVPos[0] += Offset[0]-2.4, LVPos[1] += Offset[1]-0.4, LVPos[2] += Offset[2]-0.4, 1.0);
}
}
}
return 1;
}
Re: wheel Trigometry -
Threshold - 02.08.2014
EDIT: This was meant to be a full post... but somehow I lost it when I submitted it??
I will re-do it, give me a second.
Re: wheel Trigometry -
Threshold - 02.08.2014
This is a command that I made, it shows you an example of how you might find the coordinates you need to get an offset of the tires. This of course uses the function 'GetVehicleRelativePos' which is credited to Mauzen. First you need this stock:
pawn Код:
stock GetVehicleRelativePos(vehicleid, &Float:x, &Float:y, &Float:z, Float:xoff= 0.0, Float:yoff= 0.0, Float:zoff= 0.0)
{
new Float:rot;
GetVehicleZAngle(vehicleid, rot);
rot = 360 - rot;
GetVehiclePos(vehicleid, x, y, z);
x = floatsin(rot, degrees) * yoff + floatcos(rot, degrees) * xoff + x;
y = floatcos(rot, degrees) * yoff - floatsin(rot, degrees) * xoff + y;
z = zoff + z;
}
Then you would use the following:
pawn Код:
new Float:x, Float:y, Float:z, Float:x2, Float:y2, Float:z2;
//For the front left tyre:
GetVehicleModelInfo(GetVehicleModel(veh), VEHICLE_MODEL_INFO_WHEELSFRONT, x, y, z);
GetVehicleRelativePos(veh, x2, y2, z2, -x - 0.5, y, z);
SetPlayerCheckpoint(playerid, x2, y2, z2, 0.5);
//For the front right tyre...
GetVehicleModelInfo(GetVehicleModel(veh), VEHICLE_MODEL_INFO_WHEELSFRONT, x, y, z);
GetVehicleRelativePos(veh, x2, y2, z2, x + 0.5, y, z);
SetPlayerCheckpoint(playerid, x2, y2, z2, 0.5);
//For the Back left tyre...
GetVehicleModelInfo(GetVehicleModel(veh), VEHICLE_MODEL_INFO_WHEELSREAR, x, y, z);
GetVehicleRelativePos(veh, x2, y2, z2, -x - 0.5, y, z);
SetPlayerCheckpoint(playerid, x2, y2, z2, 0.5);
//For the Back right tyre...
GetVehicleModelInfo(GetVehicleModel(veh), VEHICLE_MODEL_INFO_WHEELSREAR, x, y, z);
GetVehicleRelativePos(veh, x2, y2, z2, x + 0.5, y, z);
SetPlayerCheckpoint(playerid, x2, y2, z2, 0.5);
Where 'veh' is the ID of the vehicle you want to set the checkpoint on.
EDIT:
Example of what this would look like, with the '0.5' offset.
Re: wheel Trigometry -
Pillhead2007 - 02.08.2014
thanks mate I found this function last night been playing around with it thanks soo much anyways