Jump to content

Problem with taking control of Ped


Michcio

Recommended Posts

Hello! I wrote a script to take control of ped, but it doesnt work. Please help me with this. :fadein:

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
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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...