Jungs Posted January 2, 2014 Share Posted January 2, 2014 Please help to correct my script. The idea of the script is to move the object attached to the vehicle by bindkey. Currently object is attached, but it disappears by pressing the button. Sorry for my english, hope you understand and help me. Thank you. on = 0 function checkModel( theVehicle ) Car = getElementModel ( theVehicle ) end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), checkModel ) function onEnterVehicle ( theVehicle, seat, jacked ) if ( getElementModel ( theVehicle ) == 598 ) then bindKey ( source, "F10", "down", createObj ) end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onEnterVehicle ) function createObj ( player ) if Car == 598 then if on == 0 then on = 1 veh = getPedOccupiedVehicle (player) x, y, z = getElementPosition (veh) object1 = createObject ( 1983, x, y, z ) attachElements ( object1, veh, 0, 0, 1.5) else on=0 destroyElement(object1) end end end left1 = function (player) moveObject (object1, 1000, 1, 0, 0) end function onBind () bindKey ( source, "a", "down", left1 ) end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onBind ) function offBind () unbindKey ( source, "a", "down", left1 ) end addEventHandler ( "onPlayerVehicleExit", getRootElement(), offBind ) I do not understand what I did wrong Link to comment
Noki Posted January 3, 2014 Share Posted January 3, 2014 We won't just fix it like that. You need to specify your problem more specifically. We will help you, put you in the right direction, and possibly even fix the whole thing, but usually only if you're new to scripting. Link to comment
Drakath Posted January 3, 2014 Share Posted January 3, 2014 This should do the trick, though I'm not sure why you attached the object so I removed that line. on = 0 function checkModel( theVehicle ) Car = getElementModel ( theVehicle ) end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), checkModel ) function onEnterVehicle ( theVehicle, seat, jacked ) if ( getElementModel ( theVehicle ) == 598 ) then bindKey ( source, "F10", "down", createObj ) end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onEnterVehicle ) function createObj ( player ) if Car == 598 then if on == 0 then on = 1 veh = getPedOccupiedVehicle (player) x, y, z = getElementPosition (veh) object1 = createObject ( 1983, x, y, z ) else on=0 destroyElement(object1) end end end left1 = function (player) veh = getPedOccupiedVehicle (player) x, y, z = getElementPosition (veh) moveObject (object1, 1000, x, y, z) end function onBind () bindKey ( source, "a", "down", left1 ) end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onBind ) function offBind () unbindKey ( source, "a", "down", left1 ) end addEventHandler ( "onPlayerVehicleExit", getRootElement(), offBind ) Link to comment
Jungs Posted January 3, 2014 Author Share Posted January 3, 2014 Thank you for your response. I'm really new to scripting, this is my second script. The problem is that I can not find a way to move the object relative to the vehicle, only relatively the world. Hope you put me in the right direction. Thank you. Link to comment
Jungs Posted January 8, 2014 Author Share Posted January 8, 2014 Maybe anyone have another idea how to make working steering whell? Please help Link to comment
Noki Posted January 10, 2014 Share Posted January 10, 2014 The steering wheel already works in cars. Try pressing V a few times when in a vehicle so you can get first person view. Link to comment
Jungs Posted January 10, 2014 Author Share Posted January 10, 2014 Ok, i'll try to explain. I have a freeroam server with few replaced vehicles, and i have first person view for this vehicles. I want to make steering wheel is turned by pressing "A" and "D" buttons. To implement it I can make in zmodeller a car without a steering wheel. And make steering wheel a separate object and add it into the game by this code function importTextures() txd = engineLoadTXD ( "steering_wheel.txd" ) engineImportTXD ( txd, 9822 ) dff = engineLoadDFF ( "steering_wheel.dff", 0 ) engineReplaceModel ( dff, 9822 ) end The problem is that I can not find a way how to implement the movement of object attached to the car. Hope you understand me, thank you. Link to comment
.:HyPeX:. Posted January 10, 2014 Share Posted January 10, 2014 What ur doind is simpy really hard, and in some vehicles you cant, just on the whones where you can see it. Making it move.. im not sure if it is working alone already, but you cant move it. 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