Jump to content

[Help] Apply Impulse to a vehicle


player_258

Recommended Posts

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

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