Neler yeni

Foruma hoş geldin, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Türkiye'nin İlk ve tek FiveM forum adresi

Forum adresimize hoş geldin FiveMTürk olarak amacımız siz değerli kullanıcılarımıza en aktif fikir ve paylaşım platformu sunmak bir yana en güvenilir şekilde alışveriş yapabileceğiniz bir platform sunmaktır.
DF DF
DF DF
DF DF

Cevaplandı Kmh nin 10 10 artması?

  • Konbuyu başlatan docs
  • Başlangıç tarihi
  • Cevaplar 24
  • Görüntüleme 1K
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...

docs

Üye
FT Kullanıcı
Katılım
4 yıl 4 ay 20 gün
Mesajlar
206
Arkadaşlar başlıktada belirttiğim gibi bazılarınızın bildiği üzere sway_carhud veya np_carhud olarak geçen carhud da kmh 10 25 30 50 olarak artıyor ben bunun 1 2 3 4 5 6 7 8 diye sıralı artmasını istiyorum yardımcı olabilicek varmı

Hudun Göresli ve sıralı bir şekilde artması gereken yer:
41162
 
DF
Moderatör tarafında düzenlendi:
Konu tarafımca uygun kategoriye taşınmıştır.
 
DF
Arkadaşlar başlıktada belirttiğim gibi bazılarınızın bildiği üzere sway_carhud veya np_carhud olarak geçen carhud da kmh 10 25 30 50 olarak artıyor ben bunun 1 2 3 4 5 6 7 8 diye sıralı artmasını istiyorum yardımcı olabilicek varmı

Hudun Göresli ve sıralı bir şekilde artması gereken yer:
Ekli dosyayı görüntüle 41162
Burada ki eklenti dediğiniz gibidir kodlarına göz gezdirerek yapabilirsiniz.
 
DF
GetEntitySpeed
adı ile CTRL + F Kombinasyonunu kullanarak Clientside içerisinde arama yap.
karşına mutlaka bir kod bloğu gelecektir. bloğun içerisinde bulunan
"Citizen.Wait(msec)" kodunun parantez içerisindeki değerini 1 yaparsan sorunun çözülecektir
iyi günler iyi forumlar.
 
DF
GetEntitySpeed
adı ile CTRL + F Kombinasyonunu kullanarak Clientside içerisinde arama yap.
karşına mutlaka bir kod bloğu gelecektir. bloğun içerisinde bulunan
"Citizen.Wait(msec)" kodunun parantez içerisindeki değerini 1 yaparsan sorunun çözülecektir
iyi günler iyi forumlar.
deniyorum
 
DF
GetEntitySpeed
adı ile CTRL + F Kombinasyonunu kullanarak Clientside içerisinde arama yap.
karşına mutlaka bir kod bloğu gelecektir. bloğun içerisinde bulunan
"Citizen.Wait(msec)" kodunun parantez içerisindeki değerini 1 yaparsan sorunun çözülecektir
iyi günler iyi forumlar.
arattığımda karşıma çıkan tüm Citizen.Waitlerin parantezindekileri tek tek 1 yaparak test ettim olmadı malesef :/
 
DF
JavaScript:
local seatbeltInput = 311                   -- Toggle seatbelt on/off with K or DPAD down (controller)
local seatbeltPlaySound = true              -- Play seatbelt sound
local seatbeltDisableExit = true            -- Disable vehicle exit when seatbelt is enabled
local seatbeltEjectSpeed = 45.0             -- Speed threshold to eject player (MPH)
local seatbeltEjectAccel = 100.0            -- Acceleration threshold to eject player (G's)
local seatbeltColorOn = {160, 255, 160}     -- Color used when seatbelt is on
local seatbeltColorOff = {255, 96, 96}      -- Color used when seatbelt is off
DecorRegister("_FUEL_LEVEL",3)
Fuel = 0
local gasStations = {
    {179.8573, 6602.839, 31.86817,600},
}

function getVehicleInDirection(coordFrom, coordTo)
    local offset = 0
    local rayHandle
    local vehicle

    for i = 0, 100 do
        rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z + offset, 10, PlayerPedId(), 0)   
        a, b, c, d, vehicle = GetRaycastResult(rayHandle)
        
        offset = offset - 1

        if vehicle ~= 0 then break end
    end
    
    local distance = Vdist2(coordFrom, GetEntityCoords(vehicle))
    
    if distance > 3000 then vehicle = nil end

    return vehicle ~= nil and vehicle or 0
end
local pedInVeh = false
local seatbeltIsOn = false
Citizen.CreateThread(function()
    local currSpeed = 0.0
    while true do
        Citizen.Wait(0)
        local player = GetPlayerPed(-1)
        local position = GetEntityCoords(player)
        local vehicle = GetVehiclePedIsIn(player, false)

        -- Set vehicle states
        if IsPedInAnyVehicle(player, false) then
            pedInVeh = true
        else
            -- Reset states when not in car
            pedInVeh = false
            cruiseIsOn = false
            seatbeltIsOn = false
        end
        local vehicleClass = GetVehicleClass(vehicle)
        if pedInVeh and vehicleClass ~= 13 then
            local prevSpeed = currSpeed
            currSpeed = GetEntitySpeed(vehicle)

            -- Set PED flags
            SetPedConfigFlag(PlayerPedId(), 32, true)
            if IsControlJustReleased(0, seatbeltInput) and (enableController or GetLastInputMethod(0)) and vehicleClass ~= 8 then
                -- Toggle seatbelt status and play sound when enabled
                seatbeltIsOn = not seatbeltIsOn
                if seatbeltPlaySound then
                    PlaySoundFrontend(-1, "Faster_Click", "RESPAWN_ONLINE_SOUNDSET", 1)
                end
            end
            if not seatbeltIsOn then
                -- Eject PED when moving forward, vehicle was going over 45 MPH and acceleration over 100 G's
                local vehIsMovingFwd = GetEntitySpeedVector(vehicle, true).y > 1.0
                local vehAcc = (prevSpeed - currSpeed) / GetFrameTime()
                if (vehIsMovingFwd and (prevSpeed > (seatbeltEjectSpeed/2.237)) and (vehAcc > (seatbeltEjectAccel*9.81))) then
                    SetEntityCoords(player, position.x, position.y, position.z - 0.47, true, true, true)
                    SetEntityVelocity(player, prevVelocity.x, prevVelocity.y, prevVelocity.z)
                    Citizen.Wait(1)
                    SetPedToRagdoll(player, 1000, 1000, 0, 0, 0, 0)
                else
                    -- Update previous velocity for ejecting player
                    prevVelocity = GetEntityVelocity(vehicle)
                end
            elseif seatbeltDisableExit then
                -- Disable vehicle exit when seatbelt is on
                DisableControlAction(0, 75)
            end
            Citizen.Wait(0)
        else
            Citizen.Wait(400)
        end
    end
end)


function TargetVehicle()
    playerped = PlayerPedId()
    coordA = GetEntityCoords(playerped, 1)
    coordB = GetOffsetFromEntityInWorldCoords(playerped, 0.0, 100.0, 0.0)
    targetVehicle = getVehicleInDirection(coordA, coordB)
    return targetVehicle
end

function TargetVehicle()
    playerped = PlayerPedId()
    coordA = GetEntityCoords(playerped, 1)
    coordB = GetOffsetFromEntityInWorldCoords(playerped, 0.0, 100.0, 0.0)
    targetVehicle = getVehicleInDirection(coordA, coordB)
    return targetVehicle
end




function round( n )
    return math.floor( n + 0.5 )
end

function drawTxt(x,y ,width,height,scale, text, r,g,b,a)
    SetTextFont(4)
    SetTextProportional(0)
    SetTextScale(scale, scale)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(2, 0, 0, 0, 255)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(x - width/2, y - height/2 + 0.005)
end

