xxldoener Posted June 2, 2012 Share Posted June 2, 2012 Hey, I just wanted to program a give-car-script. Here's my code function givevehicle1 (commandname, target, vehicleid) local targetp = getPlayerFromName (target) local x, y, z = getElementPosition ( targetp ) local givenvehicle = createVehicle ( vehicleid, x, y, z) warpPedIntoVehicle (target, givenvehicle) end addCommandHandler ( "givevehicle1", givevehicle1 ) What am I doing wrong? Link to comment
Castillo Posted June 2, 2012 Share Posted June 2, 2012 function givevehicle1 ( thePlayer, commandname, target, vehicleid ) -- You had missing the first argument. local targetp = getPlayerFromName ( target ) if ( targetp ) then -- If the player exists .. local x, y, z = getElementPosition ( targetp ) -- Get his/her position. local givenvehicle = createVehicle ( tonumber ( vehicleid ), x, y, z ) -- Attempt to create a vehicle with the given ID. if ( givenvehicle ) then -- If the vehicle was created .. warpPedIntoVehicle ( target, givenvehicle ) -- Warp the player to the vehicle end end end addCommandHandler ( "givevehicle1", givevehicle1 ) Read comments. Link to comment
xxldoener Posted June 3, 2012 Author Share Posted June 3, 2012 Thank you, I did have the first argument before but removed it in hope it wold change anything ^^ the "tonumber" was the one i was looking for, thank you Link to comment
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