Jump to content

Script no loading when /refresh


micheal1230

Recommended Posts

script

function seatbelton( player ) 
    local check = getPedOccupiedVehicle ( player ) 
    if ( check == true ) then 
    setElementData( player, "seatbelt",true) 
    exports.global:sendLocalMeAction(player, "puts their seatbelt on") 
    elseif ( check == false ) then 
    outputChatBox("You are not in a car!", player, 255,0,0 ) 
    else 
    setElementData( player, "seatbelt",false) 
    exports.global:sendLocalMeAction(player, "takes their seatbelt off")     
    end 
end 
addCommandHandler("seatbelt",seatbelton)   

Meta

<meta> 
    <info author="haws1290" type="script" description="Seatbelt Script"/> 
     
    <script src="server.lua" type="server"/> 
</meta> 

Link to comment
if ( check == true ) then 

That's wrong, because getPedOccupiedVehicle returns the vehicle element, false otherwise.

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 ) 

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