local zoneNames = {
AIRP = "Los Santos International Airport",
ALAMO = "Alamo Sea",
ALTA = "Alta",
ARMYB = "Fort Zancudo",
BANHAMC = "Banham Canyon Dr",
BANNING = "Banning",
BAYTRE = "Baytree Canyon",
BEACH = "Vespucci Beach",
BHAMCA = "Banham Canyon",
BRADP = "Braddock Pass",
BRADT = "Braddock Tunnel",
BURTON = "Burton",
CALAFB = "Calafia Bridge",
CANNY = "Raton Canyon",
CCREAK = "Cassidy Creek",
CHAMH = "Chamberlain Hills",
CHIL = "Vinewood Hills",
CHU = "Chumash",
CMSW = "Chiliad Mountain State Wilderness",
CYPRE = "Cypress Flats",
DAVIS = "Davis",
DELBE = "Del Perro Beach",
DELPE = "Del Perro",
DELSOL = "La Puerta",
DESRT = "Grand Senora Desert",
DOWNT = "Downtown",
DTVINE = "Downtown Vinewood",
EAST_V = "East Vinewood",
EBURO = "El Burro Heights",
ELGORL = "El Gordo Lighthouse",
ELYSIAN = "Elysian Island",
GALFISH = "Galilee",
GALLI = "Galileo Park",
golf = "GWC and Golfing Society",
GRAPES = "Grapeseed",
GREATC = "Great Chaparral",
HARMO = "Harmony",
HAWICK = "Hawick",
HORS = "Vinewood Racetrack",
HUMLAB = "Humane Labs and Research",
JAIL = "Bolingbroke Penitentiary",
KOREAT = "Little Seoul",
LACT = "Land Act Reservoir",
LAGO = "Lago Zancudo",
LDAM = "Land Act Dam",
LEGSQU = "Legion Square",
LMESA = "La Mesa",
LOSPUER = "La Puerta",
MIRR = "Mirror Park",
MORN = "Morningwood",
MOVIE = "Richards Majestic",
MTCHIL = "Mount Chiliad",
MTGORDO = "Mount Gordo",
MTJOSE = "Mount Josiah",
MURRI = "Murrieta Heights",
NCHU = "North Chumash",
NOOSE = "N.O.O.S.E",
OCEANA = "Pacific Ocean",
PALCOV = "Paleto Cove",
PALETO = "Paleto Bay",
PALFOR = "Paleto Forest",
PALHIGH = "Palomino Highlands",
PALMPOW = "Palmer-Taylor Power Station",
PBLUFF = "Pacific Bluffs",
PBOX = "Pillbox Hill",
PROCOB = "Procopio Beach",
RANCHO = "Rancho",
RGLEN = "Richman Glen",
RICHM = "Richman",
ROCKF = "Rockford Hills",
RTRAK = "Redwood Lights Track",
SanAnd = "San Andreas",
SANCHIA = "San Chianski Mountain Range",
SANDY = "Sandy Shores",
SKID = "Mission Row",
SLAB = "Stab City",
STAD = "Maze Bank Arena",
STRAW = "Strawberry",
TATAMO = "Tataviam Mountains",
TERMINA = "Terminal",
TEXTI = "Textile City",
TONGVAH = "Tongva Hills",
TONGVAV = "Tongva Valley",
VCANA = "Vespucci Canals",
VESP = "Vespucci",
VINE = "Vinewood",
WINDF = "Ron Alternates Wind Farm",
WVINE = "West Vinewood",
ZANCUDO = "Zancudo River",
ZP_ORT = "Port of South Los Santos",
ZQ_UAR = "Davis Quartz"
}

-- CONFIG --
local showCompass = true
-- CODE --
local compass = "Loading GPS"

local lastStreet = nil
local lastStreetName = ""
local zone = "Unknown";

function playerLocation()
    return lastStreetName
end

function playerZone()
    return zone
end

-- Thanks @marxy
function getCardinalDirectionFromHeading(heading)
    if heading >= 315 or heading < 45 then
        return "North Bound"
    elseif heading >= 45 and heading < 135 then
        return "West Bound"
    elseif heading >=135 and heading < 225 then
        return "South Bound"
    elseif heading >= 225 and heading < 315 then
        return "East Bound"
    end
end

local seatbelt = false
RegisterNetEvent("seatbelt")
AddEventHandler("seatbelt", function(belt)
    seatbelt = belt
end)

local time = "12:00"
RegisterNetEvent("timeheader")
AddEventHandler("timeheader", function(h,m)
    if h < 10 then
        h = "0"..h
    end
    if m < 10 then
        m = "0"..m
    end
    time = h .. ":" .. m
end)



local counter = 0
local Mph = GetEntitySpeed(GetVehiclePedIsIn(PlayerPedId(), false)) * 3.6
local Fuel = 0.0
local uiopen = false
local colorblind = false
local compass_on = false

RegisterNetEvent('option:colorblind')
AddEventHandler('option:colorblind',function()
    colorblind = not colorblind
end)

Citizen.CreateThread(function()
    local x, y, z = table.unpack(GetEntityCoords(PlayerPedId(), true))
    local currentStreetHash, intersectStreetHash = GetStreetNameAtCoord(x, y, z, currentStreetHash, intersectStreetHash)
    currentStreetName = GetStreetNameFromHashKey(currentStreetHash)
    intersectStreetName = GetStreetNameFromHashKey(intersectStreetHash)
    zone = tostring(GetNameOfZone(x, y, z))
    playerStreetsLocation = zoneNames[tostring(zone)]

    if not zone then
        zone = "UNKNOWN"
        zoneNames['UNKNOWN'] = zone
    elseif not zoneNames[tostring(zone)] then
        local undefinedZone = zone .. " " .. x .. " " .. y .. " " .. z
        zoneNames[tostring(zone)] = "Undefined Zone"
    end

    if intersectStreetName ~= nil and intersectStreetName ~= "" then
        playerStreetsLocation = currentStreetName .. " | " .. intersectStreetName .. " | [" .. zoneNames[tostring(zone)] .. "]"
    elseif currentStreetName ~= nil and currentStreetName ~= "" then
        playerStreetsLocation = currentStreetName .. " | [" .. zoneNames[tostring(zone)] .. "]"
    else
        playerStreetsLocation = "[" .. zoneNames[tostring(zone)] .. "]"
    end

    while true do
        Citizen.Wait(10)
        local player = PlayerPedId()
        local x, y, z = table.unpack(GetEntityCoords(player, true))
        local currentStreetHash, intersectStreetHash = GetStreetNameAtCoord(x, y, z, currentStreetHash, intersectStreetHash)
        currentStreetName = GetStreetNameFromHashKey(currentStreetHash)
        intersectStreetName = GetStreetNameFromHashKey(intersectStreetHash)
        zone = tostring(GetNameOfZone(x, y, z))
        playerStreetsLocation = zoneNames[tostring(zone)]

        if not zone then
            zone = "UNKNOWN"
            zoneNames['UNKNOWN'] = zone
        elseif not zoneNames[tostring(zone)] then
            local undefinedZone = zone .. " " .. x .. " " .. y .. " " .. z
            zoneNames[tostring(zone)] = "Undefined Zone"
        end

        if intersectStreetName ~= nil and intersectStreetName ~= "" then
            playerStreetsLocation = currentStreetName .. " | " .. intersectStreetName .. " | [" .. zoneNames[tostring(zone)] .. "]"
        elseif currentStreetName ~= nil and currentStreetName ~= "" then
            playerStreetsLocation = currentStreetName .. " | [" .. zoneNames[tostring(zone)] .. "]"
        else
            playerStreetsLocation = "[".. zoneNames[tostring(zone)] .. "]"
        end
        -- compass = getCardinalDirectionFromHeading(math.floor(GetEntityHeading(player) + 0.5))
        -- street = compass .. " | " .. playerStreetsLocation
        street = playerStreetsLocation
 
        if IsVehicleEngineOn(GetVehiclePedIsIn(player, false)) then         

            if not uiopen then
                uiopen = true
                SendNUIMessage({
                  open = 1,
                })
            end
            local playerPed = PlayerPedId()
            local vehicle = GetVehiclePedIsIn(playerPed, false)
            Fuel = exports["np-fuel"]:GetFuel(vehicle)
            Mph = math.ceil(GetEntitySpeed(GetVehiclePedIsIn(player, false)) * 3.6)
            local hours = GetClockHours()
            if string.len(tostring(hours)) == 1 then
                trash = '0'..hours
            else
                trash = hours
            end
    
            local mins = GetClockMinutes()
            if string.len(tostring(mins)) == 1 then
                mins = '0'..mins
            else
                mins = mins
            end


            SendNUIMessage({
              open = 2,
              mph = Mph,
              fuel = math.ceil(Fuel),
              street = street,
              belt = seatbeltIsOn,
              time = hours .. ':' .. mins,
              colorblind = colorblind
            })

        else

            if uiopen and not compass_on then
                SendNUIMessage({
                  open = 3,
                })

                uiopen = false
            end

            compass_on = false
        end


RegisterNetEvent('carHud:compass')
AddEventHandler('carHud:compass', function(table)
        compass_on = not compass_on
    end)
    RegisterNetEvent('carHud:compassoff')
AddEventHandler('carHud:compassoff', function(table)
        compass_on = false
    end)
local IsPedInVehicle = false
if IsPedInVehicle ~= false then
TriggerClientEvent('carHud:compassoff')
        end
    end
end)


Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1)
        local player = PlayerPedId()
        if IsVehicleEngineOn(GetVehiclePedIsIn(player, false)) then
            -- in vehicle
            SendNUIMessage({
                open = 2,
                direction = math.floor(calcHeading(-GetEntityHeading(player) % 360)),
            })
        elseif compass_on == true then
            -- has compass toggled
            if not uiopen then
                uiopen = true
                SendNUIMessage({
                  open = 1,
                })
            end

            SendNUIMessage({
                open = 4,
                time = time,
                direction = math.floor(calcHeading(-GetEntityHeading(player) % 360)),
            })
            
        else
            Citizen.Wait(1000)
        end
    end
