SA-MP Forums Calculating vehicle height
 Members List Search Today's Posts Mark Forums Read

 16/06/2013, 02:14 AM #1 WillyP High-roller     Join Date: Jul 2010 Location: England Posts: 2,027 Reputation: 63 Calculating vehicle height Hey, I've been having some problems with getting a vehicle height, storing it and creating an object with the Z value being the height of the vehicle. So far I have used GetVehicleModelInfo, and GetVehicleRelativePos. They both failed to work for me, as I must have gone wrong somewhere. Here's the GetVehicleRelativePos function pawn Code: `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;    // Making the vehicle rotation compatible with pawns sin/cos    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;    /*       where xoff/yoff/zoff are the offsets relative to the vehicle       x/y/z then are the coordinates of the point with the given offset to the vehicle       xoff = 1.0 would e.g. point to the right side of the vehicle, -1.0 to the left, etc.    */    return 1;}` And the wiki page for GetVehicleModelInfo: http://wiki.sa-mp.com/wiki/GetVehicleModelInfo And the testing command: pawn Code: `CMD:test(playerid,params[]){    new veh,obj,    Float:x,    Float:y,    Float:z,    Float:ox,    Float:oy,    Float:oz,    string[64];    veh = GetNearestVehicle(playerid,15);    GetVehiclePos(veh,x,y,z);    //GetVehicleRelativePos(veh,ox,oy,oz,0,0,1.0);    GetVehicleModelInfo(GetVehicleModel(veh),VEHICLE_MODEL_INFO_SIZE,ox,oy,oz);    obj = CreateObject(18646,x,y,z,-1,0,0,0);//or ox,oy,oz    AttachObjectToVehicle(obj,veh,x,y,z,0,0,0);//or ox,oy,oz    format(string,sizeof(string),"vehicle is %.1fm wide, %.1fm long and %.1fm high",ox,oy,oz);    SendClientMessage(playerid,-1,string);    return 1;}` What I want this to do is store the value from GetVehicleModelInfo or GetVehicleRelativePos and create the object exactly on the top of the roof, without it being too high or too low, I'm pretty tired so I'm not going to keep trying with this and hopefully fresh eyes will point out my mistakes. __________________ once average now terrible
 24/06/2013, 01:39 AM #2 Kar Banned   Join Date: May 2010 Location: Black Asylum Posts: 2,938 Reputation: 538 Re: Calculating vehicle height GetVehicleModelInfo then z /= 2 thats the height of the vehicle

 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 Misiur Scripting Help 1 04/03/2013 05:50 PM Mace Scripting Help 0 28/09/2012 10:02 PM jueix Scripting Help 3 28/05/2012 08:44 AM acade Help Archive 3 21/12/2010 08:48 PM [SF]RobMob Help Archive 4 06/05/2010 01:48 AM

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

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