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

Wysłany: 2025-12-30, 23:31


noose

JESTĘ SKRYPTERĘ






Wiek: 35
Na forum: 3756 dni
Posty: 222

Piwa: 2294

Respekt: 155,8
Respekt: 155,8Respekt: 155,8

Kod:

armedVehicles = {[425]=true, [520]=true, [476]=true, [447]=true, [430]=true, [432]=true, [464]=true, [407]=true, [601]=true}
function vehicleWeaponFire(key, keyState, vehicleFireType)
local vehModel = getElementModel(getPedOccupiedVehicle(localPlayer))
if (armedVehicles[vehModel]) then
triggerEvent("onClientVehicleWeaponFire", localPlayer, vehicleFireType, vehModel)
end
end
bindKey("vehicle_fire", "down", vehicleWeaponFire, "primary")
bindKey("vehicle_secondary_fire", "down", vehicleWeaponFire, "secondary")

local tim = nil

function armatka(ftype, veh)
if not veh or veh ~=407 and veh ~=601 then return end
if ftype == "primary" or ftype == "secondary" then
if getElementData(getPedOccupiedVehicle(localPlayer), "NAPEŁNIENIE") <= 0 then
setControlState("vehicle_fire", false)
setTimer(toggleControl, 10, 1, "vehicle_fire", false)
setTimer(toggleControl, 10, 1, "vehicle_secondary_fire", false)
setElementData(getPedOccupiedVehicle(localPlayer), "NAPEŁNIENIE", 0)
else
toggleControl("vehicle_fire", true)
toggleControl("vehicle_secondary_fire", true)
end
if not isTimer(tim) then
tim = setTimer(function()
setElementData(getPedOccupiedVehicle(localPlayer),"NAPEŁNIENIE", (getElementData(getPedOccupiedVehicle(localPlayer), "NAPEŁNIENIE"))- 1)
end, 3000, 0)
end
end
end
addEvent("onClientVehicleWeaponFire", false)
addEventHandler("onClientVehicleWeaponFire", getLocalPlayer(), armatka)


armatka działą, ale nie da sie zatrzymać odejmowania napełnienia.
próbowałem pożyczyć keyState z kody na samej górze, ale nie działa

Postaw piwo autorowi tego posta
 

 
Wysłany: 2026-04-28, 20:25


Axmell

E-Commerce






Wiek: 24
Na forum: 3810 dni
Posty: 279
Nick w MP: %Axmell

Piwa: 224

Respekt: 50

local armedVehicles = { [425] = true, [520] = true, [476] = true, [447] = true, [430] = true, [432] = true, [464] = true, [407] = true, [601] = true }

local drainTimer nil
local drainVehicle nil
local firing = { primary falsesecondary false }

local function getFill(veh)
    if not isElement(vehthen
        return 0
    end
    local v getElementData(veh"NAPEŁNIENIE")
    tonumber(v) or 0
    if 0 then
        v 0
    end
    return v
end

local function setFill(vehv)
    if not isElement(vehthen
        return
    end
    v tonumber(v) or 0
    if 0 then
        v 0
    end
    setElementData(veh"NAPEŁNIENIE"v)
end

local function stopDrain()
    if drainTimer and isTimer(drainTimerthen
        killTimer(drainTimer)
    end
    drainTimer nil
    drainVehicle nil
    firing.primary false
    firing.secondary false
end

local function startDrain(veh)
    if not isElement(vehthen
        return
    end

    drainVehicle veh

    if drainTimer and isTimer(drainTimerthen
        return
    end

    drainTimer setTimer(function()
        local v drainVehicle
        if not isElement(vthen
            stopDrain()
            return
        end

        local current getPedOccupiedVehicle(localPlayer)
        if current ~= v then
            stopDrain()
            return
        end

        local fill getFill(v)
        if fill <= 0 then
            setFill(v0)
            toggleControl("vehicle_fire"false)
            toggleControl("vehicle_secondary_fire"false)
            stopDrain()
            return
        end

        setFill(vfill 1)
    end30000)
end

function vehicleWeaponFire(keykeyStatevehicleFireType)
    local veh getPedOccupiedVehicle(localPlayer)
    if not veh then
        return
    end

    local vehModel getElementModel(veh)
    if armedVehicles[vehModelthen
        triggerEvent("onClientVehicleWeaponFire"localPlayervehicleFireTypevehModel)
    end
end

local function vehicleWeaponStop(keykeyStatevehicleFireType)
    if vehicleFireType == "primary" then
        firing.primary false
    elseif vehicleFireType == "secondary" then
        firing.secondary false
    end

    if not firing.primary and not firing.secondary then
        stopDrain()
    end
end

bindKey("vehicle_fire""down"vehicleWeaponFire"primary")
bindKey("vehicle_secondary_fire""down"vehicleWeaponFire"secondary")
bindKey("vehicle_fire""up"vehicleWeaponStop"primary")
bindKey("vehicle_secondary_fire""up"vehicleWeaponStop"secondary")

function armatka(ftypevehModel)
    if not vehModel or (vehModel ~= 407 and vehModel ~= 601then
        return
    end
    if ftype ~= "primary" and ftype ~= "secondary" then
        return
    end

    local veh getPedOccupiedVehicle(localPlayer)
    if not veh then
        stopDrain()
        return
    end

    if getElementModel(veh) ~= vehModel then
        return
    end

    if ftype == "primary" then
        firing.primary true
    else
        firing.secondary true
    end

    local fill getFill(veh)
    if fill <= 0 then
        setControlState("vehicle_fire"false)
        toggleControl("vehicle_fire"false)
        toggleControl("vehicle_secondary_fire"false)
        setFill(veh0)
        stopDrain()
        return
    end

    toggleControl("vehicle_fire"true)
    toggleControl("vehicle_secondary_fire"true)
    startDrain(veh)
end

addEvent("onClientVehicleWeaponFire"false)
addEventHandler("onClientVehicleWeaponFire"localPlayerarmatka)

addEventHandler("onClientPlayerVehicleExit"localPlayer, function()
    stopDrain()
end)

addEventHandler("onClientPlayerWasted"localPlayer, function()
    stopDrain()
end)

addEventHandler("onClientResourceStop"resourceRoot, function()
    stopDrain()
end)

addEventHandler("onClientRender"root, function()
    local veh getPedOccupiedVehicle(localPlayer)
    if not veh then
        return
    end

    local model getElementModel(veh)
    if model ~= 407 and model ~= 601 then
        return
    end

    local fill getFill(veh)
    local sxsy guiGetScreenSize()

    local text "NAPEŁNIENIE: " .. tostring(fill)
    local x sx 20
    local y sy 140

    dxDrawText(text1111tocolor(000220), 1.0"default-bold""right""top"falsefalsefalse)
    dxDrawText(textxyxytocolor(255255255240), 1.0"default-bold""right""top"falsefalsefalse)
end)


Postaw piwo autorowi tego posta
 

 
Tagi: armatka :: wodna
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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