Jump to content

[HELP] Engine/vehicle...


lolman

Recommended Posts

Hello,

I've a problem with my script.

function engine() 
    local vehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
    local health = getElementHealth ( vehicle ) 
    if vehicle and ( health == 250 ) 
    then outputChatBox ("Worked!",255,0,0,thePlayer) 
    setVehicleEngineState ( vehicle, false ) 
end 
end 
addEventHandler ("onPlayerVehicleEnter", getRootElement(), engine) 
--addCommandHandler("123", engine) 

Here in this script I want that you can't drive the car (setengine false) when you enter the car if it has 25% health (as you can see there is (health == 250). everything works fine with the command if I use it but if i want it on playervehicleenter, it doesnt work, please help needed !

Link to comment

try this ..

  
function engine() 
    local vehicle = getPedOccupiedVehicle(source) 
    local health = getElementHealth ( vehicle ) 
    if vehicle and ( health == 250 ) then 
     outputChatBox ("Worked!",source,255,0,0,true) 
    setVehicleEngineState ( vehicle, false ) 
     end 
end 
addEventHandler ("onPlayerVehicleEnter", getRootElement(), engine) 
--addCommandHandler("123", engine) 
  

Link to comment
Nop... didn't work.... btw my server is client sided...

ah, ok .. use this

  
function engine() 
    local vehicle = getPedOccupiedVehicle(source) 
    local health = getElementHealth (vehicle) 
    if vehicle and ( health == 250 ) then 
     outputChatBox ("Worked!",255,0,0,true) 
    setVehicleEngineState (vehicle, false ) 
     end 
end 
addEventHandler ("onClientPlayerVehicleEnter",root, engine) 
--addCommandHandler("123", engine) 
  

Link to comment
btw how can you set the engine off while driving the car and the car gets 25% health?

try ..

  
function Ecollision() 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if source == vehicle then 
    local health = getElementHealth (vehicle) 
        if health <= 250 then 
        setVehicleEngineState (vehicle, false ) 
        end 
    end 
end 
addEventHandler ("onClientVehicleCollision",root,Ecollision) 
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...