ramzi Posted January 26, 2015 Share Posted January 26, 2015 hi guys,this script over here to show vh health but it doesnt work! check this error msg: MVehicleSettings\vehhealth.lua:2: Bad argument @ 'isPedInVehicle' [Expected ped at argument 1, got nil] Lua code: function vehHealth(check) if (isPedInVehicle(localPlayer)) then vHealth = getElementHealth(getPedOccupiedVehicle(localPlayer)) vHealth = math.floor(vHealth/10) if not (check == "noez" and vHealth >= 95) then exports.Mcommands:sendClientMessage("*INFO* The vehicle health is currently: %" .. vHealth .. ".",255,255,0) end end end function enterVehHealth(thePlayer, seat) if (seat == 0 and thePlayer == localPlayer) then vehHealth("noez") end end addCommandHandler("vh", vehHealth) addEventHandler ( "onClientVehicleEnter", getRootElement(), enterVehHealth) Link to comment
Carlos23 Posted January 26, 2015 Share Posted January 26, 2015 if (isPedInVehicle(getLocalPlayer()) then Link to comment
John Smith Posted January 26, 2015 Share Posted January 26, 2015 if (isPedInVehicle(getLocalPlayer()) then its getLocalPlayer() is same thing as localPlayer Link to comment
LaCosTa Posted January 26, 2015 Share Posted January 26, 2015 Is this code server or client one ? Link to comment
The Don Posted January 26, 2015 Share Posted January 26, 2015 I rewriting the code and it is work ! -- Client Side addEventHandler('onClientVehicleEnter',root, function (thePlayer, seat) local Vehicle = getPedOccupiedVehicle ( localPlayer ) local Health = getElementHealth ( Vehicle ) / 10 if thePlayer == localPlayer then if seat == 0 then if Health >= 90 then outputChatBox('Your Vehicle is healthy '..Health..'',255,255,0) else outputChatBox('Your Vehicle is damged '..Health..'',255,0,0) end end end end ) -- with command addCommandHandler('vh', function () local Vehicle = getPedOccupiedVehicle ( localPlayer ) local Health = getElementHealth ( Vehicle ) / 10 if isPedInVehicle ( localPlayer ) then if Health >= 90 then outputChatBox('Your Vehicle is healthy '..Health..'',255,255,0) else outputChatBox('Your Vehicle is damged '..Health..'',255,0,0) end end end ) 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