XxCozzaxX Posted April 7, 2010 Share Posted April 7, 2010 I tried to make my ped accelerate in a vehicle, but i get this error in my console: attempt to call global 'setPedControlState' (a nil value) The Code: ped = createPed( tonumber( id ), x, y, z ); local veh = createVehicle(400, x, y-4, z); warpPedIntoVehicle ( ped, veh ) setPedControlState (ped, "accelerate", true) Link to comment
Jumba' Posted April 7, 2010 Share Posted April 7, 2010 (edited) I tried to make my ped accelerate in a vehicle, but i get this error in my console:attempt to call global 'setPedControlState' (a nil value) The Code: ped = createPed( tonumber( id ), x, y, z ); local veh = createVehicle(400, x, y-4, z); warpPedIntoVehicle ( ped, veh ) setPedControlState (ped, "accelerate", true) You sure the script is client-side? -edit- It's not, since warpPedIntoVehicle worked and that's server-side only. You have to create the peds, warp em into the vehicles then use the event system to transfer them to the clients. There you can use setPedControlState Edited April 7, 2010 by Guest Link to comment
XxCozzaxX Posted April 7, 2010 Author Share Posted April 7, 2010 I tried to make my ped accelerate in a vehicle, but i get this error in my console:attempt to call global 'setPedControlState' (a nil value) The Code: ped = createPed( tonumber( id ), x, y, z ); local veh = createVehicle(400, x, y-4, z); warpPedIntoVehicle ( ped, veh ) setPedControlState (ped, "accelerate", true) You sure the script is client-side? Server-Side... Should it be client side? Link to comment
Gamesnert Posted April 7, 2010 Share Posted April 7, 2010 setPedControlState is client-side only according to the wiki, so it's safe to assume so eh. So yes, it has to be client-side. Link to comment
XxCozzaxX Posted April 7, 2010 Author Share Posted April 7, 2010 setPedControlState is client-side only according to the wiki, so it's safe to assume so eh.So yes, it has to be client-side. Ok, so should this work? function driveveh ( )local x, y, z = getElementPosition( plr );local vehped = createPed( 0, x, y, z );local pedveh = createVehicle(400, x, y-4, z);warpPedIntoVehicle ( vehped, pedveh )setPedControlState (ped, "accelerate", true)endaddCommandHandler("drive", driveveh) Hmm, no it wont... so how do i make the client function work with the server function? Link to comment
Gamesnert Posted April 7, 2010 Share Posted April 7, 2010 warpPedIntoVehicle setPedControlState Check the top-right of both pages. Also hint: Use [code=lua] instead of Link to comment
XxCozzaxX Posted April 7, 2010 Author Share Posted April 7, 2010 Lol, so your trying to tell me its not possible to put a player in a vehicle and make him drive? Bull**** Link to comment
Dark Dragon Posted April 7, 2010 Share Posted April 7, 2010 as suggested by jumba 6 posts above this one you need to trigger a client event after warping a ped into a vehicle server side, then set the control state in the client side triggered function https://wiki.multitheftauto.com/wiki/Event_system 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