Deltanic Posted February 25, 2010 Share Posted February 25, 2010 Hi, I'm searching a script to get the X, Y and Z in front of a vehicle. What I made until now, is only getting the X and Y in front of a vehicle, but it doesn't work. The object doesn't spawn. if getElementData ( source, "spawnedRamp" ) then destroyElement ( getElementData ( source, "spawnedRamp" ) ) setElementData ( source, "spawnedRamp", nil ) end local rX, rY, rZ = getVehicleRotation ( getPedOccupiedVehicle ( source ) ) outputChatBox ( "DEBUG: Vehicle=" .. getElementModel ( getPedOccupiedVehicle ( source ) ) ) local pX, pY, pZ = getElementPosition ( etPedOccupiedVehicle ( source ) ) pX = pX + ( 10 * math.sin ( -rZ ) ) py = py + ( 10 * math.cos ( -rZ ) ) local rampObject = createObject ( 1655, pX, pY, pZ, rX, rY, rZ ) -- This object doesn't spawn. Or atleast, I can't see it. setElementData ( source, "spawnedRamp", rampObject ) (Based out of this script of SA:MP's Pawn Language to get the X and Y points. I'm really not good in maths ) new Float:a; GetPlayerPos(playerid, x, y, a); GetPlayerFacingAngle(playerid, a); x += (distance * floatsin(-a, degrees)); y += (distance * floatcos(-a, degrees)); But the problem is: I'm using my script in a Vehicle, and that object doesnt spawn. Problaby by a fault in the script. And I want to spawn that object in the air too, so I need the Z in front of the vehicle too. Link to comment
Buffalo Posted February 25, 2010 Share Posted February 25, 2010 Based on your vehicle speed too: local theVehicle = getPedOccupiedVehicle ( source ) local speedx,speedy = getElementVelocity(theVehicle) local px,py,pz = getElementPosition(theVehicle) local nx,ny = speedx * 50 + px, speedy * 50 + py if(math.abs(px-nx) > 1 or math.abs(py-ny) > 1) then local a,b,r = getVehicleRotation ( theVehicle ) local newramp = createObject ( 1655, nx, ny, pz, 0, b, r ) end ..and you should use table for these, to avoid data syncing, if you don't need it to be synced with all clients: something like ramp[source][newramp] = newramp Link to comment
Deltanic Posted February 25, 2010 Author Share Posted February 25, 2010 Works, tnx And is it possible too to check the X, Y and Z where the player is looking at in (eg.) 3 units away? Link to comment
Dark Dragon Posted February 26, 2010 Share Posted February 26, 2010 if you mean the player ped: getPedRotation if you mean the camera: getCameraMatrix then the rest is up to the trigonometric functions. but client-side you could also use getElementMatrix and one more thing: outputChatBox ( "DEBUG: Vehicle=" .. getElementModel ( getPedOccupiedVehicle ( source ) ) ) come on, why don't you use outputDebugString instead? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now