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

Wysłany: 2018-04-01, 18:25


PenkY

Mapper






Wiek: 24
Na forum: 3606 dni
Posty: 223
Nick w MP: penky

Piwa: 2225

Respekt: 472
Respekt: 472

Witam.
Ot?? mam skrypt na ogranicznik lecz gdy wybieram 20km/h to na liczniku jest napisane 30km/h o co chodzi? mo?e kto? pom?c? Stawiam R* :piwo:
za pomoc.

Licznik:


local screenX, screenY = guiGetScreenSize() 
local Czcionka = dxCreateFont ( "Czcionka/czcionka.ttf",20 )
local rotacjaBiegow = 0


stanSwiatel = 0
localPlayer = getLocalPlayer ()

addEventHandler("onClientVehicleEnter", getRootElement(),
    function(thePlayer, seat)
        if thePlayer == getLocalPlayer() then
            if seat == 0 then
                bindKey ( "i", "down", interakcjaSwiatel )
                stanSwiatel = getVehicleOverrideLights ( source ) or 0
            end
        end
    end
)

addEventHandler("onClientVehicleExit", getRootElement(),
    function(thePlayer, seat)
        if thePlayer == getLocalPlayer() then
            if seat == 0 then
                unbindKey ( "i", "down" )
               
end
        end
    end
)



