Jump to content

HELP - BELT


Recommended Posts

Hii there ,,

This is belt script

function seatbelton ( player ) 
    local check = isPedInVehicle ( player ) 
    if ( check ) then 
        local state = ( not getElementData ( player, "seatbelt" ) ) 
        setElementData ( player, "seatbelt", state ) 
        exports.global:sendLocalMeAction ( player, "takes their seatbelt ".. ( state and "on" or "off" ) ) 
    else 
        outputChatBox ( "You are not in a car!", player, 255, 0, 0 ) 
    end 
end 
addCommandHandler ( "seatbelt", seatbelton ) 

How to edit this script , so when i use the belt, then nobody can hijack my car ,,

And when i use the belt , then i can't throw out from vehicle when crash...

Link to comment
  
function onVehicleStartEnter(thePlayer, seat, jacked) 
    if (isElement(jacked) and seat == 0 and getElementData( jacked, "seatbelt" )) then 
        outputChatBox( getPlayerName(jacked).." uses his belt. Therefore, you are unable to hijack him", thePlayer, 255, 0, 0, false) 
        cancelEvent() 
    end 
end 
addEventHandler( "onVehicleStartEnter", getRootElement(), onVehicleStartEnter ) 
  

edit: just realized that the source was player that starts entering the vehicle, my bad

Edited by Guest
Link to comment
function onVehicleStartEnter(thePlayer, seat, jacked) 
    if isElement(jacked) and seat == 0 and getElementData(jacked, "seatbelt") then 
        outputChatBox(getPlayerName(jacked).." uses his belt. Therefore, you are unable to hijack him", thePlayer, 255, 0, 0) 
        cancelEvent() 
    end 
end 
addEventHandler("onVehicleStartEnter", root, onVehicleStartEnter) 

Link to comment
function onAttemptExit(thePlayer) 
    if getElementData(thePlayer, "seatbelt") then 
        cancelEvent(true) 
        outputChatBox("You cannot exit the vehicle while you're wearing your seatbelt.", thePlayer, 255, 0, 0) 
    end 
end 
addEventHandler("onVehicleStartExit", root, onAttemptExit) 

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