Junim Posted May 15, 2018 Posted May 15, 2018 (edited) WeaponCar = {}; Guard1 = {}; Guard2 = {}; addEventHandler("onResourceStart", root, function () StartTrajet (); end ) function StartTrajet () setTimer(function() if (isElement(WeaponCar) ) then destroyElement(WeaponCar); end if (isElement(Guard1) ) then destroyElement(Guard1); end if (isElement(Guard2) ) then destroyElement(Guard2); end WeaponCar = createVehicle(498, 1360, -1279, 14); Guard1 = createPed(73, 0, 0, 0); Guard2 = createPed(73, 0, 0, 0); warpPedIntoVehicle(Guard1, WeaponCar); warpPedIntoVehicle(Guard2, WeaponCar, 1); setElementRotation(WeaponCar, 0, 0, 1); setVehicleColor(WeaponCar, 0, 0, 0, 255); setControlState(WeaponCar, "accelerate", true); end, 1500, 1) end Hi guys, my problem is this "setControlState" my debugscript say "Expected player at argument 1, got vehicle" why he say this? what is the error in my code? Sorry my english I AM FROM BRAZIL ! I want that this vehicle accelerate alone , because i am doing an Artificial Inteligence "Traffic of vehicles". you can help me? Edited May 15, 2018 by Junim I entered the wrong code
Moderators IIYAMA Posted May 15, 2018 Moderators Posted May 15, 2018 You can't apply control states directly on to vehicles. You can only apply it on to players. (Or peds with another function) In your case you have to use a ped with this function: https://wiki.multitheftauto.com/wiki/SetPedControlState Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
MIKI785 Posted May 15, 2018 Posted May 15, 2018 2 hours ago, IIYAMA said: You can't apply control states directly on to vehicles. You can only apply it on to players. (Or peds with another function) In your case you have to use a ped with this function: https://wiki.multitheftauto.com/wiki/SetPedControlState This or you can make the vehicle move on its own using setElementVelocity. 1 Lua Scripter Owner of mshost.cz MTA portal.
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