Hi Guys, My friend did oil (fossil) script. But İt's not working. Can you help we ?
function showPlayerFuel()
if( fuelFrame) then
destroyElement(fuelFrame)
destroyElement(fuelBar1)
end
fuelFrame = guiCreateStaticImage( 0.72, 0.79, 0.05, 0.20, "images/Fuel_Gage.png", true)
fuelBar1 = guiCreateStaticImage( 0.742, 0.811, 0.021, 0.17, "images/Fuel_Dot.png", true)
guiBringToFront ( fuelFrame )
end
addEvent("FullTank", true )
addEventHandler("FullTank", getLocalPlayer(), showPlayerFuel)
addEvent("fullRefill", true)
addEventHandler("fullRefill",getLocalPlayer(), showPlayerFuel)
addEvent("fuelGageShow", true)
addEventHandler("fuelGageShow", getLocalPlayer(), showPlayerFuel)
function CurrentFuelIn ( currentFuel )
local sizex = currentFuel["sizex"]
local sizey = currentFuel["sizey"]
local posx = currentFuel["posx"]
local posy = currentFuel["posy"]
if(fuelFrame) then
destroyElement(fuelFrame)
destroyElement(fuelBar1)
end
fuelBar1 = guiCreateStaticImage( tonumber(posx), tonumber(posy), tonumber(sizex), tonumber(sizey), "images/Fuel_Dot.png", true)
fuelFrame = guiCreateStaticImage( 0.72, 0.79, 0.05, 0.20, "images/Fuel_Gage.png", true)
if(posy and posy > 0.9) then
if not warningdot1 then
warningdot1 = guiCreateStaticImage( 0.7288, 0.912, 0.014, 0.016, "images/warning_dot.png", true)
end
if(Posy >= 0.981) then
setVehicleEngineState(getPedOccupiedVehicle(gMe),false)
else
outputChatBox("-- You Are Quite Low On Fuel | Refuel at Area 51", 255, 50, 50, true)
playSoundFrontEnd(4)
end
end
end
addEvent("CurrentFuel", true)
addEventHandler("CurrentFuel", getLocalPlayer(), CurrentFuelIn)
function startExit ( thePlayer,seat )
if thePlayer == getLocalPlayer() and seat == 0 then
local x, y = guiGetSize( fuelBar1, true )
local Posx, Posy = guiGetPosition ( fuelBar1, true )
local fTbl = {}
fTbl.sizex = x
fTbl.sizey = y
fTbl.posx = Posx
fTbl.posy = Posy
triggerServerEvent('onGetFuel',source,fTbl)
hidePlayerFuel()
killTimer(fuelTimer)
end
end
addEventHandler("onClientVehicleStartExit", getRootElement(), startExit )
function vehEntered ( veh,seat )
if seat == 0 and isElement(fuelBar1) then
local Posx, Posy = guiGetPosition ( fuelBar1, true )
if(Posy and Posy >= 0.981) then
setVehicleEngineState(veh,false)
end
end
fuelTimer = setTimer ( decFuel1, 2000, 0)
end
addEventHandler("onClientPlayerVehicleEnter", getLocalPlayer(), vehEntered )
function decFuel1()
local PlayerInCar = getPedOccupiedVehicle( getLocalPlayer() )
if (PlayerInCar and getVehicleController(PlayerInCar) == gMe and not isPlayerDead(gMe) ) then
local x, y = guiGetSize( fuelBar1, true )
local Posx, Posy = guiGetPosition ( fuelBar1, true )
local NewY,NewPosY
if not Posy then return end
if((isElementWithinColShape(gMe,safeZone) or isElementWithinSafeArea(gMe)) and Posy > 0.812) then
NewY = y + 0.009
NewPosY = Posy - 0.009
if(warningdot1) then
destroyElement(warningdot1)
warningdot1 = nil
playSoundFrontEnd(1)
end
elseif(Posy < 0.981) then
local velo = getActualVelocity( PlayerInCar )
local val = (velo < 5 and 0) or (velo < 100 and 0.0006) or 0.0009
NewY = y - val
NewPosY = Posy + val
if(Posy and (Posy > 0.950 and Posy<0.953) and not warningdot1) then
warningdot1 = guiCreateStaticImage( 0.7288, 0.912, 0.014, 0.016, "images/warning_dot.png", true)
playSoundFrontEnd(4)
end
elseif (Posy >= 0.981 and getVehicleEngineState(PlayerInCar)) then
setVehicleEngineState(PlayerInCar,false)
callServerFunction('setVehicleEngineState',PlayerInCar,false)
end
guiSetSize(fuelBar1, x, NewY, true)
guiSetPosition(fuelBar1, Posx, NewPosY, true )
else
hidePlayerFuel()
killTimer(fuelTimer)
end
end
function hidePlayerFuel ()
if fuelBar1 then
destroyElement(fuelBar1)
destroyElement(fuelFrame)
if warningdot1 then
destroyElement(warningdot1)
end
fuelBar1,fuelFrame,warningdot1 = nil
end
end
addEvent("jacked", true )
addEventHandler("jacked", getLocalPlayer(), hidePlayerFuel )
function getActualVelocity( element )
if(element) then x,y,z = getElementVelocity(element) end
return math.sqrt(x^2 + y^2 + z^2) * 161
end