PDA

View Full Version : Detect the part of vehicle

MisterMania67
21/10/2013, 03:55 PM
Hi everyone !

I would like know how detect the parts of a vehicle.
I have find a function for detect the behind of a vehicle, but i dont know how to detect the front and the petrol cab.

Function for detect the behind:

stock GetPosBehindVehicle(vehicleid, &Float:x, &Float:y, &Float:z, Float:offset=0.5)
{
new Float:vehicleSize[3], Float:vehiclePos[3];
GetVehiclePos(vehicleid, vehiclePos[0], vehiclePos[1], vehiclePos[2]);
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, vehicleSize[0], vehicleSize[1], vehicleSize[2]);
GetXYBehindVehicle(vehicleid, vehiclePos[0], vehiclePos[1], (vehicleSize[1]/2)+offset);
x = vehiclePos[0];
y = vehiclePos[1];
z = vehiclePos[2];
return 1;
}

GetXYBehindVehicle(vehicleid, &Float:q, &Float:w, Float:distance)
{
new Float:a;
GetVehiclePos(vehicleid, q, w, a);
GetVehicleZAngle(vehicleid, a);
q += (distance * -floatsin(-a, degrees));
w += (distance * -floatcos(-a, degrees));
}

Thanks you in advance everyone !

[WA]iRonan
21/10/2013, 04:43 PM
I guess you want to make synced shooting for vehicles?

MisterMania67
21/10/2013, 04:49 PM
No, I would like detect the part of a vehicle for create a command, example: "/open bonnet".

Wizzy951
21/10/2013, 04:53 PM
This may help you (http://wiki.sa-mp.com/wiki/SetVehicleParamsEx).

And your command will look like:

CMD:bonnet(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, true, boot, objective);
return 1;
}

MisterMania67
21/10/2013, 05:00 PM
Yes I know but my gamemode is a roleplay. I would like detect the positions for as player can use the command only if he is before the bonnet.

Wizzy951
21/10/2013, 05:09 PM
Okay, then check this (http://forum.sa-mp.com/showpost.php?p=1957918&postcount=7).

MisterMania67
21/10/2013, 05:17 PM
Thanks, but look my topic ^^
I use already this function, but i don't know how change this function for detect the bonnet of a vehicle.

Wizzy951
21/10/2013, 05:29 PM
Just use the search button .. There (http://forum.sa-mp.com/showthread.php?t=453546&page=2)

And you edited your main thread, didn't you ?

MisterMania67
21/10/2013, 05:32 PM
Thanks, I go to test the function and no, i don't edit the main thread.

EDIT:
Its not working. The function not detect the positions of the bonnet.

MisterMania67
22/10/2013, 10:34 AM
Up ? :)