player_258 Posted February 3, 2013 Share Posted February 3, 2013 Im trying to make a script that randomly "pushes" a car in a random direction. The problem is, i don't know how to get the vehicle that the player is driving. btw, this is supposed to work in a server running "race" Gamemode. server.lua addEvent("forceButtonInfo",true) function forceButtonServer(playerName) --Connected with a gui button in client.lua local targetPlayer = getPlayerFromName ( playerName ) if ( targetPlayer ) then outputChatBox("Player Found!") --This actually appears in the chatbox so the function is working setElementVelocity ( targetPlayer,math.random(-100,100), math.random(-100,100),math.random(-100,100) ) --This doesnt work else outputChatBox("Player not Found") end end addEventHandler ( "forceButtonInfo", getRootElement(), forceButtonServer ) Sorry if theres any typo, im not a native english speaker. Link to comment
csiguusz Posted February 3, 2013 Share Posted February 3, 2013 You can get a player's vehicle so whith getPedOccupiedVehicle. And if you try to set a ped's velocity which is standing on the ground X and Y won't be applied to the player, just Z. Link to comment
csiguusz Posted February 3, 2013 Share Posted February 3, 2013 getPedOccupiedVehicle Ahh, you were faster Link to comment
player_258 Posted February 3, 2013 Author Share Posted February 3, 2013 Thanks to both of you for the quick response 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