end)

Controlkey = {["generalUse"] = {38,"E"}}
RegisterNetEvent('event:control:update')
AddEventHandler('event:control:update', function(table)
    Controlkey["generalUse"] = table["generalUse"]
end)




---------------------------------
-- Compass shit
---------------------------------

--[[
    Heavy Math Calcs
 ]]--

 local imageWidth = 100 -- leave this variable, related to pixel size of the directions
 local containerWidth = 100 -- width of the image container
 
 -- local width =  (imageWidth / containerWidth) * 100; -- used to convert image width if changed
 local width =  0;
 local south = (-imageWidth) + width
 local west = (-imageWidth * 2) + width
 local north = (-imageWidth * 3) + width
 local east = (-imageWidth * 4) + width
 local south2 = (-imageWidth * 5) + width
 
 function calcHeading(direction)
     if (direction < 90) then
         return lerp(north, east, direction / 90)
     elseif (direction < 180) then
         return lerp(east, south2, rangePercent(90, 180, direction))
     elseif (direction < 270) then
         return lerp(south, west, rangePercent(180, 270, direction))
     elseif (direction <= 360) then
         return lerp(west, north, rangePercent(270, 360, direction))
     end
 end
 
 
 function rangePercent(min, max, amt)
     return (((amt - min) * 100) / (max - min)) / 100
 end
 
 function lerp(min, max, amt)
     return (1 - amt) * min + amt * max
 end


-- FUEL ALARM--

alarmset = false

RegisterNetEvent("CarFuelAlarm")
AddEventHandler("CarFuelAlarm",function()
    if not alarmset then
        alarmset = true
        local i = 5
        TriggerEvent("DoLongHudText", "Low fuel.",1)
        while i > 0 do
            PlaySound(-1, "5_SEC_WARNING", "HUD_MINI_GAME_SOUNDSET", 0, 0, 1)
            i = i - 1
            Citizen.Wait(6000)
        end
        Citizen.Wait(9000)
        alarmset = false
    end
end)



Citizen.CreateThread(function()

    while true do

        Citizen.Wait(250)
        local player = PlayerPedId()

        if (IsPedInAnyVehicle(player, false)) then

            local veh = GetVehiclePedIsIn(player,false)

                if Fuel < 20 then
                  --  print(Fuel)
                    if not IsThisModelABike(GetEntityModel(veh)) then
                        TriggerEvent("CarFuelAlarm")
                    end
                else
                            if Fuel < 10 then
                                --print(Fuel)
                                if not IsThisModelABike(GetEntityModel(veh)) then
                                    TriggerEvent("CarFuelAlarm")
                                end
                    end
                end
            end
        end
    end)


Bunu komple kendi client side'ın ile değiştir ve tekrar dene en son bunda anlık olarak güncelliyor olması gerek.

Eski bir eklenti en son öyle olması gerekiyor emin değilim o şekilde çalışmıyor da olabilir.
 
DF
JavaScript:
local seatbeltInput = 311                   -- Toggle seatbelt on/off with K or DPAD down (controller)
local seatbeltPlaySound = true              -- Play seatbelt sound
local seatbeltDisableExit = true            -- Disable vehicle exit when seatbelt is enabled
local seatbeltEjectSpeed = 45.0             -- Speed threshold to eject player (MPH)
local seatbeltEjectAccel = 100.0            -- Acceleration threshold to eject player (G's)
local seatbeltColorOn = {160, 255, 160}     -- Color used when seatbelt is on
local seatbeltColorOff = {255, 96, 96}      -- Color used when seatbelt is off
DecorRegister("_FUEL_LEVEL",3)
Fuel = 0
local gasStations = {
    {179.8573, 6602.839, 31.86817,600},
}

function getVehicleInDirection(coordFrom, coordTo)
    local offset = 0
    local rayHandle
    local vehicle

    for i = 0, 100 do
        rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z + offset, 10, PlayerPedId(), 0)  
        a, b, c, d, vehicle = GetRaycastResult(rayHandle)
       
        offset = offset - 1

        if vehicle ~= 0 then break end
    end
   
    local distance = Vdist2(coordFrom, GetEntityCoords(vehicle))
   
    if distance > 3000 then vehicle = nil end

    return vehicle ~= nil and vehicle or 0
end
local pedInVeh = false
local seatbeltIsOn = false
Citizen.CreateThread(function()
    local currSpeed = 0.0
    while true do
        Citizen.Wait(0)
        local player = GetPlayerPed(-1)
        local position = GetEntityCoords(player)
        local vehicle = GetVehiclePedIsIn(player, false)

        -- Set vehicle states
        if IsPedInAnyVehicle(player, false) then
            pedInVeh = true
        else
            -- Reset states when not in car
            pedInVeh = false
            cruiseIsOn = false
            seatbeltIsOn = false
        end
        local vehicleClass = GetVehicleClass(vehicle)
        if pedInVeh and vehicleClass ~= 13 then
            local prevSpeed = currSpeed
            currSpeed = GetEntitySpeed(vehicle)

            -- Set PED flags
            SetPedConfigFlag(PlayerPedId(), 32, true)
            if IsControlJustReleased(0, seatbeltInput) and (enableController or GetLastInputMethod(0)) and vehicleClass ~= 8 then
                -- Toggle seatbelt status and play sound when enabled
                seatbeltIsOn = not seatbeltIsOn
                if seatbeltPlaySound then
                    PlaySoundFrontend(-1, "Faster_Click", "RESPAWN_ONLINE_SOUNDSET", 1)
                end
            end
            if not seatbeltIsOn then
                -- Eject PED when moving forward, vehicle was going over 45 MPH and acceleration over 100 G's
                local vehIsMovingFwd = GetEntitySpeedVector(vehicle, true).y > 1.0
                local vehAcc = (prevSpeed - currSpeed) / GetFrameTime()
                if (vehIsMovingFwd and (prevSpeed > (seatbeltEjectSpeed/2.237)) and (vehAcc > (seatbeltEjectAccel*9.81))) then
                    SetEntityCoords(player, position.x, position.y, position.z - 0.47, true, true, true)
                    SetEntityVelocity(player, prevVelocity.x, prevVelocity.y, prevVelocity.z)
                    Citizen.Wait(1)
                    SetPedToRagdoll(player, 1000, 1000, 0, 0, 0, 0)
                else
                    -- Update previous velocity for ejecting player
                    prevVelocity = GetEntityVelocity(vehicle)
                end
            elseif seatbeltDisableExit then
                -- Disable vehicle exit when seatbelt is on
                DisableControlAction(0, 75)
            end
            Citizen.Wait(0)
        else
            Citizen.Wait(400)
        end
    end
end)


