Jump to content

help with controlstate


AE.

Recommended Posts

function cv()
    local Ped = createPed ( 287, 0, 0, 3 )
    local Vehicle = createVehicle ( 487, 1290.68958, -785.93646, 96.55399 )   
    setVehicleColor( Vehicle, 0, 0, 0, 0, 250, 250 )        
    setTimer ( warpPedIntoVehicle, 200, 1, Ped, Vehicle )                 
end
addEventHandler ("onResourceStart", resourceRoot, cv )

function fly()
local pp = getLocalPlayer ()
if isPedInVehicle ( pp ) then
setPedControlState(Ped,"steer_back", true)
end
end

 

Link to comment
local Ped = createPed ( 287, 0, 0, 3 )
local Vehicle = createVehicle ( 487, 1290.68958, -785.93646, 96.55399 )   
setVehicleColor( Vehicle, 0, 0, 0, 0, 250, 250 )        
setTimer ( warpPedIntoVehicle, 200, 1, Ped, Vehicle )                 


function fly ( )  
    local theVeh = getPedOccupiedVehicle ( Ped )
    if ( theVeh ) then
        setPedControlState ( Ped, "steer_back", true )
    end
end

 

Link to comment
4 minutes ago, EstrategiaGTA said:

onResourceStart is a server-side event and setPedControlState is a client-side function... It won't work.

yes i missed this 
 

 

5 minutes ago, KariiiM said:

local Ped = createPed ( 287, 0, 0, 3 )
local Vehicle = createVehicle ( 487, 1290.68958, -785.93646, 96.55399 )   
setVehicleColor( Vehicle, 0, 0, 0, 0, 250, 250 )        
setTimer ( warpPedIntoVehicle, 200, 1, Ped, Vehicle )                 


function fly ( )  
    local theVeh = getPedOccupiedVehicle ( Ped )
    if ( theVeh ) then
        setPedControlState ( Ped, "steer_back", true )
    end
end

 

i want the ped do steer_back when a player enter as a passenger ...

9 minutes ago, KariiiM said:

Also, the Ped variable was not gonna be triggered since it was inside a function.

then wtf should i do?

how do i trigger without a function? 

 

Link to comment
Spoiler

 

Server-Side
[lua]local control = {}

addEventHandler("onResourceStart", resourceRoot, function()
     control.vehicle = createVehicle(...)
     control.ped = createPed(...)
     setTimer(warpPedIntoVehicle, 200, 1, control.ped, control.vehicle)
end)

local function fly()
     triggerClientEvent("fly", resourceRoot, control)
end

addEventHandler("onVehicleEnter", root, function(player, seat)
     if seat ~= 0 and source == control.vehicle then
          fly()
     end
end)[/lua]

Client-Side
[lua]
addEvent("fly", true)
addEventHandler("fly", root, function(control)
     setPedControlState(control.ped, "steer_back", true)
end)[/lua]

  • Like 1
Link to comment
7 minutes ago, ZoRRoM said:
  Reveal hidden contents

 

Server-Side
[lua]local control = {}

addEventHandler("onResourceStart", resourceRoot, function()
     control.vehicle = createVehicle(...)
     control.ped = createPed(...)
     setTimer(warpPedIntoVehicle, 200, 1, control.ped, control.vehicle)
end)

local function fly()
     triggerClientEvent("fly", resourceRoot, control)
end

addEventHandler("onVehicleEnter", root, function(player, seat)
     if seat ~= 0 and source == control.vehicle then
          fly()
     end
end)[/lua]

Client-Side
[lua]
addEvent("fly", true)
addEventHandler("fly", root, function(control)
     setPedControlState(control.ped, "steer_back", true)
end)[/lua]

it works but still don't fly ...

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