AE. Posted September 9, 2016 Posted September 9, 2016 i created a function to make a ped fly with a heli it did not work function fly() local pp = getLocalPlayer () if isPedInVehicle ( pp ) then setPedControlState(Ped,"steer_back", true) end end
KariiiM Posted September 9, 2016 Posted September 9, 2016 You need to create a ped to let the function setPedControlState works.
AE. Posted September 9, 2016 Author Posted September 9, 2016 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
KariiiM Posted September 9, 2016 Posted September 9, 2016 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
EstrategiaGTA Posted September 9, 2016 Posted September 9, 2016 onResourceStart is a server-side event and setPedControlState is a client-side function... It won't work.
KariiiM Posted September 9, 2016 Posted September 9, 2016 (edited) Also, the Ped variable was not gonna be triggered since it was inside a function. Edited September 9, 2016 by KariiiM
AE. Posted September 9, 2016 Author Posted September 9, 2016 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?
draobrehtom Posted September 9, 2016 Posted September 9, 2016 (edited) I don't know another way to do this, but you maybe can create ped localy and synchronize it with a world I think (or it will be gonna automatically). Edited September 9, 2016 by draobrehtom
AE. Posted September 9, 2016 Author Posted September 9, 2016 i will just make a client with the same codes but without a function
undefined Posted September 9, 2016 Posted September 9, 2016 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] 1
AE. Posted September 9, 2016 Author Posted September 9, 2016 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 ...
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