Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2021-10-02, 11:28


Pro3west1







Wiek: 26
Na forum: 2524 dni
Posty: 37
Nick w MP: hjkh



Respekt: 50

Witam, jak zrobi? aby licznik by? widziany przez kierowc? i pasa?er?w pojazdu?
Aktualnie jest widziany tylko przez kierowc?.
Pozdrawiam!

c.lua

local xguiGetScreenSize()

show_speed false

local smothedRotation 0

local indikator_1 "images/1.png"
local indikator_2 "images/2.png"
local indikator_3 "images/3.png"
local indikator_4 "images/4.png"
local indikator_5 "images/5.png"
local indikator_6 "images/6.png"
local indikator_7 "images/7.png"
local indikator_8 "images/8.png"

alpha 255

function fons ()
    if show_speed == false then

        local veh getPedOccupiedVehicle(getLocalPlayer()) 
        if not veh or getVehicleOccupant veh ) ~= localPlayer then return true end
        if not driveDistance then lastTick getTickCount() driveDistance getElementData veh"driveDistance" ) or 0 end

        local vehs getElementSpeed(getPedOccupiedVehicle(getLocalPlayer()), "kmh")
        local fuel getElementData(getPedOccupiedVehicle localPlayer ), "vehicle:fuel" ) or 0

        local rot math.floor(((270/9800)* getVehicleRPM(getPedOccupiedVehicle(getLocalPlayer()))) + 0.5)

        local actualspeed getElementSpeed (veh1)
        local kmh math.floor(actualspeed)
        
        local num getElementData(veh,"vehicle:mileage") or 0
        local mileage ""..math.floor(num)
        repeat mileage "0"..mileage until #mileage >= 7    
        
        if smothedRotation 252 then
            smothedRotation 252
        else
            if (smothedRotation rotthen
            smothedRotation smothedRotation 1.8
            end
            if (smothedRotation rotthen
                smothedRotation smothedRotation 1.8
            end
        end

        ------------------------------------------------------------------------------------------------------------------------------------------------------
        
        dxDrawImage(420230405198"images/fon.png"000tocolor(255,255,255,225))
        
        --dxDrawButtonText_pas(245240220220"КМ/Ч"0.300.30)
        
        --dxDrawImage(365184150150"images/odometr.png"smothedRotation 12800tocolor(255,255,255,225))
        --hou_straight288108144145tocolor(255,0,0200), 140smothedRotation+2,5)


        dxDrawButtonText_pas(241205220220mileage0.30.3)
        
        dxDrawButtonText_pas(245265220250kmh0.70.7)
        
        if kmh 405 then
        dxDrawImage(245220220220"images/spidometr.png", (-37) + kmh 1.6 00tocolor(255,255,255,225))
        hou_circle128128160160tocolor(0191255100), 277kmh 1.4,20)
        else
        --dxDrawImage(245220220220"images/spidometr.png", (-37) + 405 1.6 00tocolor(255,255,255,225))
        --hou_circle135112234235tocolor(208,64,64150), 232405 1.6,8)
        end
    --    outputChatBox(getElementSpeed(veh))
        ------------------------------------------------------------------------------------------------------------------------------------------------------
        
        --dxDrawImage(75504040indikator_7000tocolor(255,255,255,alpha))
        if getVehicleOverrideLightsveh ) == 2 then
            dxDrawImage(75504040indikator_8000tocolor(255,255,255,225))
            --alpha 0
        elseif getVehicleOverrideLightsveh ) == 1 then
            dxDrawImage(75504040indikator_7000tocolor(255,255,255,225))
            -- alpha 0
        end
        
        if getVehicleEngineState veh ) == false then
            dxDrawImage(210504040indikator_1000tocolor(255,255,255,225))
        elseif getVehicleEngineState veh ) == true then
            dxDrawImage(210504040indikator_2000tocolor(255,255,255,225))
        end
        if isVehicleLocked veh then    
            dxDrawImage(165504040indikator_3000tocolor(255,255,255,225))
        else
            dxDrawImage(165504040indikator_4000tocolor(255,255,255,225))
        end
        
        if getElementData(veh"cruize") == false then
            dxDrawImage(120504040indikator_5000tocolor(255,255,255,225))
        elseif getElementData(veh"cruize") == true then
            dxDrawImage(120504040indikator_6000tocolor(255,255,255,225))
        end

        
        hou_circle21585100100tocolor(0191255100), 360fuel 10.9,7) --85

        
    end
