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

Wysłany: 2020-03-23, 17:05


adaskOO

Ten który patrzy






Wiek: 24
Na forum: 3732 dni
Posty: 249
Nick w MP: adaskOO

Piwa: 3168

Respekt: 280
Respekt: 280Respekt: 280Respekt: 280

Witaaam, mam problem z paliwem LPG. Po prostu gdy prze??cz? na LPG nie zabiera paliwa, mo?na zatankowa? ale nie odejmuje ilo?ci z baku gdy poruszamy sie pojazdem. Natomiast gdy prze??cz? na benzyn? kt?ra ma praktycznie taki sam kod jak gaz dzia?a bez zarzut?w.

c side

--[[
    ResourceOURGame
    DevelopersSplit <split.programista@gmail.com>
    Copyright <split.programista@gmail.com2015-2016
    You have no right to use this code without my permission.
]]

-- Kod odpowiadaj?cy za odejmowanie paliwa oraz dodawanie paliwa
-- Wszelkie inne rzeczy sw systemie vehicle?// Split
local time=getTickCount()
local isBike={[509]=true,[481]=true,[510]=true}
local x1,y1,z1



local oXoYoZ
local function naliczaj(veh)
    if(isPedInVehicle(localPlayer)) then
        local pojazd getPedOccupiedVehicle(localPlayer)
        if getElementData(pojazd'vehicle:id'then 
        if getElementData(pojazd"lpg:adaskOO") == false then return end
            
            local x,y,getElementPosition(pojazd)
            local thisTime  getDistanceBetweenPoints3D(x,y,z,oX,oY,oZ)
            local dst getElementData(pojazd"vehicle:mileage") or 0
            local dystans_add thisTime
            oX x
            oY y
            oZ z
            local przebiegAdd=dystans_add/100
            local gazAdd=dystans_add/600
            setElementData(pojazd"vehicle:mileage"getElementData(pojazd"vehicle:mileage")+przebiegAdd)
            setElementData(pojazd,"gaz",getElementData(pojazd,"gaz") - gazAdd )
        end
    end
end
addEventHandler('onClientVehicleEnter',root,function()
    local xygetElementPosition(localPlayer)
    oXoYoZ xyz
end)
addEventHandler("onClientRender"root, function()
    local vehicle getPedOccupiedVehicle(localPlayer)
    if not vehicle then return end
    if getElementData(vehicle"vehicle:lpg") == and getElementData(vehicle"lpg:adaskOO") == false then return end


    if isBike[getElementModel(vehicle)] then return end
    if not getVehicleEngineState(vehiclethen return end
    if getElementData(vehicle"vehicle:lpg") == 1 then
    if getElementData(vehicle,"gaz") and getElementData(vehicle,"gaz") or getElementData(vehicle,"vehicle:mileage") and getElementData(vehicle,"vehicle:mileage"then
        naliczaj(vehicle)
        if getElementData(vehicle,"gaz")<1 then
            setVehicleEngineState(vehiclefalse)
        end
    end
    end
    end)



s side

local czas getTickCount()

isBike = {
    [509]=true, --Bike
    [481]=true, --BMX
    [510]=true, --Mountain bike
}

function odejmijGaz(pojazd)
 if getElementData(pojazd"lpg:adaskOO") == false then return end
    if getTickCount() - czas 150 then
        czas getTickCount()
        local gaz getElementData(pojazd"gaz") or 0
        local vx,vy,vz getElementVelocity(pojazd)
        local spd = ((vx^2+vy^2+vz^2)^(0.5)/150)
        if spd 0 then
            gaz gaz-spd*2
            setElementData(pojazd"gaz"gaz)
        end
    end
end

addEventHandler("onClientRender"root, function()
    local pojazd getPedOccupiedVehicle(localPlayer)
    if not pojazd then return end
    if getElementData(pojazd"lpg:adaskOO") == true then else return end
    if isBike[getElementModel(pojazd)] then return end
    if not getVehicleEngineState(pojazdthen return end
    if getVehicleController(pojazd) ~= localPlayer then return end
    odejmijGaz(pojazd)
end)

addEvent("TANKUJLPG",true)
addEventHandler("TANKUJLPG",root,function()
    if getPlayerMoney(source)>= 2 then
        takePlayerMoney(source2)
        triggerClientEvent("TANKUJLPG",source)
    end
end)

function zgasSilnik()
    for i,v in ipairs(getElementsByType("vehicle")) do
    local data getElementData(v"gaz")
        if data then
        if getElementData(v"lpg:adaskOO") == true then
        if tonumber(data) < 0 then
            setVehicleEngineState(vfalse)
        end
    end
end
    end
end
setTimer(zgasSilnik10000) 

function koniecLPG()
    vehicle getPedOccupiedVehicle(localPlayer)
    if getElementData(vehicle"lpg:adaskOO") == false then return end
    if vehicle and (not getElementData(vehicle,"gaz") == false ) and getElementData(vehicle,"gaz") <= 0 then
        if getElementData(vehicle"lpg:adaskOO") == true then
        setElementData(vehicle,"gaz",0)
        setElementData(vehicle,"konieclpg",true)
        setVehicleEngineState(vehicle,false)
    end
end
end
addEventHandler("onClientRender",root,koniecLPG)


Dodam, ?e element data "gaz:adaskOO", gdy gaz jest w??czony zwraca true, wy??czony zwraca false. Jest to po prostu w interakcji.
"gaz" to ilo?? gazu.
"vehicle:lpg" - Czy w pojedzie jest zamontowany gaz. 1 == tak

Po prostu nie mam poj?cia dlaczego nie pobiera gazu podczas jazdy..

Podpis

Zapraszam do współpracy :)
Discord: adaskOO#8255
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-23, 23:26


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

2 razy odejmujesz gaz? onClientRender po serwerze?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-24, 11:47


adaskOO

Ten który patrzy






Wiek: 24
Na forum: 3732 dni
Posty: 249
Nick w MP: adaskOO

Piwa: 3168

Respekt: 280
Respekt: 280Respekt: 280Respekt: 280

"Wilq" napisał/a:

2 razy odejmujesz gaz? onClientRender po serwerze?


Faktycznie, onClientRender tylko po stronie clienta.. nie dopatrzy?em. Aczkolwiek ciekawi mnie jak dzia?a benzyna skoro to ten sam kod w tym samym ulo?eniu tylko ze zmienionymi elementdatami? Nawiazuj?c do dwa razy odejmowania gazu.. jak? Skoro funkcja odejmijgaz zaczyna dzia?a? dopiero gdy wsi?d? do pojazdu i i element data "lpg;adaskoo" zwraca true.

Podpis

Zapraszam do współpracy :)
Discord: adaskOO#8255
Postaw piwo autorowi tego posta
 

 
Tagi: nie :: odejmuje :: gazu
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Nie odejmuje gazu 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