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

Wysłany: 2018-11-11, 23:21


Fl!k







Wiek: 26
Na forum: 3592 dni
Posty: 162

Piwa: 18

Respekt: 50

Witam chcia?em odda? do schowka aodo gdy doda?em schowek przesta? dzia?a?

c.lua
local screenSize Vector2(guiGetScreenSize())
local ticks = {alphaTick getTickCount(), animTick getTickCount(), vehicle nil}

local function isMouseInPosition(xywidthheight)
    if not isCursorShowing() then return false end
    
    local cursor = {getCursorPosition()}
    local cxcy = (cursor[1]*screenSize.x), (cursor[2]*screenSize.y)
    if (cx >= and cx <= width) and (cy >= and cy <= heightthen return true else return false end
end

function isEventHandlerAdded(sEventNamepElementAttachedTofunc)
    if type(sEventName) == 'string' and isElement(pElementAttachedTo) and type(func) == 'function' then
    local aAttachedFunctions getEventHandlers(sEventNamepElementAttachedTo)
    if type(aAttachedFunctions) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs(aAttachedFunctions) do if v == func then return true end end end 
    end return false
end

local function scaleElement(sxsy)
    return (screenSize.sx)/2, (screenSize.sy)/2
end

local icon_xicon_y scaleElement(128128)
local function drawGUI()
    local up interpolateBetween(10000000, (getTickCount()-ticks.animTick)/2000"OutBack") 

    if anim == "fadein" then
        progress = (getTickCount()-ticks.alphaTick)/1000
        alpha interpolateBetween(alpha0025500progress"Linear")
        if alpha == 255 then
            ticks.alphaTick getTickCount()
            anim nil
        end
    elseif anim == "fadeout" then
        progress = (getTickCount()-ticks.alphaTick)/500
        alpha interpolateBetween(alpha00000progress"Linear")
        if alpha == 0 then
            removeEventHandler("onClientRender"rootdrawGUI)
            ticks.alphaTick nil
            anim nil
        end
    end
    
    if isMouseInPosition(icon_x-300icon_y128128then color_one_down = {36175178} else color_one_down = {255255255end
    if isMouseInPosition(icon_x-150icon_y128128then color_two_down = {36175178} else color_two_down = {255255255end
    if isMouseInPosition(icon_xicon_y128128then color_three_down = {36175178} else color_three_down = {255255255end
    if isMouseInPosition(icon_x+150icon_y128128then color_four_down = {36175178} else color_four_down = {255255255end
    if isMouseInPosition(icon_x+300icon_y128128then color_five_down = {36175178} else color_five_down = {255255255end
    if isMouseInPosition(icon_x+450icon_y128128then color_six_down = {36175178} else color_six_down = {255255255end
    dxDrawImage(icon_x-300icon_y+up128128"images/extinguisher.png"000tocolor(color_one_down[1], color_one_down[2], color_one_down[3], alpha), false)
    dxDrawImage(icon_x-150icon_y+up128128"images/ladder.png"000tocolor(color_two_down[1], color_two_down[2], color_two_down[3], alpha), false)
    dxDrawImage(icon_xicon_y+up128128"images/object.png"000tocolor(color_three_down[1], color_three_down[2], color_three_down[3], alpha), false)
    dxDrawImage(icon_x+150icon_y+up128128"images/saw.png"000tocolor(color_four_down[1], color_four_down[2], color_four_down[3], alpha), false)
    dxDrawImage(icon_x+300icon_y+up128128"images/sorbent.png"000tocolor(color_five_down[1], color_five_down[2], color_five_down[3], alpha), false)
    dxDrawImage(icon_x+450icon_y+up128128"images/aodo.png"000tocolor(color_six_down[1], color_six_down[2], color_six_down[3], alpha), false)
end

for i,v in ipairs(getElementsByType("vehicle")) do
    if v.model == 407 then
        if v:getData("vehicle:rank"then
            marker Marker(000"cylinder"125500150)
            attachElements(markerv1.80, -1)
            
            addEventHandler("onClientMarkerHit"resourceRoot, function(playerdimension)
                if player == localPlayer and dimension then
                    if not isEventHandlerAdded("onClientRender"rootdrawGUIthen
                        if player:getData("player:duty") == "SAFD" then
                            local data marker:getData("marker:vehicle")
                            ticks.vehicle data
                        
                            alpha 0
                            anim "fadein"
                            showChat(false)
                            showCursor(truefalse)
                            ticks.animTick getTickCount()
                            ticks.alphaTick getTickCount()
                            player:setData("player:blackwhite"true)
                            player:setData("player:hud_visible"true)
                            setPlayerHudComponentVisible("radar"false)
                            addEventHandler("onClientRender"rootdrawGUI)
                            --triggerServerEvent("iyw_fire_equipment:say"localPlayer"podchodzi do wozu, przegl?daj?c zawarto??...")
                        end
                    end
                end
            end)
            
            addEventHandler("onClientMarkerLeave"marker, function(playerdimension)
                if player == localPlayer and dimension then
                    if isEventHandlerAdded("onClientRender"rootdrawGUIthen
                        alpha 255
                        showChat(true)
                        anim "fadeout"
                        showCursor(false)
                        ticks.vehicle nil
                        ticks.animTick getTickCount()
                        ticks.alphaTick getTickCount()
                        player:setData("player:blackwhite"false)
                        player:setData("player:hud_visible"false)
                        setPlayerHudComponentVisible("radar"true)
                    end
                end
            end)
        end
    end
end

local function closeGUI()
    alpha 255
    showChat(true)
    anim "fadeout"
    showCursor(false)
    ticks.animTick getTickCount()
    ticks.alphaTick getTickCount()
    setPlayerHudComponentVisible("radar"true)
    localPlayer:setData("player:blackwhite"false)
    localPlayer:setData("player:hud_visible"false)
end

addEventHandler("onClientClick"root, function(buttonstate)
    if button == "left" and state == "down" then
        if isEventHandlerAdded("onClientRender"rootdrawGUIthen
            if isMouseInPosition(icon_x-300icon_y128128then
                closeGUI()
                triggerServerEvent("iyw_fire_equipment:say"localPlayer"bierze ga?nic? ze schowka.")
                triggerServerEvent("iyw_fire_equipment:give"localPlayer"extinguisher")
            elseif isMouseInPosition(icon_x-150icon_y128128then
                if not localPlayer:getData("player:ladder"then
                    closeGUI()
                    triggerServerEvent("iyw_fire_equipment:say"localPlayer"w?wczas chwyci? za drabin?, oraz wyj?? j? ze schowka.")
                    triggerServerEvent("iyw_fire_equipment:give"localPlayer"ladder")
                else
                    closeGUI()
                    triggerServerEvent("iyw_fire_equipment:say"localPlayer"z?o?y? drabin?, oraz umie?ci? j? w schowku.")
                    triggerServerEvent("iyw_fire_equipment:give"localPlayer"ladder")    
                end
            elseif isMouseInPosition(icon_xicon_y128128then
                if not localPlayer:getData("vehicle:jumping"then
                    closeGUI()
                    triggerServerEvent("iyw_fire_equipment:say"localPlayer"bierze skokochron ze schowka.")
                    triggerServerEvent("iyw_fire_equipment:give"localPlayer"jump")
                else
                    closeGUI()
                    triggerServerEvent("iyw_fire_equipment:say"localPlayer"chowa skokochron do schowka.")
                    localPlayer:setData("vehicle:jumping"false)
                end
            elseif isMouseInPosition(icon_x+150icon_y128128then
                closeGUI()
                triggerServerEvent("iyw_fire_equipment:say"localPlayer"bierze pi?? mechaniczn? ze schowka.")
                triggerServerEvent("iyw_fire_equipment:give"localPlayer"saw")            
            end
            elseif isMouseInPosition(icon_x+450icon_y128128then
                closeGUI()
                triggerServerEvent("iyw_fire_equipment:say"localPlayer"bierze AODO ze schowka.")
                triggerServerEvent("iyw_fire_equipment:give"localPlayer"aodo")            
            end
        end
    end
end)


debugscript 3


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-11-12, 01:29


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

W linijce (bodaj?e) 150 pojawi? si? end, kt?ry by? zb?dny i powodowa? b??dy.
Spr?buj poni?szy kod:

local screenSize Vector2(guiGetScreenSize())
local ticks = {alphaTick getTickCount(), animTick getTickCount(), vehicle nil}

local function isMouseInPosition(xywidthheight)
    if not isCursorShowing() then return false end
    
    local cursor = {getCursorPosition()}
    local cxcy = (cursor[1]*screenSize.x), (cursor[2]*screenSize.y)
    if (cx >= and cx <= width) and (cy >= and cy <= heightthen return true else return false end
end

function isEventHandlerAdded(sEventNamepElementAttachedTofunc)
    if type(sEventName) == 'string' and isElement(pElementAttachedTo) and type(func) == 'function' then
    local aAttachedFunctions getEventHandlers(sEventNamepElementAttachedTo)
    if type(aAttachedFunctions) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs(aAttachedFunctions) do if v == func then return true end end end 
    end return false
end

local function scaleElement(sxsy)
    return (screenSize.sx)/2, (screenSize.sy)/2
end

local icon_xicon_y scaleElement(128128)
local function drawGUI()
    local up interpolateBetween(10000000, (getTickCount()-ticks.animTick)/2000"OutBack") 

    if anim == "fadein" then
        progress = (getTickCount()-ticks.alphaTick)/1000
        alpha interpolateBetween(alpha0025500progress"Linear")
        if alpha == 255 then
            ticks.alphaTick getTickCount()
            anim nil
        end
    elseif anim == "fadeout" then
        progress = (getTickCount()-ticks.alphaTick)/500
        alpha interpolateBetween(alpha00000progress"Linear")
        if alpha == 0 then
            removeEventHandler("onClientRender"rootdrawGUI)
            ticks.alphaTick nil
            anim nil
        end
    end
    
    if isMouseInPosition(icon_x-300icon_y128128then color_one_down = {36175178} else color_one_down = {255255255end
    if isMouseInPosition(icon_x-150icon_y128128then color_two_down = {36175178} else color_two_down = {255255255end
    if isMouseInPosition(icon_xicon_y128128then color_three_down = {36175178} else color_three_down = {255255255end
    if isMouseInPosition(icon_x+150icon_y128128then color_four_down = {36175178} else color_four_down = {255255255end
    if isMouseInPosition(icon_x+300icon_y128128then color_five_down = {36175178} else color_five_down = {255255255end
    if isMouseInPosition(icon_x+450icon_y128128then color_six_down = {36175178} else color_six_down = {255255255end
    dxDrawImage(icon_x-300icon_y+up128128"images/extinguisher.png"000tocolor(color_one_down[1], color_one_down[2], color_one_down[3], alpha), false)
    dxDrawImage(icon_x-150icon_y+up128128"images/ladder.png"000tocolor(color_two_down[1], color_two_down[2], color_two_down[3], alpha), false)
    dxDrawImage(icon_xicon_y+up128128"images/object.png"000tocolor(color_three_down[1], color_three_down[2], color_three_down[3], alpha), false)
    dxDrawImage(icon_x+150icon_y+up128128"images/saw.png"000tocolor(color_four_down[1], color_four_down[2], color_four_down[3], alpha), false)
    dxDrawImage(icon_x+300icon_y+up128128"images/sorbent.png"000tocolor(color_five_down[1], color_five_down[2], color_five_down[3], alpha), false)
    dxDrawImage(icon_x+450icon_y+up128128"images/aodo.png"000tocolor(color_six_down[1], color_six_down[2], color_six_down[3], alpha), false)
end

for i,v in ipairs(getElementsByType("vehicle")) do
    if v.model == 407 then
        if v:getData("vehicle:rank"then
            marker Marker(000"cylinder"125500150)
            attachElements(markerv1.80, -1)
            
            addEventHandler("onClientMarkerHit"resourceRoot, function(playerdimension)
                if player == localPlayer and dimension then
                    if not isEventHandlerAdded("onClientRender"rootdrawGUIthen
                        if player:getData("player:duty") == "SAFD" then
                            local data marker:getData("marker:vehicle")
                            ticks.vehicle data
                        
                            alpha 0
                            anim "fadein"
                            showChat(false)
                            showCursor(truefalse)
                            ticks.animTick getTickCount()
                            ticks.alphaTick getTickCount()
                            player:setData("player:blackwhite"true)
                            player:setData("player:hud_visible"true)
                            setPlayerHudComponentVisible("radar"false)
                            addEventHandler("onClientRender"rootdrawGUI)
                            --triggerServerEvent("iyw_fire_equipment:say"localPlayer"podchodzi do wozu, przegl?daj?c zawarto??...")
                        end
                    end
                end
            end)
            
            addEventHandler("onClientMarkerLeave"marker, function(playerdimension)
                if player == localPlayer and dimension then
                    if isEventHandlerAdded("onClientRender"rootdrawGUIthen
                        alpha 255
                        showChat(true)
                        anim "fadeout"
                        showCursor(false)
                        ticks.vehicle nil
                        ticks.animTick getTickCount()
                        ticks.alphaTick getTickCount()
                        player:setData("player:blackwhite"false)
                        player:setData("player:hud_visible"false)
                        setPlayerHudComponentVisible("radar"true)
                    end
                end
            end)
        end
    end
end

local function closeGUI()
    alpha 255
    showChat(true)
    anim "fadeout"
    showCursor(false)
    ticks.animTick getTickCount()
    ticks.alphaTick getTickCount()
    setPlayerHudComponentVisible("radar"true)
    localPlayer:setData("player:blackwhite"false)
    localPlayer:setData("player:hud_visible"false)
end

addEventHandler("onClientClick"root, function(buttonstate)
    if button == "left" and state == "down" then
        if isEventHandlerAdded("onClientRender"rootdrawGUIthen
            if isMouseInPosition(icon_x-300icon_y128128then
                closeGUI()
                triggerServerEvent("iyw_fire_equipment:say"localPlayer"bierze ga?nic? ze schowka.")
                triggerServerEvent("iyw_fire_equipment:give"localPlayer"extinguisher")
            elseif isMouseInPosition(icon_x-150icon_y128128then
                if not localPlayer:getData("player:ladder"then
                    closeGUI()
                    triggerServerEvent("iyw_fire_equipment:say"localPlayer"w?wczas chwyci? za drabin?, oraz wyj?? j? ze schowka.")
                    triggerServerEvent("iyw_fire_equipment:give"localPlayer"ladder")
                else
                    closeGUI()
                    triggerServerEvent("iyw_fire_equipment:say"localPlayer"z?o?y? drabin?, oraz umie?ci? j? w schowku.")
                    triggerServerEvent("iyw_fire_equipment:give"localPlayer"ladder")    
                end
            elseif isMouseInPosition(icon_xicon_y128128then
                if not localPlayer:getData("vehicle:jumping"then
                    closeGUI()
                    triggerServerEvent("iyw_fire_equipment:say"localPlayer"bierze skokochron ze schowka.")
                    triggerServerEvent("iyw_fire_equipment:give"localPlayer"jump")
                else
                    closeGUI()
                    triggerServerEvent("iyw_fire_equipment:say"localPlayer"chowa skokochron do schowka.")
                    localPlayer:setData("vehicle:jumping"false)
                end
            elseif isMouseInPosition(icon_x+150icon_y128128then
                closeGUI()
                triggerServerEvent("iyw_fire_equipment:say"localPlayer"bierze pi?? mechaniczn? ze schowka.")
                triggerServerEvent("iyw_fire_equipment:give"localPlayer"saw")            
            elseif isMouseInPosition(icon_x+450icon_y128128then
                closeGUI()
                triggerServerEvent("iyw_fire_equipment:say"localPlayer"bierze AODO ze schowka.")
                triggerServerEvent("iyw_fire_equipment:give"localPlayer"aodo")            
            end
        end
    end
end)


Postaw piwo autorowi tego posta
 

 
Tagi: nie :: działający :: schowek :: psp
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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