function TargetVehicle()
    playerped = PlayerPedId()
    coordA = GetEntityCoords(playerped, 1)
    coordB = GetOffsetFromEntityInWorldCoords(playerped, 0.0, 100.0, 0.0)
    targetVehicle = getVehicleInDirection(coordA, coordB)
    return targetVehicle
end

function TargetVehicle()
    playerped = PlayerPedId()
    coordA = GetEntityCoords(playerped, 1)
    coordB = GetOffsetFromEntityInWorldCoords(playerped, 0.0, 100.0, 0.0)
    targetVehicle = getVehicleInDirection(coordA, coordB)
    return targetVehicle
end




function round( n )
    return math.floor( n + 0.5 )
end

function drawTxt(x,y ,width,height,scale, text, r,g,b,a)
    SetTextFont(4)
    SetTextProportional(0)
    SetTextScale(scale, scale)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(2, 0, 0, 0, 255)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(x - width/2, y - height/2 + 0.005)
end

local zoneNames = {
AIRP = "Los Santos International Airport",
ALAMO = "Alamo Sea",
ALTA = "Alta",
ARMYB = "Fort Zancudo",
BANHAMC = "Banham Canyon Dr",
BANNING = "Banning",
BAYTRE = "Baytree Canyon",
BEACH = "Vespucci Beach",
BHAMCA = "Banham Canyon",
BRADP = "Braddock Pass",
BRADT = "Braddock Tunnel",
BURTON = "Burton",
CALAFB = "Calafia Bridge",
CANNY = "Raton Canyon",
CCREAK = "Cassidy Creek",
CHAMH = "Chamberlain Hills",
CHIL = "Vinewood Hills",
CHU = "Chumash",
CMSW = "Chiliad Mountain State Wilderness",
CYPRE = "Cypress Flats",
DAVIS = "Davis",
DELBE = "Del Perro Beach",
DELPE = "Del Perro",
DELSOL = "La Puerta",
DESRT = "Grand Senora Desert",
DOWNT = "Downtown",
DTVINE = "Downtown Vinewood",
EAST_V = "East Vinewood",
EBURO = "El Burro Heights",
ELGORL = "El Gordo Lighthouse",
ELYSIAN = "Elysian Island",
GALFISH = "Galilee",
GALLI = "Galileo Park",
golf = "GWC and Golfing Society",
GRAPES = "Grapeseed",
GREATC = "Great Chaparral",
HARMO = "Harmony",
HAWICK = "Hawick",
HORS = "Vinewood Racetrack",
HUMLAB = "Humane Labs and Research",
JAIL = "Bolingbroke Penitentiary",
KOREAT = "Little Seoul",
LACT = "Land Act Reservoir",
LAGO = "Lago Zancudo",
LDAM = "Land Act Dam",
LEGSQU = "Legion Square",
LMESA = "La Mesa",
LOSPUER = "La Puerta",
MIRR = "Mirror Park",
MORN = "Morningwood",
MOVIE = "Richards Majestic",
MTCHIL = "Mount Chiliad",
MTGORDO = "Mount Gordo",
MTJOSE = "Mount Josiah",
MURRI = "Murrieta Heights",
NCHU = "North Chumash",
NOOSE = "N.O.O.S.E",
OCEANA = "Pacific Ocean",
PALCOV = "Paleto Cove",
PALETO = "Paleto Bay",
PALFOR = "Paleto Forest",
PALHIGH = "Palomino Highlands",
PALMPOW = "Palmer-Taylor Power Station",
PBLUFF = "Pacific Bluffs",
PBOX = "Pillbox Hill",
PROCOB = "Procopio Beach",
RANCHO = "Rancho",
RGLEN = "Richman Glen",
RICHM = "Richman",
ROCKF = "Rockford Hills",
RTRAK = "Redwood Lights Track",
SanAnd = "San Andreas",
SANCHIA = "San Chianski Mountain Range",
SANDY = "Sandy Shores",
SKID = "Mission Row",
SLAB = "Stab City",
STAD = "Maze Bank Arena",
STRAW = "Strawberry",
TATAMO = "Tataviam Mountains",
TERMINA = "Terminal",
TEXTI = "Textile City",
TONGVAH = "Tongva Hills",
TONGVAV = "Tongva Valley",
VCANA = "Vespucci Canals",
VESP = "Vespucci",
VINE = "Vinewood",
WINDF = "Ron Alternates Wind Farm",
WVINE = "West Vinewood",
ZANCUDO = "Zancudo River",
ZP_ORT = "Port of South Los Santos",
ZQ_UAR = "Davis Quartz"
}

-- CONFIG --
local showCompass = true
-- CODE --
local compass = "Loading GPS"

local lastStreet = nil
local lastStreetName = ""
local zone = "Unknown";

function playerLocation()
    return lastStreetName
end

function playerZone()
    return zone
end

-- Thanks @marxy
function getCardinalDirectionFromHeading(heading)
    if heading >= 315 or heading < 45 then
        return "North Bound"
    elseif heading >= 45 and heading < 135 then
        return "West Bound"
    elseif heading >=135 and heading < 225 then
        return "South Bound"
    elseif heading >= 225 and heading < 315 then
        return "East Bound"
    end
end

local seatbelt = false
RegisterNetEvent("seatbelt")
AddEventHandler("seatbelt", function(belt)
    seatbelt = belt
end)

local time = "12:00"
RegisterNetEvent("timeheader")
AddEventHandler("timeheader", function(h,m)
    if h < 10 then
        h = "0"..h
    end
    if m < 10 then
        m = "0"..m
    end
    time = h .. ":" .. m
end)



local counter = 0
local Mph = GetEntitySpeed(GetVehiclePedIsIn(PlayerPedId(), false)) * 3.6
local Fuel = 0.0
local uiopen = false
local colorblind = false
local compass_on = false

RegisterNetEvent('option:colorblind')
AddEventHandler('option:colorblind',function()
    colorblind = not colorblind
end)

