micheal1230 Posted August 11, 2012 Share Posted August 11, 2012 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
Castillo Posted August 11, 2012 Share Posted August 11, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now