Xwad Posted March 26, 2016 Posted March 26, 2016 Hi i tryed to attach an object to the rhino vehicle but when the rhinos turret is rotating then the object is not moving. Is it possible to attach it to the rhinos turret? Thanks!
Captain Cody Posted March 27, 2016 Posted March 27, 2016 I was wondering the same thing Only way I can think of atm is to get the rotation of the turret and make it constantly correct the objects location.
Xwad Posted March 27, 2016 Author Posted March 27, 2016 I made the script but its not working correctly:/ I set the rotation of the object but i also need to set the position. How can i do that? pls help function object() local veh = getPedOccupiedVehicle ( localPlayer ) local x,y,z = getElementPosition(veh) local id = getElementModel ( veh ) if id == 432 then object = createObject ( 356, x,y,z) attachElements ( object, veh, 0, 0, 0, 0, 7, 96 ) addEventHandler("onClientRender", getRootElement(), rotate_object) end end addEventHandler("onClientVehicleEnter", getRootElement(), object) function rotate_object() local veh = getPedOccupiedVehicle ( localPlayer ) local tx,ty = getVehicleTurretPosition ( veh ) ty = math.deg ( -ty ) tx = math.deg ( tx ) setElementAttachedOffsets ( object, 0.56, 1.15, 1.3, 0, ty+7, tx+96) end
Xwad Posted March 27, 2016 Author Posted March 27, 2016 now its wokring! i made it on a funny way:D I created another object to the middle and attached the other object to it.
Xwad Posted March 27, 2016 Author Posted March 27, 2016 one more question: why is this code not working? the projectile is not shooting function shootProjectile() local veh = getPedOccupiedVehicle(localPlayer) if(veh) and getVehicleModel(veh) == 601 then local tx, ty = getVehicleTurretPosition ( veh) createProjectile(veh, 19, tx,ty,2) end end
Einheit-101 Posted March 27, 2016 Posted March 27, 2016 Attaching an object to the center and then attach another object to rotate it correctly is honestly a genius way to get around the offset calculations lol I do the same thing for a different usage GetVehicleModel is deprecated, use getElementModel lol
Xwad Posted March 27, 2016 Author Posted March 27, 2016 I already did that. Now i have a new problem. Since 1.5.2 released your vreload script causes always game crashes so i decided to make a new script like yours. I created a script that makes possible to shoot projectiles with the swat tank. My problem is that the projectile is not shooting to the direction where the turret is looking at. I hope you can help me. Thanks function shootProjectile() local veh =getPedOccupiedVehicle(localPlayer) if(veh) and getVehicleModel(veh) == 601then local tx, ty = getVehicleTurretPosition (veh) createProjectile(veh, 19, tx,ty,2) endend
Einheit-101 Posted March 27, 2016 Posted March 27, 2016 just download newest vreload or manually remove setElementModel(projectile) out of the resource and it will not crash anymore
Xwad Posted March 28, 2016 Author Posted March 28, 2016 Yeah but i have more problems with you resource: the crosshair is Too much on the top. I want to make a script where the crosshair is lower if you know what i mean
Captain Cody Posted March 28, 2016 Posted March 28, 2016 -- Change the cords for the crosshair issue solved..
Xwad Posted March 28, 2016 Author Posted March 28, 2016 - Change the cords for the crosshair issue solved.. Download the resource and you will see that its not so easy as you think, Its more complicated. If i change i crosshairs position that will not change the shooting direction.. now my only question is: I want to set the projectiles direction to the turrets direction. Whats the problem in my script? function shootProjectile() local veh =getPedOccupiedVehicle(localPlayer) if(veh) and getVehicleModel(veh) == 601then local tx, ty = getVehicleTurretPosition (veh) createProjectile(veh, 19, tx,ty,2) endend
1LoL1 Posted March 28, 2016 Posted March 28, 2016 - Change the cords for the crosshair issue solved.. Download the resource and you will see that its not so easy as you think, Its more complicated. If i change i crosshairs position that will not change the shooting direction.. now my only question is: I want to set the projectiles direction to the turrets direction. Whats the problem in my script? function shootProjectile() local veh =getPedOccupiedVehicle(localPlayer) if(veh) and getVehicleModel(veh) == 601then local tx, ty = getVehicleTurretPosition (veh) createProjectile(veh, 19, tx,ty,2) endend function shootProjectile() local veh = getPedOccupiedVehicle(localPlayer) if(veh) and getVehicleModel(veh) == 601 then local tx, ty = getVehicleTurretPosition (veh) createProjectile(veh, 19, tx,ty,2) end end
Einheit-101 Posted March 28, 2016 Posted March 28, 2016 the crosshair is not precise? idk but you could try to reduce the z position of its dxDrawImage
Xwad Posted April 12, 2016 Author Posted April 12, 2016 one more question: Why is the rx rotating in the wrong direction? it should be rotate up when the tanks turret barrel is rotating up. Its rotating to the opposite direction:/ the rz is working correctly! heres the code. Thanks in advance! client.lua function rotate_object(veh) local veh = getPedOccupiedVehicle ( localPlayer ) local _,_,rz = getVehicleComponentRotation(veh, "misc_a") local rx,_,_ = getVehicleComponentRotation(veh, "misc_b") triggerServerEvent("rotate_object", localPlayer, veh,rx,rz, localPlayer) end server.lua function rotate_object(veh,rx,rz) local object = getElementData ( veh, "object" ) local object2 = getElementData ( veh, "object2" ) local weapon = getElementData ( veh, "weapon" ) setElementAttachedOffsets ( object, 0, 0, 0, 0, 7, rz+95) setElementAttachedOffsets ( object2, 0.9, -0.6, 3, 0, rx+0, 0) setElementAttachedOffsets ( weapon, 0.9, -0.6, 3, rx+7, 0, 0) end addEvent("rotate_object", true) addEventHandler("rotate_object", root, rotate_object)
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