Citizen.CreateThread(function()
    local x, y, z = table.unpack(GetEntityCoords(PlayerPedId(), true))
    local currentStreetHash, intersectStreetHash = GetStreetNameAtCoord(x, y, z, currentStreetHash, intersectStreetHash)
    currentStreetName = GetStreetNameFromHashKey(currentStreetHash)
    intersectStreetName = GetStreetNameFromHashKey(intersectStreetHash)
    zone = tostring(GetNameOfZone(x, y, z))
    playerStreetsLocation = zoneNames[tostring(zone)]

    if not zone then
        zone = "UNKNOWN"
        zoneNames['UNKNOWN'] = zone
    elseif not zoneNames[tostring(zone)] then
        local undefinedZone = zone .. " " .. x .. " " .. y .. " " .. z
        zoneNames[tostring(zone)] = "Undefined Zone"
    end

    if intersectStreetName ~= nil and intersectStreetName ~= "" then
        playerStreetsLocation = currentStreetName .. " | " .. intersectStreetName .. " | [" .. zoneNames[tostring(zone)] .. "]"
    elseif currentStreetName ~= nil and currentStreetName ~= "" then
        playerStreetsLocation = currentStreetName .. " | [" .. zoneNames[tostring(zone)] .. "]"
    else
        playerStreetsLocation = "[" .. zoneNames[tostring(zone)] .. "]"
    end

    while true do
        Citizen.Wait(10)
        local player = PlayerPedId()
        local x, y, z = table.unpack(GetEntityCoords(player, true))
        local currentStreetHash, intersectStreetHash = GetStreetNameAtCoord(x, y, z, currentStreetHash, intersectStreetHash)
        currentStreetName = GetStreetNameFromHashKey(currentStreetHash)
        intersectStreetName = GetStreetNameFromHashKey(intersectStreetHash)
        zone = tostring(GetNameOfZone(x, y, z))
        playerStreetsLocation = zoneNames[tostring(zone)]

        if not zone then
            zone = "UNKNOWN"
            zoneNames['UNKNOWN'] = zone
        elseif not zoneNames[tostring(zone)] then
            local undefinedZone = zone .. " " .. x .. " " .. y .. " " .. z
            zoneNames[tostring(zone)] = "Undefined Zone"
        end

        if intersectStreetName ~= nil and intersectStreetName ~= "" then
            playerStreetsLocation = currentStreetName .. " | " .. intersectStreetName .. " | [" .. zoneNames[tostring(zone)] .. "]"
        elseif currentStreetName ~= nil and currentStreetName ~= "" then
            playerStreetsLocation = currentStreetName .. " | [" .. zoneNames[tostring(zone)] .. "]"
        else
            playerStreetsLocation = "[".. zoneNames[tostring(zone)] .. "]"
        end
        -- compass = getCardinalDirectionFromHeading(math.floor(GetEntityHeading(player) + 0.5))
        -- street = compass .. " | " .. playerStreetsLocation
        street = playerStreetsLocation

        if IsVehicleEngineOn(GetVehiclePedIsIn(player, false)) then        

            if not uiopen then
                uiopen = true
                SendNUIMessage({
                  open = 1,
                })
            end
            local playerPed = PlayerPedId()
            local vehicle = GetVehiclePedIsIn(playerPed, false)
            Fuel = exports["np-fuel"]:GetFuel(vehicle)
            Mph = math.ceil(GetEntitySpeed(GetVehiclePedIsIn(player, false)) * 3.6)
            local hours = GetClockHours()
            if string.len(tostring(hours)) == 1 then
                trash = '0'..hours
            else
                trash = hours
            end
   
            local mins = GetClockMinutes()
            if string.len(tostring(mins)) == 1 then
                mins = '0'..mins
            else
                mins = mins
            end


            SendNUIMessage({
              open = 2,
              mph = Mph,
              fuel = math.ceil(Fuel),
              street = street,
              belt = seatbeltIsOn,
              time = hours .. ':' .. mins,
              colorblind = colorblind
            })

        else

            if uiopen and not compass_on then
                SendNUIMessage({
                  open = 3,
                })

                uiopen = false
            end

            compass_on = false
        end


RegisterNetEvent('carHud:compass')
AddEventHandler('carHud:compass', function(table)
        compass_on = not compass_on
    end)
    RegisterNetEvent('carHud:compassoff')
AddEventHandler('carHud:compassoff', function(table)
        compass_on = false
    end)
local IsPedInVehicle = false
if IsPedInVehicle ~= false then
TriggerClientEvent('carHud:compassoff')
        end
    end
end)


Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1)
        local player = PlayerPedId()
        if IsVehicleEngineOn(GetVehiclePedIsIn(player, false)) then
            -- in vehicle
            SendNUIMessage({
                open = 2,
                direction = math.floor(calcHeading(-GetEntityHeading(player) % 360)),
            })
        elseif compass_on == true then
            -- has compass toggled
            if not uiopen then
                uiopen = true
                SendNUIMessage({
                  open = 1,
                })
            end

            SendNUIMessage({
                open = 4,
                time = time,
                direction = math.floor(calcHeading(-GetEntityHeading(player) % 360)),
            })
           
        else
            Citizen.Wait(1000)
        end
    end
end)

Controlkey = {["generalUse"] = {38,"E"}}
RegisterNetEvent('event:control:update')
AddEventHandler('event:control:update', function(table)
    Controlkey["generalUse"] = table["generalUse"]
end)




---------------------------------
-- Compass shit
---------------------------------

--[[
    Heavy Math Calcs
]]--

local imageWidth = 100 -- leave this variable, related to pixel size of the directions
local containerWidth = 100 -- width of the image container

-- local width =  (imageWidth / containerWidth) * 100; -- used to convert image width if changed
local width =  0;
local south = (-imageWidth) + width
local west = (-imageWidth * 2) + width
local north = (-imageWidth * 3) + width
local east = (-imageWidth * 4) + width
local south2 = (-imageWidth * 5) + width

function calcHeading(direction)
     if (direction < 90) then
         return lerp(north, east, direction / 90)
     elseif (direction < 180) then
         return lerp(east, south2, rangePercent(90, 180, direction))
     elseif (direction < 270) then
         return lerp(south, west, rangePercent(180, 270, direction))
     elseif (direction <= 360) then
         return lerp(west, north, rangePercent(270, 360, direction))
     end
end


function rangePercent(min, max, amt)
     return (((amt - min) * 100) / (max - min)) / 100
end

function lerp(min, max, amt)
     return (1 - amt) * min + amt * max
end


-- FUEL ALARM--

alarmset = false

RegisterNetEvent("CarFuelAlarm")
AddEventHandler("CarFuelAlarm",function()
    if not alarmset then
        alarmset = true
        local i = 5
        TriggerEvent("DoLongHudText", "Low fuel.",1)
        while i > 0 do
            PlaySound(-1, "5_SEC_WARNING", "HUD_MINI_GAME_SOUNDSET", 0, 0, 1)
            i = i - 1
            Citizen.Wait(6000)
        end
        Citizen.Wait(9000)
        alarmset = false
    end
end)



Citizen.CreateThread(function()

    while true do

        Citizen.Wait(250)
        local player = PlayerPedId()

        if (IsPedInAnyVehicle(player, false)) then

            local veh = GetVehiclePedIsIn(player,false)

                if Fuel < 20 then
                  --  print(Fuel)
                    if not IsThisModelABike(GetEntityModel(veh)) then
                        TriggerEvent("CarFuelAlarm")
                    end
                else
                            if Fuel < 10 then
                                --print(Fuel)
                                if not IsThisModelABike(GetEntityModel(veh)) then
                                    TriggerEvent("CarFuelAlarm")
                                end
                    end
                end
            end
        end
    end)


Bunu komple kendi client side'ın ile değiştir ve tekrar dene en son bunda anlık olarak güncelliyor olması gerek.

Eski bir eklenti en son öyle olması gerekiyor emin değilim o şekilde çalışmıyor da olabilir.
hud bozuluyor direkt gözükmüyor hud
 
DF
Kullandığınız sürüm farklı o halde lakin citizen.wait(x) kısmında doğru yeri düşürüp eklentiyi yeniden başlattığınızda sorununuz kalmayacaktır denemeye devam edin tek tek.
citizen.wait olarak arattığım herşeyi 1 yaptım scripti restartladım sonrasında denedim olmadı ctrl z yaptım gene arattım bunu hepsine yaptım fakat olumlu bir sonuş elde edemedim
 
DF
Konu eki tarafımca değiştirilmiştir.
 
DF
halen yardıma ihtiyacım var sorunum çözülmedi :/ +up
 
DF
Kanka çok merak ettiğimden soruyorum.
Bu kadar basit bir olayı bilmiyorken


Bu motel sistemini yapabilmen garip açıkcası ?

Ayrıca sorunu çözebilmem için lütfen scriptin clientsideını kod olarak ekler misin?
 
DF
Kanka çok merak ettiğimden soruyorum.
Bu kadar basit bir olayı bilmiyorken


Bu motel sistemini yapabilmen garip açıkcası ?

Ayrıca sorunu çözebilmem için lütfen scriptin clientsideını kod olarak ekler misin?
arkadaşımdan yardım alarak yaptığımı oraya bırakmışım ve buglarını çözemediğim için paylaşmadım
 
DF
Son düzenleme:
arkadaşımdan yardım alarak yaptığımı oraya bırakmışım ve buglarını çözemediğim için paylaşmadım neyse client sidesi bu

Kod:
ESX = nil

local Keys = {
    ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
    ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
    ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
    ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
    ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
    ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
    ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
    ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
    ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}

Citizen.CreateThread(function()
    while ESX == nil do
        TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
        Citizen.Wait(0)
    end
end)