function drawNeedle( vehicle, seat)
    if not getPedOccupiedVehicle ( localPlayer ) then
        unbindKey ( "3", "down" )
        stanSwiatel = 0
        return true
    end
        if isPedInVehicle(getLocalPlayer())then 
            local pojazd = getElementSpeed(getPedOccupiedVehicle(getLocalPlayer()), "kmh")
            local stanSilnika = (getPedOccupiedVehicle(getLocalPlayer()))
            if not pojazd then return end
            local pojazdPredkosc = getVehicleSpeed()
            local rotacja = math.floor(((220/12800)* getVehicleRPM(getPedOccupiedVehicle(getLocalPlayer()))) + 0.5)
            local paliwo = getElementData(getPedOccupiedVehicle ( localPlayer ), "vehicle:fuel" ) or 0
        if (rotacjaBiegow < rotacja) then
            rotacjaBiegow = rotacjaBiegow + 1.5
        end
        if (rotacjaBiegow > rotacja) then
            rotacjaBiegow = rotacjaBiegow - 1.5
        end
            
        if pojazdPredkosc > 252 then
            pojazdPredkosc = 252
        end
        if pojazdPredkosc < -252 then
            pojazdPredkosc = -252
        end
            dxDrawImage(screenX-320, screenY-220,314,220,"Grafika/licznik.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            dxDrawImage(screenX-216, screenY-209,200,200,"Grafika/iglaLicznika.png",pojazdPredkosc-0,0.0,0.0,tocolor(255,255,255,255),false)
            dxDrawImage(screenX-313, screenY-188,158,158,"Grafika/iglaBiegow.png",rotacjaBiegow,0.0,0.0,tocolor(255,255,255,255),false)
            dxDrawText(""..tostring ( getFormatSpeed ( pojazd ) ).."", screenX-142, screenY-128, 170, 300,tocolor ( 255,255,255 ),1,Czcionka)
            dxDrawText(""..tostring ( getFormatFuel(math.round  (paliwo))).."", screenX-131, screenY-100, 170, 300,tocolor ( 255,255,255 ),0.6,Czcionka)
            dxDrawImage(screenX-180, screenY-53,23,26,"Grafika/lewoOFF.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            dxDrawImage(screenX-73, screenY-53,23,26,"Grafika/prawoOFF.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            
        if ( pojazdPredkosc == 0 ) then
            dxDrawText(getFormatNeutral().."", screenX-246, screenY-128, 170, 300,tocolor ( 255,255,255 ),1,Czcionka)
        else
            dxDrawText(getFormatGear().."", screenX-246, screenY-128, 170, 300,tocolor ( 255,255,255 ),1,Czcionka)
        end
    
        if ( getVehicleEngineState (stanSilnika) == true ) then
            dxDrawImage(screenX-125, screenY-33,23,26,"Grafika/silnikON.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
        else
            dxDrawImage(screenX-125, screenY-33,23,26,"Grafika/silnikOFF.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
        end
    
        if stanSwiatel == 0 or stanSwiatel == 1 then
            dxDrawImage(screenX-154, screenY-40,23,26,"Grafika/swiatlaOFF.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
        else
            dxDrawImage(screenX-154, screenY-40,23,26,"Grafika/swiatlaON.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
        end
            
        if getElementData(getPedOccupiedVehicle ( localPlayer ), "kierunkowskaz:lewo" ) then
            if ( getTickCount () % 1400 >= 400 ) then
                dxDrawImage(screenX-180, screenY-53,23,26,"Grafika/lewoON.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            end
        end
            
        if getElementData(getPedOccupiedVehicle ( localPlayer ), "kierunkowskaz:prawo" ) then
            if ( getTickCount () % 1400 >= 400 ) then
                dxDrawImage(screenX-73, screenY-53,23,26,"Grafika/prawoON.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            end
        end
            
        local theVehicle = getPedOccupiedVehicle ( localPlayer )
        if ( theVehicle ) then
            if ( enablelock ) and ( isVehicleLocked( theVehicle ) ) or ( getElementData( theVehicle, "drzwi:zamkniete" ) ) then
                dxDrawImage(screenX-95, screenY-35,13,15,"Grafika/zamkniety.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            else
                dxDrawImage(screenX-95, screenY-35,13,15,"Grafika/otwarty.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            end
        end
    end
end
addEventHandler("onClientRender", getRootElement(), drawNeedle)

function interakcjaSwiatel ()
    if stanSwiatel == 0 or stanSwiatel == 1 then
        stanSwiatel = 2
        setVehicleOverrideLights( getPedOccupiedVehicle ( localPlayer ), 2 )
    else
        setVehicleOverrideLights( getPedOccupiedVehicle ( localPlayer ), 1 )
        stanSwiatel = 0
    end
end


function getVehicleSpeed()
    if isPedInVehicle(getLocalPlayer()) then
        local theVehicle = getPedOccupiedVehicle (getLocalPlayer())
        local vx, vy, vz = getElementVelocity (theVehicle)
        return math.sqrt(vx^2 + vy^2 + vz^2) * 225
    end
    return 0
end

function getElementSpeed(element,unit)
    if (unit == nil) then unit = 0 end
    if (isElement(element)) then
        local x,y,z = getElementVelocity(element)
        if (unit=="mph" or unit==1 or unit =='1') then
            return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100)
        else
            return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100 * 1.609344)
        end
    else
        return false
    end
end

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end


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

function getFormatFuel(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

function getFormatGear()
    local gear = getVehicleCurrentGear(getPedOccupiedVehicle(getLocalPlayer()))
    local rear = "R"
    local neutral = "N"
    if (gear > 0) then 
        return gear
    else
        return rear
    end
end

function getFormatNeutral()
    local neutral = "N"
    return neutral
end

function getVehicleRPM(vehicle)
local vehicleRPM = 0
    if (vehicle) then  
        if (getVehicleEngineState(vehicle) == true) then
            if getVehicleCurrentGear(vehicle) > 0 then             
                vehicleRPM = math.floor(((getElementSpeed(vehicle, "kmh")/getVehicleCurrentGear(vehicle))*180) + 0.5) 
                if (vehicleRPM < 650) then
                    vehicleRPM = math.random(650, 750)
                elseif (vehicleRPM >= 9800) then
                    vehicleRPM = math.random(9800, 9900)
                end
            else
                vehicleRPM = math.floor((getElementSpeed(vehicle, "kmh")*180) + 0.5)
                if (vehicleRPM < 650) then
                    vehicleRPM = math.random(650, 750)
                elseif (vehicleRPM >= 9800) then
                    vehicleRPM = math.random(9800, 9900)
                end
            end
        else
            vehicleRPM = 0
        end
        return tonumber(vehicleRPM)
    else
        return 0
    end
end


Ogranicznik:

local typyograniczen = {nil, 120, 90, 60, 20}
local selected = 1

local blocked = {
    [481] = 60,
    [510] = 60,
}

local function ogranicznik()
    local ograniczenie = typyograniczen[selected]
    local vehicle = getPedOccupiedVehicle(localPlayer)
    local typVehicle = getElementModel(vehicle)
    if not vehicle then return end
    
    if getVehicleController(vehicle) ~= localPlayer then return end
    if not isVehicleOnGround(vehicle) then return end
    
    local vx,vy,vz = getElementVelocity(vehicle)
    
    if not getVehicleEngineState(vehicle) then
        if getDistanceBetweenPoints2D(0, 0, vx, vy)<0.1 then
            vx,vy = 0,0
            setElementVelocity(vehicle, vx,vy,vz)
            return
        end
    end
    
    if getVehicleType(vehicle) ~= "Automobile" and not blocked[typVehicle] then return end
    if blocked[typVehicle] then
        ograniczenie = blocked[typVehicle]
    end
    
    if not ograniczenie then return end
    
    local speed = (vx^2 + vy^2 + vz^2)^(0.5) *0.6*180
    if speed > ograniczenie then
        setElementVelocity(vehicle, vx*0.9,vy*0.9,vz*0.9)
    end
end

setTimer(ogranicznik, 50, 0)
addCommandHandler("ogranicznikzmniejsz", function()
    if isCursorShowing() or isPedDoingGangDriveby(localPlayer) then return end
    local vehicle = getPedOccupiedVehicle(localPlayer)
    if not vehicle then return end
    if getVehicleController(vehicle) ~= localPlayer then return end
    if not isVehicleOnGround(vehicle) then return end
    if getVehicleType(vehicle) ~= "Automobile" then return end
    
    selected = selected-1
    if selected < 1 then selected = #typyograniczen end
    if typyograniczen[selected] then
        exports["lr_noti"]:addNotification("Ustawiono ogranicznik pr?dkosci na: "..typyograniczen[selected].." km/h!", localPlayer)
    else
        exports["lr_noti"]:addNotification("Wy??czono ogranicznik", localPlayer)
    end
end)
bindKey("mouse1", "down", "ogranicznikzmniejsz")

addCommandHandler("ogranicznikzwieksz", function()
    if isCursorShowing() or isPedDoingGangDriveby(localPlayer) then return end
    local vehicle = getPedOccupiedVehicle(localPlayer)
    if not vehicle then return end
    if getVehicleController(vehicle) ~= localPlayer then return end
    if not isVehicleOnGround(vehicle) then return end
    
    selected = selected+1
    if selected > #typyograniczen then selected = 1 end
    if typyograniczen[selected] then
        exports["lr_noti"]:addNotification("Ustawiono ogranicznik pr?dkosci na: "..typyograniczen[selected].." km/h!", localPlayer)
    else
        exports["lr_noti"]:addNotification("Wy??czono ogranicznik", localPlayer)
    end
end)
bindKey("mouse2", "down", "ogranicznikzwieksz")


Podpis
Discord: p3nky.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-04-01, 18:36


Kalizman







Wiek: 24
Na forum: 3793 dni
Posty: 1394

Piwa: 4624

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

Sprawd? teraz.

local screenX, screenY = guiGetScreenSize() 
local Czcionka = dxCreateFont ( "Czcionka/czcionka.ttf",20 )
local rotacjaBiegow = 0


stanSwiatel = 0
localPlayer = getLocalPlayer ()

addEventHandler("onClientVehicleEnter", getRootElement(),
    function(thePlayer, seat)
        if thePlayer == getLocalPlayer() then
            if seat == 0 then
                bindKey ( "i", "down", interakcjaSwiatel )
                stanSwiatel = getVehicleOverrideLights ( source ) or 0
            end
        end
    end
)

addEventHandler("onClientVehicleExit", getRootElement(),
    function(thePlayer, seat)
        if thePlayer == getLocalPlayer() then
            if seat == 0 then
                unbindKey ( "i", "down" )
               
end
        end
    end
)



function drawNeedle( vehicle, seat)
    if not getPedOccupiedVehicle ( localPlayer ) then
        unbindKey ( "3", "down" )
        stanSwiatel = 0
        return true
    end
        if isPedInVehicle(getLocalPlayer())then 
            local pojazd = getElementSpeed(getPedOccupiedVehicle(getLocalPlayer()), "kmh")
            local stanSilnika = (getPedOccupiedVehicle(getLocalPlayer()))
            if not pojazd then return end
            local pojazdPredkosc = getVehicleSpeed()
            local rotacja = math.floor(((220/12800)* getVehicleRPM(getPedOccupiedVehicle(getLocalPlayer()))) + 0.5)
            local paliwo = getElementData(getPedOccupiedVehicle ( localPlayer ), "vehicle:fuel" ) or 0
        if (rotacjaBiegow < rotacja) then
            rotacjaBiegow = rotacjaBiegow + 1.5
        end
        if (rotacjaBiegow > rotacja) then
            rotacjaBiegow = rotacjaBiegow - 1.5
        end
            
        if pojazdPredkosc > 252 then
            pojazdPredkosc = 252
        end
        if pojazdPredkosc < -252 then
            pojazdPredkosc = -252
        end
            dxDrawImage(screenX-320, screenY-220,314,220,"Grafika/licznik.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            dxDrawImage(screenX-216, screenY-209,200,200,"Grafika/iglaLicznika.png",pojazdPredkosc-0,0.0,0.0,tocolor(255,255,255,255),false)
            dxDrawImage(screenX-313, screenY-188,158,158,"Grafika/iglaBiegow.png",rotacjaBiegow,0.0,0.0,tocolor(255,255,255,255),false)
            dxDrawText(""..tostring ( getFormatSpeed ( pojazd ) ).."", screenX-142, screenY-128, 170, 300,tocolor ( 255,255,255 ),1,Czcionka)
            dxDrawText(""..tostring ( getFormatFuel(math.round  (paliwo))).."", screenX-131, screenY-100, 170, 300,tocolor ( 255,255,255 ),0.6,Czcionka)
            dxDrawImage(screenX-180, screenY-53,23,26,"Grafika/lewoOFF.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            dxDrawImage(screenX-73, screenY-53,23,26,"Grafika/prawoOFF.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            
        if ( pojazdPredkosc == 0 ) then
            dxDrawText(getFormatNeutral().."", screenX-246, screenY-128, 170, 300,tocolor ( 255,255,255 ),1,Czcionka)
        else
            dxDrawText(getFormatGear().."", screenX-246, screenY-128, 170, 300,tocolor ( 255,255,255 ),1,Czcionka)
        end
    
        if ( getVehicleEngineState (stanSilnika) == true ) then
            dxDrawImage(screenX-125, screenY-33,23,26,"Grafika/silnikON.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
        else
            dxDrawImage(screenX-125, screenY-33,23,26,"Grafika/silnikOFF.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
        end
    
        if stanSwiatel == 0 or stanSwiatel == 1 then
            dxDrawImage(screenX-154, screenY-40,23,26,"Grafika/swiatlaOFF.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
        else
            dxDrawImage(screenX-154, screenY-40,23,26,"Grafika/swiatlaON.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
        end
            
        if getElementData(getPedOccupiedVehicle ( localPlayer ), "kierunkowskaz:lewo" ) then
            if ( getTickCount () % 1400 >= 400 ) then
                dxDrawImage(screenX-180, screenY-53,23,26,"Grafika/lewoON.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            end
        end
            
        if getElementData(getPedOccupiedVehicle ( localPlayer ), "kierunkowskaz:prawo" ) then
            if ( getTickCount () % 1400 >= 400 ) then
                dxDrawImage(screenX-73, screenY-53,23,26,"Grafika/prawoON.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            end
        end
            
        local theVehicle = getPedOccupiedVehicle ( localPlayer )
        if ( theVehicle ) then
            if ( enablelock ) and ( isVehicleLocked( theVehicle ) ) or ( getElementData( theVehicle, "drzwi:zamkniete" ) ) then
                dxDrawImage(screenX-95, screenY-35,13,15,"Grafika/zamkniety.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            else
                dxDrawImage(screenX-95, screenY-35,13,15,"Grafika/otwarty.png",0.0,0.0,0.0,tocolor(255,255,255,255),false)
            end
        end
    end
end
addEventHandler("onClientRender", getRootElement(), drawNeedle)

function interakcjaSwiatel ()
    if stanSwiatel == 0 or stanSwiatel == 1 then
        stanSwiatel = 2
        setVehicleOverrideLights( getPedOccupiedVehicle ( localPlayer ), 2 )
    else
        setVehicleOverrideLights( getPedOccupiedVehicle ( localPlayer ), 1 )
        stanSwiatel = 0
    end
end


function getVehicleSpeed()
    if isPedInVehicle(getLocalPlayer()) then
        local theVehicle = getPedOccupiedVehicle (getLocalPlayer())
        local vx, vy, vz = getElementVelocity (theVehicle)
        return math.sqrt(vx^2 + vy^2 + vz^2) * 180
    end
    return 0
end

function getElementSpeed(element,unit)
    if (unit == nil) then unit = 0 end
    if (isElement(element)) then
        local x,y,z = getElementVelocity(element)
        if (unit=="mph" or unit==1 or unit =='1') then
            return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100)
        else
            return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100 * 1.609344)
        end
    else
        return false
    end
end

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end


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

function getFormatFuel(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

function getFormatGear()
    local gear = getVehicleCurrentGear(getPedOccupiedVehicle(getLocalPlayer()))
    local rear = "R"
    local neutral = "N"
    if (gear > 0) then 
        return gear
    else
        return rear
    end
end

function getFormatNeutral()
    local neutral = "N"
    return neutral
end

function getVehicleRPM(vehicle)
local vehicleRPM = 0
    if (vehicle) then  
        if (getVehicleEngineState(vehicle) == true) then
            if getVehicleCurrentGear(vehicle) > 0 then             
                vehicleRPM = math.floor(((getElementSpeed(vehicle, "kmh")/getVehicleCurrentGear(vehicle))*180) + 0.5) 
                if (vehicleRPM < 650) then
                    vehicleRPM = math.random(650, 750)
                elseif (vehicleRPM >= 9800) then
                    vehicleRPM = math.random(9800, 9900)
                end
            else
                vehicleRPM = math.floor((getElementSpeed(vehicle, "kmh")*180) + 0.5)
                if (vehicleRPM < 650) then
                    vehicleRPM = math.random(650, 750)
                elseif (vehicleRPM >= 9800) then
                    vehicleRPM = math.random(9800, 9900)
                end
            end
        else
            vehicleRPM = 0
        end
        return tonumber(vehicleRPM)
    else
        return 0
    end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-04-01, 18:50


PenkY

Mapper






Wiek: 24
Na forum: 3606 dni
Posty: 223
Nick w MP: penky

Piwa: 2225

Respekt: 472
Respekt: 472

Kalizman, Dalej to samo nie poprawi?o si?

Podpis
Discord: p3nky.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-04-01, 19:24


Ciastuuś

As-salamu alaykum






Wiek: 27
Na forum: 3212 dni
Posty: 800
Nick w MP: Ciastuuś

Piwa: 4304

Respekt: 640
Respekt: 640Respekt: 640

Potrzeba troch? oblicze?. Musisz dor?wna? tempomat z ig??(wskaz?wk?) mierz?c? pr?dko??. Je?eli chcesz to osi?gn?? musisz u?y? matematyki :)

Podpis
As-salamu alaykum
Postaw piwo autorowi tego posta
 

 
Tagi: licznik :: ogranicznik
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, ogranicznik Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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