SA-MP Forums World position from vehicle offset
 User Name Remember Me? Password
 Members List Search Today's Posts Mark Forums Read

 Thread Tools Display Modes
 22/06/2013, 04:53 PM #1 WillyP High-roller     Join Date: Jul 2010 Location: England Posts: 2,027 Reputation: 63 World position from vehicle offset Yoo, I was wondering on how I would get the position of the offset of a vehicle in world values. For example, I'd use http://wiki.sa-mp.com/wiki/GetVehicleModelInfo to get the position of the fuel cap. However when this is done and I want to get the coordinates, and all it returns is 0 as I only use the GetVehicleModelInfo function in order to retrieve values. I then began a search to see if anyone had the solution, and I came across a post where something about trigonometry was mentioned. Trigonometry will be used to calculate the world position from a vehicle position (and offset) which will return the value of the fuel cap, or any example you wish to use. I have no idea how to do trigonometry in association with coding as that's not the kind of thing I get taught in math class. If someone could create a function for me or explain how to then it would be greatly appreciated __________________ once average now terrible
 22/06/2013, 06:28 PM #2 Stylock Huge Clucker     Join Date: Dec 2010 Posts: 315 Reputation: 155 Re: World position from vehicle offset Not sure, but is this what your looking for: http://forum.sa-mp.com/showthread.ph...76#post2580576
 22/06/2013, 06:52 PM #3 WillyP High-roller     Join Date: Jul 2010 Location: England Posts: 2,027 Reputation: 63 Re: World position from vehicle offset I already had a similar function however I will try yours and compare results __________________ once average now terrible
 22/06/2013, 07:22 PM #4 WillyP High-roller     Join Date: Jul 2010 Location: England Posts: 2,027 Reputation: 63 Re: World position from vehicle offset pawn Code: `CMD:wheelpos(playerid,params[]){    new str[128],str2[128],str3[128];    new Float:x,Float:y,Float:z,Float:a;    new Float:vx,Float:vy,Float:vz;        new Float:rx,Float:ry,Float:rz;        new Float:nx,Float:ny,Float:nz,str4[128];        GetVehiclePos(GetPlayerVehicleID(playerid),x,y,z);    GetVehicleZAngle(GetPlayerVehicleID(playerid),a);    GetVehicleModelInfo(GetPlayerVehicleID(playerid),VEHICLE_MODEL_INFO_WHEELSFRONT,vx,vy,vz);    GetVehiclePosEx(GetPlayerVehicleID(playerid),vx,vy,vz,0.1,0.1,0.1);        nx = vx-x;    ny = vy-y;    nz = vz-z;    GetVehicleRelativePos(GetPlayerVehicleID(playerid),rx,ry,rz,0.1,0.1,0.1);    format(str,128,"x = %f y = %f z = %f",x,y,z);    format(str2,128,"wheelinfo: x = %f y = %f z = %f",vx,vy,vz);    format(str3,128,"relative pos: x = %f y = %f z = %f - unused",rx,ry,rz);    format(str4,128,"difference x = %f y = %f z = %f",nx,ny,nz);    SendClientMessage(playerid,-1,str);    SendClientMessage(playerid,-1,str2);    SendClientMessage(playerid,-1,str3);    SendClientMessage(playerid,-1,str4);    //other stuff    return 1;}` Here's part of what I've been doing, however I just want to return the location of the front wheels however I believe what I have done is slightly wrong.. __________________ once average now terrible
 22/06/2013, 07:33 PM #5 Stylock Huge Clucker     Join Date: Dec 2010 Posts: 315 Reputation: 155 Re: World position from vehicle offset Idk what you're doing, but I noticed one mistake: Code: `GetVehicleModelInfo(GetPlayerVehicleID(playerid),VEHICLE_MODEL_INFO_WHEELSFRONT,vx,vy,vz);` You need to pass the model ID, not the vehicle ID
22/06/2013, 08:14 PM   #6
WillyP
High-roller

Join Date: Jul 2010
Location: England
Posts: 2,027
Reputation: 63
Re: World position from vehicle offset

Quote:
 Originally Posted by Stylock Idk what you're doing, but I noticed one mistake: Code: `GetVehicleModelInfo(GetPlayerVehicleID(playerid),VEHICLE_MODEL_INFO_WHEELSFRONT,vx,vy,vz);` You need to pass the model ID, not the vehicle ID
Ahh, silly mistake. What I'm trying to do is get the offset values, and return it in the world x,y,z. So as a test I could create an object where the values I get from the offset info, then do some extra changing around.

So, vehicle pos+vehicle offset = object and world value. The object will be created at the coordinates from the offset values
__________________
once average now terrible

 22/06/2013, 10:03 PM #7 Stylock Huge Clucker     Join Date: Dec 2010 Posts: 315 Reputation: 155 Re: World position from vehicle offset That's what the function I posted does. You need to pass the petrol cap's offsets to the function and it will calculate the wolrd coordinates.
 23/06/2013, 10:44 AM #8 WillyP High-roller     Join Date: Jul 2010 Location: England Posts: 2,027 Reputation: 63 Re: World position from vehicle offset I need something so that it stores the value until it has been removed. I used objects however obviously when the vehicle moved they didn't stick. Basically getting the offset position and saving it to the vehicle, probably using a timer to keep it updated. P.S: I don't actually want the fuel cap, I lied EDIT: I have it working now, thanks for all your help! __________________ once average now terrible Last edited by WillyP; 23/06/2013 at 11:29 AM.

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post MP2 Scripting Help 3 09/04/2016 10:10 AM _[HuN]_Epsilon_ Help Archive 5 06/08/2011 01:25 AM Donya Help Archive 2 14/05/2011 12:49 AM thomas.. Help Archive 2 03/10/2010 03:40 PM

All times are GMT. The time now is 07:16 PM.

 -- (EN) English -- (RU) Русски SA-MP - Archive - Top