end
addEventHandler "onClientRender"getRootElement(), fons)

bindKey("4","down",function()
    triggerServerEvent"triggerVehicleSystem"localPlayer"engine" )
end)
--bindKey("3","down",function()
--    triggerServerEvent"triggerVehicleSystem"localPlayer"lights" )
--end)

function getVehicleRPM(vehicle)
local vehicleRPM 0
    if (vehiclethen  
        if (getVehicleEngineState(vehicle) == truethen
            if getVehicleCurrentGear(vehicle) > 0 then             
                vehicleRPM math.floor(((getElementSpeed(vehicle"kmh")/getVehicleCurrentGear(vehicle))*180) + 0.5) 
                if (vehicleRPM 650then
                    vehicleRPM math.random(650750)
                elseif (vehicleRPM >= 9800then
                    vehicleRPM math.random(98009900)
                end
            else
                vehicleRPM math.floor((getElementSpeed(vehicle"kmh")*180) + 0.5)
                if (vehicleRPM 650then
                    vehicleRPM math.random(650750)
                elseif (vehicleRPM >= 9800then
                    vehicleRPM math.random(98009900)
                end
            end
        else
            vehicleRPM 0
        end
        return tonumber(vehicleRPM)
    else
        return 0
    end
end

function getFormatSpeed(unit)
    if unit 10 then
        unit "00" .. unit
    elseif unit 100 then
        unit "0" .. unit
    elseif unit >= 1000 then
        unit "999"
    end
    return unit
end

--[[unction getElementSpeed(element,unit)
    if (unit == nilthen unit 0 end
    if (isElement(element)) then
        local x,y,getElementVelocity(element)
        if (unit=="mph" or unit==or unit =='1'then
            return math.floor((x^y^z^2) ^ 0.5 100)
        else
            return math.floor((x^y^z^2) ^ 0.5 100 1.609344)
        end
    else
        return false
    end
end]]

function getElementSpeed(theElementunit)
    -- Check arguments for errors
    assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
    local elementType getElementType(theElement)
    assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile""Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")")
    assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == or tonumber(unit) == or tonumber(unit) == 2)) or unit == "m/s" or unit == "kmh" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
    -- Default to m/if no unit specified and 'ignore' argument type if the string contains a number
    unit unit == nil and or ((not tonumber(unit)) and unit or tonumber(unit))
    -- Setup our multiplier to convert the velocity to the specified unit
    local mult = (unit == or unit == "m/s") and 50 or ((unit == or unit == "km/h") and 180 or 111.84681456)
    -- Return the speed by calculating the length of the velocity vectorafter converting the velocity to the specified unit
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

function shows_speed ()
if show_speed == false then
show_speed true
showChat(false)
else
show_speed false
showChat(true)
end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-10-02, 11:54


Tey







Wiek: 31
Na forum: 4876 dni
Posty: 155
Nick w MP: l0nger

Piwa: 280

Respekt: 193
Respekt: 193Respekt: 193

Kod tego licznika jest s?aby i pogmatwany, ale je?eli chcesz go u?ywa? to okej - usu? z warunku ten kod
Kod:

getVehicleOccupant ( veh ) ~= localPlayer
poniewa? to sprawdza czy gracz jest kierowca pojazdu.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Pro3west1
Tagi: licznik :: widziany :: tylko :: przez :: jedną :: osobe
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Licznik widziany tylko przez jedną osobe Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku