roddydennvor Posted March 22, 2015 Posted March 22, 2015 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...
roaddog Posted March 22, 2015 Posted March 22, 2015 (edited) 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 March 22, 2015 by Guest
TAPL Posted March 22, 2015 Posted March 22, 2015 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)
roddydennvor Posted March 22, 2015 Author Posted March 22, 2015 but how to add , when i use seat belt , i can't press "F" or "ENTER" , So i must to released my belt first ??
Addlibs Posted March 22, 2015 Posted March 22, 2015 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)
roddydennvor Posted March 22, 2015 Author Posted March 22, 2015 i use vehicle crash system , so when i got an accident , i will get out from vehicle and play anim /crack , but how to edit this , so when i use belt , i can't throw out of vehicle ?
Addlibs Posted March 22, 2015 Posted March 22, 2015 You could try setting element data seatbelt to false just before throwing the player out
xeon17 Posted March 22, 2015 Posted March 22, 2015 if getElementData(thePlayer, "seatbelt") then setElementData(thePlayer,"seatbelt",nil) ?
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