-- gas filling
DecorRegister("CurrentFuel", 3)
Fuel = 0
local gasStations = {
    {49.41872, 2778.793, 58.04395,600},
    {263.8949, 2606.463, 44.98339,600},
    {1039.958, 2671.134, 39.55091,900},
    {1207.26, 2660.175, 37.89996,900},
    {2539.685, 2594.192, 37.94488,1500},
    {2679.858, 3263.946, 55.24057,1500},
    {2005.055, 3773.887, 32.40393,1200},
    {1687.156, 4929.392, 42.07809,900},
    {1701.314, 6416.028, 32.76395,1200},
    {179.8573, 6602.839, 31.86817,600},
    {-94.46199, 6419.594, 31.48952,600},
    {-2554.996, 2334.402, 33.07803,600},
    {-1800.375, 803.6619, 138.6512,600},
    {-1437.622, -276.7476, 46.20771,600},
    {-2096.243, -320.2867, 13.16857,600},
    {-724.6192, -935.1631, 19.21386,600},
    {-526.0198, -1211.003, 18.18483,600},
    {-70.21484, -1761.792, 29.53402,600},
    {265.6484,-1261.309, 29.29294,600},
    {819.6538,-1028.846, 26.40342,780},
    {1208.951,-1402.567, 35.22419,900},
    {1181.381,-330.8471, 69.31651,900},
    {620.8434, 269.1009, 103.0895,780},
    {2581.321, 362.0393, 108.4688,1500},
    {1785.363, 3330.372, 41.38188,1200},
    {-319.537, -1471.5116, 30.54118,600},
    {-66.58, -2532.56, 6.14, 400}
}

function getVehicleInDirection(coordFrom, coordTo)
    local offset = 0
    local rayHandle
    local vehicle

    for i = 0, 100 do
        rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z + offset, 10, PlayerPedId(), 0)  
        a, b, c, d, vehicle = GetRaycastResult(rayHandle)
       
        offset = offset - 1

        if vehicle ~= 0 then break end
    end
   
    local distance = Vdist2(coordFrom, GetEntityCoords(vehicle))
   
    if distance > 3000 then vehicle = nil end

    return vehicle ~= nil and vehicle or 0
end
local showGasStations = false

RegisterNetEvent('CarPlayerHud:ToggleGas')
AddEventHandler('CarPlayerHud:ToggleGas', function()
    showGasStations = not showGasStations
   for _, item in pairs(gasStations) do
        if not showGasStations then
            if item.blip ~= nil then
                RemoveBlip(item.blip)
            end
        else
            item.blip = AddBlipForCoord(item[1], item[2], item[3])
            SetBlipSprite(item.blip, 361)
            SetBlipScale(item.blip, 0.7)
            SetBlipAsShortRange(item.blip, true)
            BeginTextCommandSetBlipName("STRING")
            AddTextComponentString("Gas")
            EndTextCommandSetBlipName(item.blip)
        end
    end
end)

Citizen.CreateThread(function()
    showGasStations = true
    TriggerEvent('CarPlayerHud:ToggleGas')
end)

function DisplayHelpText(str)
    SetTextComponentFormat("STRING")
    AddTextComponentString(str)
    DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end

function TargetVehicle()
    playerped = PlayerPedId()
    coordA = GetEntityCoords(playerped, 1)
    coordB = GetOffsetFromEntityInWorldCoords(playerped, 0.0, 100.0, 0.0)
    targetVehicle = getVehicleInDirection(coordA, coordB)
    return targetVehicle
end

function IsNearGasStations()
    local location = {}
    local hasFound = false
    local pos = GetEntityCoords(PlayerPedId(), false)
    for k,v in ipairs(gasStations) do
        if(Vdist(v[1], v[2], v[3], pos.x, pos.y, pos.z) < 22.0)then
            location = {v[1], v[2], v[3],v[4]}
            hasFound = true
        end
    end

    if hasFound then return location,true end
    return {},false
end

RegisterNetEvent("RefuelCar")
AddEventHandler("RefuelCar",function()
    local w = `WEAPON_PetrolCan`
    local curw = GetSelectedPedWeapon(PlayerPedId())
    if curw == w then
        coordA = GetEntityCoords(PlayerPedId(), 1)
        coordB = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 100.0, 0.0)
        targetVehicle = getVehicleInDirection(coordA, coordB)
        if DoesEntityExist(targetVehicle) then
            SetPedAmmo( PlayerPedId(), GetSelectedPedWeapon(PlayerPedId()), 0 )

            if DecorExistOn(targetVehicle, "CurrentFuel") then
                curFuel = DecorGetInt(targetVehicle, "CurrentFuel")
               
                curFuel = curFuel + 30
                if curFuel > 100 then
                    curFuel = 100
                end
                DecorSetInt(targetVehicle, "CurrentFuel", curFuel)
            else
                DecorSetInt(targetVehicle, "CurrentFuel", 50)
            end

            DecorSetInt(targetVehicle, "CurrentFuel", 100)
            TriggerEvent("notification","Refueled",1)
        else
            TriggerEvent("notification","No Target",2)
        end
    else
        TriggerEvent("notification","Need a Gas Can",2)
    end
end)

RegisterNetEvent("RefuelCarServerReturn")
AddEventHandler("RefuelCarServerReturn",function()

    local timer = (100 - curFuel) * 400
    refillVehicle()
    local finished = exports["taskbar"]:taskBar(timer,"Refueling")
    local veh = TargetVehicle()

    if finished == 100 then
        DecorSetInt(veh, "CurrentFuel", 100)
    else

        local curFuel = DecorGetInt(veh, "CurrentFuel")
        local endFuel = (100 - curFuel)
        endFuel = math.ceil(endFuel * (finished / 100) + curFuel)
        DecorSetInt(veh, "CurrentFuel", endFuel)

    end
    endanimation()
    TriggerEvent('notification', 'You paid $' .. round(costs) .. ' for your fuel')
end)

local petrolCan = {title = "Petrol Can", name = "PetrolCan", costs = 100, description = {}, model = "WEAPON_PetrolCan"}

function refillVehicle()
    ClearPedSecondaryTask(PlayerPedId())
    loadAnimDict( "weapon@w_sp_jerrycan" )
    TaskPlayAnim( PlayerPedId(), "weapon@w_sp_jerrycan", "fire", 8.0, 1.0, -1, 1, 0, 0, 0, 0 )
end

function endanimation()
    shiftheld = false
    ctrlheld = false
    tabheld = false
    ClearPedTasksImmediately(PlayerPedId())
end

function loadAnimDict( dict )
    while ( not HasAnimDictLoaded( dict ) ) do
        RequestAnimDict( dict )
        Citizen.Wait( 5 )
    end
end

function TargetVehicle()
    playerped = PlayerPedId()
    coordA = GetEntityCoords(playerped, 1)
    coordB = GetOffsetFromEntityInWorldCoords(playerped, 0.0, 100.0, 0.0)
    targetVehicle = getVehicleInDirection(coordA, coordB)
    return targetVehicle
end

function round( n )
    return math.floor( n + 0.5 )
end

Fuel = 45
DrivingSet = false
LastVehicle = nil
lastupdate = 0
local fuelMulti = 0

RegisterNetEvent("carHud:FuelMulti")
AddEventHandler("carHud:FuelMulti",function(multi)
    fuelMulti = multi
end)

alarmset = false

RegisterNetEvent("CarFuelAlarm")
AddEventHandler("CarFuelAlarm",function()
    if not alarmset then
        alarmset = true
        local i = 5
        TriggerEvent("notification", "Benzin Az.",1)
        while i > 0 do
            PlaySound(-1, "5_SEC_WARNING", "HUD_MINI_GAME_SOUNDSET", 0, 0, 1)
            i = i - 1
            Citizen.Wait(300)
        end
        Citizen.Wait(60000)
        alarmset = false
    end
end)

function drawTxt(x,y ,width,height,scale, text, r,g,b,a)
    SetTextFont(4)
    SetTextProportional(0)
    SetTextScale(scale, scale)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(2, 0, 0, 0, 255)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(x - width/2, y - height/2 + 0.005)
end

-- CONFIG --
local showCompass = true
-- CODE --
local compass = "GPS Yükleniyor."

local lastStreet = nil
local lastStreetName = ""
local zone = "Unknown";

