Jump to content

removePedFromVehicle


Recommended Posts

  
local localPlayer = getLocalPlayer() 
  
function fuehrerschein() 
    if isPedInVehicle(localPlayer) then 
        local fuehrerscheinda = tostring(getElementData(localPlayer,"Scheine")) 
            if fuehrerscheinda == "0" then 
                outputChatBox("Du hast keinen Führerschein!", thePlayer,255,0,0) 
                removePedFromVehicle ( localPlayer ) 
            end 
  
    end 
end 
addEventHandler( "onClientPlayerVehicleEnter", localPlayer, fuehrerschein ) 
  

My Problem :

This Code has to be clientside, but the removePedFromVehicle serverside. How do I get this function serverside?

The outputChatBox isn't red, like it should be.

Thanks

Link to comment

Well, you can trigger a server event to remove yourself from a vehicle.

--client side 
local localPlayer = getLocalPlayer() 
  
function fuehrerschein() 
    if isPedInVehicle(localPlayer) then 
        local fuehrerscheinda = tostring(getElementData(localPlayer,"Scheine")) 
        if fuehrerscheinda == "0" then 
            outputChatBox("Du hast keinen Führerschein!",255,0,0) --removed 'thePlayer', look wiki for details 
            triggerServerEvent( "removeMe", localPlayer ) 
        end 
    end 
end 
addEventHandler( "onClientPlayerVehicleEnter", localPlayer, fuehrerschein ) 

--SERVER side 
addEvent( "removeMe", true ) 
addEventHandler( "removeMe", getRootElement(), function() 
  removePedFromVehicle( source ) 
end ) 

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