Jump to content

Elseif -- expected end near line 10


micheal1230

Recommended Posts

title says error

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

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

change with

  
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)    

Link to comment

Sorry, your code is wrong too laserlaser.

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

Link to comment
Sorry, your code is wrong too laserlaser.
  
function seatBeltOn( player ) 
    local check = getPedOccupiedVehicle ( player ) 
    if ( check == true ) then 
         
        local beltOn = getElementData( player, "seatbelt" ) 
        if ( not beltOn ) then 
             
            setElementData( player, "seatbelt", true) 
            exports.global:sendLocalMeAction( player, "puts their seatbelt on.") 
        else 
            setElementData( player, "seatbelt", false) 
            exports.global:sendLocalMeAction( player, "takes their seatbelt off.")   
        end  
    elseif ( check == false ) then 
        outputChatBox("You are not in a car!", player, 255, 0, 0 ) 
    end 
end 
addCommandHandler("seatbelt", seatBeltOn)  
  

Oh I looked a if block only, not element == true :D

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