function playerLocation()
    return lastStreetName
end

function playerZone()
    return zone
end

-- Thanks @marxy
function getCardinalDirectionFromHeading(heading)
    if heading >= 315 or heading < 45 then
        return "North Bound"
    elseif heading >= 45 and heading < 135 then
        return "West Bound"
    elseif heading >=135 and heading < 225 then
        return "South Bound"
    elseif heading >= 225 and heading < 315 then
        return "East Bound"
    end
end

local seatbelt = false
RegisterNetEvent("seatbelt")
AddEventHandler("seatbelt", function(belt)
    seatbelt = belt
end)

local nos = 0
local nosEnabled = false
RegisterNetEvent("noshud")
AddEventHandler("noshud", function(_nos, _nosEnabled)
    if _nos == nil then
        nos = 0
    else
        nos = _nos
    end
    nosEnabled = _nosEnabled
end)

RegisterNetEvent("np-jobmanager:playerBecameJob")
AddEventHandler("np-jobmanager:playerBecameJob", function(job, name)
    if job ~= "police" then isCop = false else isCop = true end
end)

local time = "12:00"
RegisterNetEvent("timeheader2")
AddEventHandler("timeheader2", function(h,m)
    if h < 10 then
        h = "0"..h
    end
    if m < 10 then
        m = "0"..m
    end
    time = h .. ":" .. m
end)

local counter = 0
local Mph = GetEntitySpeed(GetVehiclePedIsIn(PlayerPedId(), false)) * 3.6 --
local uiopen = false
local colorblind = false
local compass_on = false

RegisterNetEvent('option:colorblind')
AddEventHandler('option:colorblind',function()
    colorblind = not colorblind
end)

Citizen.CreateThread(function()
   
    local x, y, z = table.unpack(GetEntityCoords(PlayerPedId(), true))
    local currentStreetHash, intersectStreetHash = GetStreetNameAtCoord(x, y, z, currentStreetHash, intersectStreetHash)
    currentStreetName = GetStreetNameFromHashKey(currentStreetHash)
    intersectStreetName = GetStreetNameFromHashKey(intersectStreetHash)
    zone = tostring(GetNameOfZone(x, y, z))
    local area = GetLabelText(zone)
    playerStreetsLocation = area

    if not zone then
        zone = "UNKNOWN"
    end

    if intersectStreetName ~= nil and intersectStreetName ~= "" then
        playerStreetsLocation = currentStreetName .. " | " .. intersectStreetName .. " | [" .. area .. "]"
    elseif currentStreetName ~= nil and currentStreetName ~= "" then
        playerStreetsLocation = currentStreetName .. " | [" .. area .. "]"
    else
        playerStreetsLocation = "[" .. area .. "]"
    end

    while true do
        Citizen.Wait(500)
        local player = PlayerPedId()
        local x, y, z = table.unpack(GetEntityCoords(player, true))
        local currentStreetHash, intersectStreetHash = GetStreetNameAtCoord(x, y, z, currentStreetHash, intersectStreetHash)
        currentStreetName = GetStreetNameFromHashKey(currentStreetHash)
        intersectStreetName = GetStreetNameFromHashKey(intersectStreetHash)
        zone = tostring(GetNameOfZone(x, y, z))
        local area = GetLabelText(zone)
        playerStreetsLocation = area

        if not zone then
            zone = "UNKNOWN"
        end

        if intersectStreetName ~= nil and intersectStreetName ~= "" then
            playerStreetsLocation = currentStreetName .. " | " .. intersectStreetName .. " | [" .. area .. "]"
        elseif currentStreetName ~= nil and currentStreetName ~= "" then
            playerStreetsLocation = currentStreetName .. " | [" .. area .. "]"
        else
            playerStreetsLocation = "[".. area .. "]"
        end
        -- compass = getCardinalDirectionFromHeading(math.floor(GetEntityHeading(player) + 0.5))
        -- street = compass .. " | " .. playerStreetsLocation
        street = playerStreetsLocation
        local veh = GetVehiclePedIsIn(player, false)
        if IsVehicleEngineOn(veh) then        

            if not uiopen then
                uiopen = true
                SendNUIMessage({
                  open = 1,
                })
            end

             Mph = math.ceil(GetEntitySpeed(GetVehiclePedIsIn(player, false)) * 3.6) -- Elleme arttırırsan aracın 100le gitse bile 200 olarak gösterir
           
             local hours = GetClockHours()
            if string.len(tostring(hours)) == 1 then
                trash = '0'..hours
            else
                trash = hours
            end
   
            local mins = GetClockMinutes()
            if string.len(tostring(mins)) == 1 then
                mins = '0'..mins
            else
                mins = mins
            end
           
            local atl = false
            if IsPedInAnyPlane(player) or IsPedInAnyHeli(player) then
                atl = string.format("%.1f", GetEntityHeightAboveGround(veh) * 3.28084)
            end
            local engine = false
            if GetVehicleEngineHealth(veh) < 400.0 then
                engine = true
            end
            local GasTank = false
            if GetVehiclePetrolTankHealth(veh) < 3002.0 then
                GasTank = true
            end
            SendNUIMessage({
              open = 2,
              mph = Mph,
              fuel = math.ceil(Fuel),
              street = street,
              belt = seatbelt,
              nos = nos,
              nosEnabled = nosEnabled,
              time = hours .. ':' .. mins,
              colorblind = colorblind,
              atl = atl,
              engine = engine,
              GasTank = GasTank,
            })
        else

            if uiopen and not compass_on then
                SendNUIMessage({
                  open = 3,
                })
                uiopen = false
            end
        end
    end
end)

local seatbelt = false

Citizen.CreateThread(function()
    local currSpeed = 0
    local prevVelocity = { x = 0.0, y = 0.0, z = 0.0 }
    while true do
        Citizen.Wait(0)
        local prevSpeed = currSpeed
        local position = GetEntityCoords(player)
        currSpeed = GetEntitySpeed(veh)
        if not seatbelt then
            local vehIsMovingFwd = GetEntitySpeedVector(veh, true).y > 1.0
            local vehAcc = (prevSpeed - currSpeed) / GetFrameTime()
            if (vehIsMovingFwd and (prevSpeed > seatbeltEjectSpeed) and (vehAcc > (seatbeltEjectAccel * 9.81))) then
                SetEntityCoords(player, position.x, position.y, position.z - 0.47, true, true, true)
                SetEntityVelocity(player, prevVelocity.x, prevVelocity.y, prevVelocity.z)
                Citizen.Wait(1)
                SetPedToRagdoll(player, 1000, 1000, 0, 0, 0, 0)
            else
                prevVelocity = GetEntityVelocity(veh)
            end
        else
            DisableControlAction(0, 75)
        end
    end
end)

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if IsControlJustReleased(0, 311) and IsPedInAnyVehicle(PlayerPedId()) then
             if seatbelt == false then
                TriggerEvent("seatbelt",true)
                TriggerEvent("InteractSound_CL:PlayOnOne","buckle",0.5)
                TriggerEvent('mythic_notify:client:SendAlert', { type = 'inform', text = 'Kemer takıldı'})
               
            else
                TriggerEvent("seatbelt",false)
                TriggerEvent("InteractSound_CL:PlayOnOne","unbuckle",0.5)
                TriggerEvent('mythic_notify:client:SendAlert', { type = 'inform', text = 'Kemer çıkarıldı'})
            end
            seatbelt = not seatbelt
        end
    end
end)

RegisterNetEvent('carHud:compass')
AddEventHandler('carHud:compass', function(table)
    compass_on = true
end)

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(50)
        local player = PlayerPedId()
        if IsVehicleEngineOn(GetVehiclePedIsIn(player, false)) then
            -- in vehicle
            SendNUIMessage({
                open = 2,
                direction = math.floor(calcHeading(-GetEntityHeading(player) % 360)),
            })
        elseif compass_on == true then
            -- has compass toggled
            if not uiopen then
                uiopen = true
                SendNUIMessage({
                  open = 1,
                })
            end
           
            local hours = GetClockHours()
            if string.len(tostring(hours)) == 1 then
                trash = '0'..hours
            else
                trash = hours
            end
   
            local mins = GetClockMinutes()
            if string.len(tostring(mins)) == 1 then
                mins = '0'..mins
            else
                mins = mins
            end

            SendNUIMessage({
                open = 4,
                time = hours .. ':' .. mins,
                direction = math.floor(calcHeading(-GetEntityHeading(player) % 360)),
            })
        else
            Citizen.Wait(1000)
        end
    end
