Jump to content

setPedControlState


Recommended Posts

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
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 by Guest
Link to comment
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
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

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