Jump to content

setPedAnalogControlState


Jonni

Recommended Posts

hi,

when I try the command /AI it gives this error in server console: attempt to call global 'setPedAnalogControlState' (a nil value)

It spawns the ped,vehicle and puts ped into the vehicle but doesnt start driving forward for some reason. How can I fix this?

function AIo ( playerSource ) 
local x, y, z = getElementPosition ( playerSource ) 
local ped = createPed(194,x,y,z) 
  
    local vehicle = createVehicle ( 411, x, y, z) 
    warpPedIntoVehicle (ped, vehicle)  
    setPedAnalogControlState(ped, 'accelerate', 1) 
  
end 
addCommandHandler ( "AI", AIo) 

Link to comment

try like this:

--server 
  
function setAiControl(ai,control,value) 
triggerClientEvent("onAiSetControl",ai,control,value) 
end 
  
function AIo ( playerSource ) 
local x, y, z = getElementPosition ( playerSource ) 
local ped = createPed(194,x,y,z) 
  
    local vehicle = createVehicle ( 411, x, y, z) 
    warpPedIntoVehicle (ped, vehicle) 
    setAiControl(ped,'accelerate', 1) 
  
end 
addCommandHandler ( "AI", AIo) 
  
-- client 
addEvent("onAiSetControl",true) 
addEventHandler("onAiSetControl",root, 
function(controlName,value) 
 setPedAnalogControlState(source,controlName, value) 
end) 

Link to comment
try like this:
--server 
  
function setAiControl(ai,control,value) 
triggerClientEvent("onAiSetControl",ai,control,value) 
end 
  
function AIo ( playerSource ) 
local x, y, z = getElementPosition ( playerSource ) 
local ped = createPed(194,x,y,z) 
  
    local vehicle = createVehicle ( 411, x, y, z) 
    warpPedIntoVehicle (ped, vehicle) 
    setAiControl(ped,'accelerate', 1) 
  
end 
addCommandHandler ( "AI", AIo) 
  
-- client 
addEvent("onAiSetControl",true) 
addEventHandler("onAiSetControl",root, 
function(controlName,value) 
 setPedAnalogControlState(source,controlName, value) 
end) 

He already figured it out.

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