end)

Citizen.CreateThread(function()

    while true do

        Citizen.Wait(250)
        local player = PlayerPedId()

        if (IsPedInAnyVehicle(player, false)) then

            local veh = GetVehiclePedIsIn(player,false)

            if GetPedInVehicleSeat(veh, -1) == player then

                if not DrivingSet then

                    if LastVehicle ~= veh then
                        if not DecorExistOn(veh, "CurrentFuel") then
                            Fuel = math.random(80,100)
                        else
                            Fuel = DecorGetInt(veh, "CurrentFuel")
                        end
                    else
                        Fuel = DecorGetInt(veh, "CurrentFuel")
                    end

                    DrivingSet = true
                    LastVehicle = veh
                    lastupdate = 0

                    if not DecorExistOn(veh, "CurrentFuel") then
                        Fuel = math.random(80,100)
                        DecorSetInt(veh, "CurrentFuel", round(Fuel))
                    end

                else

                    if Fuel > 105 then
                        Fuel = DecorGetInt(veh, "CurrentFuel")
                    end                    
                    if Fuel == 101 then
                        Fuel = DecorGetInt(veh, "CurrentFuel")
                    end
                end

                if ( lastupdate > 300) then
                    DecorSetInt(veh, "CurrentFuel", round(Fuel))
                    lasteupdate = 0
                end

                lastupdate = lastupdate + 1

                if Fuel > 0 then
                    if IsVehicleEngineOn(veh) then
                        local fueltankhealth = GetVehiclePetrolTankHealth(veh)
                        if fueltankhealth == 1000.0 then
                            SetVehiclePetrolTankHealth(veh, 4000.0)
                        end
                        local algofuel = GetEntitySpeed(GetVehiclePedIsIn(player, false)) * 3.6
                        if algofuel > 160 then
                            algofuel = algofuel * 1.8
                        else
                            algofuel = algofuel / 2.0
                        end
                        algofuel = algofuel / 15000

                        if algofuel == 0 then
                            algofuel = 0.0001
                        end

                        --TriggerEvent('chatMessage', '', { 0, 0, 0 }, '' .. algofuel .. '')
                        if IsPedInAnyBoat(PlayerPedId()) then
                            algofuel = 0.0090
                        end
                        if fuelMulti == 0 then fuelMulti = 1 end
                        local missingTankHealth = (4000 - fueltankhealth) / 1000

                        if missingTankHealth > 1 then
                            missingTankHealth = missingTankHealth * (missingTankHealth * missingTankHealth * 12)
                        end

                        local factorFuel = (algofuel + fuelMulti / 10000) * (missingTankHealth+1)
                        Fuel = Fuel - factorFuel
                    end
                end

                if Fuel <= 4 and Fuel > 0 then
                    if not IsThisModelABike(GetEntityModel(veh)) then
                        local decayChance = math.random(20,100)
                        if decayChance > 90 then
                            SetVehicleEngineOn(veh,0,0,1)
                            SetVehicleUndriveable(veh,true)
                            Citizen.Wait(100)
                            SetVehicleEngineOn(veh,1,0,1)
                            SetVehicleUndriveable(veh,false)
                        end
                    end
                   
                end

                if Fuel < 15 then
                    if not IsThisModelABike(GetEntityModel(veh)) then
                        TriggerEvent("CarFuelAlarm")
                    end
                end

                if Fuel < 1 then

                    if Fuel ~= 0 then
                        Fuel = 0
                        DecorSetInt(veh, "CurrentFuel", round(Fuel))
                    end

                    if IsVehicleEngineOn(veh) or IsThisModelAHeli(GetEntityModel(veh)) then
                        SetVehicleEngineOn(veh,0,0,1)
                        SetVehicleUndriveable(veh,false)
                    end
                end
            end
        else

            if DrivingSet then
                DrivingSet = false
                DecorSetInt(LastVehicle, "CurrentFuel", round(Fuel))
            end
            Citizen.Wait(1500)
        end
    end
end)

Controlkey = {["generalUse"] = {38,"E"}}
RegisterNetEvent('event:control:update')
AddEventHandler('event:control:update', function(table)
    Controlkey["generalUse"] = table["generalUse"]
end)

Citizen.CreateThread(function()
    local bool = false
    local counter = 0
    while true do

        if counter == 0 then
            loc,bool = IsNearGasStations()
            counter = 5
        end
        counter = counter - 1
        if bool == true then

            local veh = TargetVehicle()

            if DoesEntityExist(veh) and IsEntityAVehicle(veh) and #(GetEntityCoords(veh) - GetEntityCoords(PlayerPedId())) < 5.0 then

                curFuel = DecorGetInt(veh, "CurrentFuel")
                costs = (100 - curFuel)
                if costs < 0 then
                    costs = 0
                end
                info = string.format("Press ~g~"..Controlkey["generalUse"][2].."~s~ to refuel your vehicle | ~g~$%s + tax", costs)
                local crd = GetEntityCoords(veh)
                DrawMarker(2,crd["x"],crd["y"],crd["z"]+1.5, 0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, 100, 15, 15, 130, 0, 0, 0, 0)
                DisplayHelpText(info)
                if IsControlJustPressed(1, Controlkey["generalUse"][1]) then
                    if curFuel >= 100 then
                        PlaySound(-1, "5_Second_Timer", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS", 0, 0, 1)
                        TriggerEvent('notification', "Your gas tank is full", 2)
                    else
                        costs = math.ceil(costs)
                        TriggerServerEvent("carfill:checkmoney",costs,loc)
                    end
                end
            end
            Citizen.Wait(1)
        else
            Citizen.Wait(500)
        end
    end
end)

---------------------------------
-- Compass shit
---------------------------------

--[[
    Heavy Math Calcs
]]--

local imageWidth = 100 -- leave this variable, related to pixel size of the directions
local containerWidth = 100 -- width of the image container

-- local width =  (imageWidth / containerWidth) * 100; -- used to convert image width if changed
local width =  0;
local south = (-imageWidth) + width
local west = (-imageWidth * 2) + width
local north = (-imageWidth * 3) + width
local east = (-imageWidth * 4) + width
local south2 = (-imageWidth * 5) + width

function calcHeading(direction)
     if (direction < 90) then
         return lerp(north, east, direction / 90)
     elseif (direction < 180) then
         return lerp(east, south2, rangePercent(90, 180, direction))
     elseif (direction < 270) then
         return lerp(south, west, rangePercent(180, 270, direction))
     elseif (direction <= 360) then
         return lerp(west, north, rangePercent(270, 360, direction))
     end
end

function rangePercent(min, max, amt)
     return (((amt - min) * 100) / (max - min)) / 100
end

function lerp(min, max, amt)
     return (1 - amt) * min + amt * max
end
Konudaki yorum yapan herkes Citizen.Wait()'i yüksek olan yerleri küçük sayılara çek demiş sende çektim dedin fakat hala içinde Citizen.Wait(500), Citizen.Wait(250) gibi yerler mevcut ya insanlarla dalga geçiyorsun ya da bulamadın.
 
DF
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...

Forumdan daha fazla yararlanmak için giriş yapın yada üye olun!

Forumdan daha fazla yararlanmak için giriş yapın veya kayıt olun!

Kayıt ol

Forumda bir hesap oluşturmak tamamen ücretsizdir.

Şimdi kayıt ol
Giriş yap

Eğer bir hesabınız var ise lütfen giriş yapın

Giriş yap

Bu konuyu görüntüleyen kullanıcılar

Tema düzenleyici

Tema özelletirmeleri

Granit arka planlar

Lütfen Javascript'i etkinleştirin!Javascript'i etkinleştirin!
// Adblock Kod Start // // Adblock Kod End//