Michcio Posted January 12, 2011 Share Posted January 12, 2011 Hello! I wrote a script to take control of ped, but it doesnt work. Please help me with this. Server: function bot () me = getPlayerFromNick("Michcio") car = createVehicle(411,0,5,3) drv = createPed(105,0,0,3) setElementID(drv,"drv") warpPedIntoVehicle(drv,car) end addEventHandler("onResourceStart",getRootElement(),bot) Client: drv = getElementbyID("drv") drvctrls = {accelerate="num_8,brake_reverse="num_2",vehicle_left="num_4",vehicle_right="num_6",handbrake="num_5"} function ctrldrv () for ctrl,key in pairs(drvctrls) do setPedControlState(drv,ctrl,getKeyState(key)) end end addEventHandler("onClientPreRender",getRootElement(),ctrldrv) Link to comment
Michcio Posted January 12, 2011 Author Share Posted January 12, 2011 drv = getElementbyID("drv") drvctrls = {accelerate="num_8",brake_reverse="num_2",vehicle_left="num_4",vehicle_right="num_6",handbrake="num_5"} function ctrldrv () for ctrl,key in pairs(drvctrls) do setPedControlState(drv,ctrl,getKeyState(key)) end end addEventHandler("onClientPreRender",getRootElement(),ctrldrv) It was a mistake in 2 line but it doesnt work. eAi when i press num_2 nothing happens. Ped and vehicle creating is good. Link to comment
12p Posted January 12, 2011 Share Posted January 12, 2011 drv = getElementbyID("drv") drvctrls = {{"accelerate", "num_8"}, {"brake_reverse", "num_2"}, {"vehicle_left", "num_4"}, {"vehicle_right", "num_6"}, {"handbrake", "num_5"}} function ctrldrv () for index,key in pairs(drvctrls) do setPedControlState(drv,key[1],getKeyState(key[2])) end end addEventHandler("onClientPreRender",getRootElement(),ctrldrv) Link to comment
proracer Posted January 12, 2011 Share Posted January 12, 2011 Try to debug script in the server with '/debugscript 3 ' and see if there are any errors. Link to comment
Michcio Posted January 12, 2011 Author Share Posted January 12, 2011 O.K. Thanks to all! It's work now. 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