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

Wysłany: 2018-10-12, 10:41


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam ot?? usuniecie mi linijki kt?re teleportuj? pojazd do przecho po zamontowaniu neon?w?
kod

defs_c.lua
function isEventHandlerAdded(sEventName, pElementAttachedTo, func)
    if type(sEventName) == 'string' and isElement(pElementAttachedTo) and type(func) == 'function' then
    local aAttachedFunctions = getEventHandlers(sEventName, pElementAttachedTo)
    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

function secondsToClock(seconds)
    seconds = seconds or 0
    if seconds <= 0 then
        return "00:00:00"
    else
        hours = string.format("%02.f", math.floor(seconds/3600))
        mins = string.format("%02.f", math.floor(seconds/60 - (hours*60)))
        secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60))
        return ""..hours.." godzin "..mins
    end
end


s.lua

elements = {}
elements["positions"] = {
    ["EZ 3"]={
        marker = {-2138.74, -110.33, 34.88},
        cuboid = {-2138.74, -110.33, 34.88, 4},
        text = "Monta? wzmocnie?"
    },
}

local napis=createElement("text")
setElementData(napis, "name", "Montarz PaintJob'a\nCena 5kk")
setElementPosition(napis, -2138.74, -110.33, 34.88)

for i,v in pairs(elements["positions"]) do
    v.cuboid = ColShape.Sphere(unpack(v.cuboid))
    v.marker = Marker(v.marker[1], v.marker[2], v.marker[3]-0.90, "cylinder", 2, 255, 0, 150, 0)
        setElementData(v.marker, "markery3", true)
end

addEvent("pj0", true)
addEventHandler("pj0", getRootElement(), function()
    local hajs = getPlayerMoney(source)
    local ccar = getPedOccupiedVehicle(source)
    local cena = 7000000
    
    if getElementData(ccar, "vehicle:ownedPlayer") == getElementData(client, "player:uid") then
    if hajs < cena then triggerClientEvent(client, "onClientAddNotification", client, "Nie sta? Ci? aby zakupi? tej PaintJob!", "error") return end
    local id = getElementData(ccar, "vehicle:id")
    if not id then triggerClientEvent(client, "onClientAddNotification", client, "To nie jest pojazd prywatny!", "error") return end
    local pj = getVehiclePaintjob(ccar)
    if pj == 0 then triggerClientEvent(client, "onClientAddNotification", client, "Posidasz ju? ten paintjob!", "error") return end
    setVehiclePaintjob(ccar, 0)
    takePlayerMoney(source, cena)
    exports["ogrpg-db"]:dbSet("update ez_logi set ile=ile+1 where usluga=? limit 1", "pj0")
    else
        triggerClientEvent(client, "onClientAddNotification", client, "To nie jest Tw?j pojazd!", "warning")
    end
end)

addEvent("pj1", true)
addEventHandler("pj1", getRootElement(), function()
    local hajs = getPlayerMoney(source)
    local ccar = getPedOccupiedVehicle(source)
    local cena = 7000000
    
    if getElementData(ccar, "vehicle:ownedPlayer") == getElementData(client, "player:uid") then
    if hajs < cena then triggerClientEvent(client, "onClientAddNotification", client, "Nie sta? Ci? aby zakupi? tej PaintJob!", "error") return end
    local id = getElementData(ccar, "vehicle:id")
    if not id then triggerClientEvent(client, "onClientAddNotification", client, "To nie jest pojazd prywatny!", "error") return end
    local pj = getVehiclePaintjob(ccar)
    if pj == 1 then triggerClientEvent(client, "onClientAddNotification", client, "Posidasz ju? ten paintjob!", "error") return end
    setVehiclePaintjob(ccar, 1)
    takePlayerMoney(source, cena)
    exports["ogrpg-db"]:dbSet("update ez_logi set ile=ile+1 where usluga=? limit 1", "pj1")
    else
        triggerClientEvent(client, "onClientAddNotification", client, "To nie jest Tw?j pojazd!", "warning")
    end
end)

addEvent("pj2", true)
addEventHandler("pj2", getRootElement(), function()
    local hajs = getPlayerMoney(source)
    local ccar = getPedOccupiedVehicle(source)
    local cena = 7000000
    
    if getElementData(ccar, "vehicle:ownedPlayer") == getElementData(client, "player:uid") then
    if hajs < cena then triggerClientEvent(client, "onClientAddNotification", client, "Nie sta? Ci? aby zakupi? tej PaintJob!", "error") return end
    local id = getElementData(ccar, "vehicle:id")
    if not id then triggerClientEvent(client, "onClientAddNotification", client, "To nie jest pojazd prywatny!", "error") return end
    local pj = getVehiclePaintjob(ccar)
    if pj == 2 then triggerClientEvent(client, "onClientAddNotification", client, "Posidasz ju? ten paintjob!", "error") return end
    setVehiclePaintjob(ccar, 2)
    takePlayerMoney(source, cena)
    exports["ogrpg-db"]:dbSet("update ez_logi set ile=ile+1 where usluga=? limit 1", "pj2")
    else
        triggerClientEvent(client, "onClientAddNotification", client, "To nie jest Tw?j pojazd!", "warning")
    end
end)

addEvent("pj3", true)
addEventHandler("pj3", getRootElement(), function()
    local hajs = getPlayerMoney(source)
    local ccar = getPedOccupiedVehicle(source)
    local cena = 0
    
    if getElementData(ccar, "vehicle:ownedPlayer") == getElementData(client, "player:uid") then
    if hajs < cena then triggerClientEvent(client, "onClientAddNotification", client, "Nie sta? Ci? aby zakupi? tej PaintJob!", "error") return end
    local id = getElementData(ccar, "vehicle:id")
    if not id then triggerClientEvent(client, "onClientAddNotification", client, "To nie jest pojazd prywatny!", "error") return end
    local pj = getVehiclePaintjob(ccar)
    if pj == 3 then triggerClientEvent(client, "onClientAddNotification", client, "Posidasz ju? ten paintjob!", "error") return end
    setVehiclePaintjob(ccar, 3)
    takePlayerMoney(source, cena)
    exports["ogrpg-db"]:dbSet("update ez_logi set ile=ile+1 where usluga=? limit 1", "pj3")
    else
        triggerClientEvent(client, "onClientAddNotification", client, "To nie jest Tw?j pojazd!", "warning")
    end
end)

addEvent("pjx", true)
addEventHandler("pjx", getRootElement(), function()
    local hajs = getPlayerMoney(source)
    local ccar = getPedOccupiedVehicle(source)
    local cena = 0
    
    if getElementData(ccar, "vehicle:ownedPlayer") == getElementData(client, "player:uid") then
    if hajs < cena then triggerClientEvent(client, "onClientAddNotification", client, "Nie sta? Ci? aby zakupi? tej PaintJob!", "error") return end
    local id = getElementData(ccar, "vehicle:id")
    if not id then triggerClientEvent(client, "onClientAddNotification", client, "To nie jest pojazd prywatny!", "error") return end
    setVehiclePaintjob(ccar, 3)
    takePlayerMoney(source, cena)
    exports["ogrpg-db"]:dbSet("update ez_logi set ile=ile+1 where usluga=? limit 1", "pjx")
    else
        triggerClientEvent(client, "onClientAddNotification", client, "To nie jest Tw?j pojazd!", "warning")
    end
end)


main_c.lua

local screenSize = Vector2(guiGetScreenSize())
local ticks = {alphaTick = getTickCount(), animTick = getTickCount(), upperTick = getTickCount(), gui = {getTickCount(), getTickCount(), getTickCount()}}
local data = {showed = false, upper = false, upperLock = false, gridlist = false, edits = {}, actual = false, link}
local serials = {}

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

local function scaleElement(sx, sy)
    return (screenSize.x - sx)/2, (screenSize.y - sy)/2
end

local icon_x, icon_y = scaleElement(128, 128)
local function drawGUI()
    local up = interpolateBetween(100, 0, 0, 0, 0, 0, (getTickCount()-ticks.animTick)/2000, "OutBack") 

    if anim == "fadein" then
        progress = (getTickCount()-ticks.alphaTick)/1000
        alpha = interpolateBetween(alpha, 0, 0, 255, 0, 0, progress, "Linear")
        if alpha == 255 then
            ticks.alphaTick = getTickCount()
            anim = nil
        end
    elseif anim == "fadeout" then
        progress = (getTickCount()-ticks.alphaTick)/500
        alpha = interpolateBetween(alpha, 0, 0, 0, 0, 0, progress, "Linear")
        if alpha == 0 then
            removeEventHandler("onClientRender", root, drawGUI)
            ticks.alphaTick = nil
            anim = nil
        end
    end
    
    if isMouseInPosition(icon_x-300, icon_y, 128, 128) then color_one_down = {150, 150, 150} else color_one_down = {255, 255, 255} end
    if isMouseInPosition(icon_x-150, icon_y, 128, 128) then color_two_down = {150, 150, 150} else color_two_down = {255, 255, 255} end
    if isMouseInPosition(icon_x, icon_y, 128, 128) then color_three_down = {150, 150, 150} else color_three_down = {255, 255, 255} end
    if isMouseInPosition(icon_x+150, icon_y, 128, 128) then color_four_down = {150, 150, 150} else color_four_down = {255, 255, 255} end
    if isMouseInPosition(icon_x+300, icon_y, 128, 128) then color_five_down = {150, 150, 150} else color_five_down = {255, 255, 255} end
    
    if not data.upper then
        dxDrawImage(icon_x-300, icon_y+up, 128, 128, "images/pj0.png", 0, 0, 0, tocolor(color_one_down[1], color_one_down[2], color_one_down[3], alpha), false)
        dxDrawImage(icon_x-150, icon_y+up, 128, 128, "images/pj1.png", 0, 0, 0, tocolor(color_two_down[1], color_two_down[2], color_two_down[3], alpha), false)
        dxDrawImage(icon_x, icon_y+up, 128, 128, "images/pj2.png", 0, 0, 0, tocolor(color_three_down[1], color_three_down[2], color_three_down[3], alpha), false)
        dxDrawImage(icon_x+150, icon_y+up, 128, 128, "images/pj3.png", 0, 0, 0, tocolor(color_four_down[1], color_four_down[2], color_four_down[3], alpha), false)
        dxDrawImage(icon_x+300, icon_y+up, 128, 128, "images/pjx.png", 0, 0, 0, tocolor(color_five_down[1], color_five_down[2], color_five_down[3], alpha), false)
    else
    if not data.upperLock then
        progress = (getTickCount()-ticks.upperTick)/1500
        change = interpolateBetween(300, 0, 0, 0, 0, 0, progress, "Linear")
        dxDrawImage(icon_x-300, icon_y-300+change, 128, 128, "images/pj0png", 0, 0, 0, tocolor(color_one_down[1], color_one_down[2], color_one_down[3], alpha), false)
        dxDrawImage(icon_x-150, icon_y-300+change, 128, 128, "images/pj1.png", 0, 0, 0, tocolor(color_two_down[1], color_two_down[2], color_two_down[3], alpha), false)
        dxDrawImage(icon_x, icon_y-300+change, 128, 128, "images/pj2.png", 0, 0, 0, tocolor(color_three_down[1], color_three_down[2], color_three_down[3], alpha), false)
        dxDrawImage(icon_x+150, icon_y-300+change, 128, 128, "images/pj3.png", 0, 0, 0, tocolor(color_four_down[1], color_four_down[2], color_four_down[3], alpha), false)
        dxDrawImage(icon_x+300, icon_y-300+change, 128, 128, "images/pjx.png", 0, 0, 0, tocolor(color_five_down[1], color_five_down[2], color_five_down[3], alpha), false)
    else
        dxDrawImage(icon_x-300, icon_y-300, 128, 128, "images/pj0.png", 0, 0, 0, tocolor(color_one_down[1], color_one_down[2], color_one_down[3], alpha), false)
        dxDrawImage(icon_x-150, icon_y-300, 128, 128, "images/pj1.png", 0, 0, 0, tocolor(color_two_down[1], color_two_down[2], color_two_down[3], alpha), false)
        dxDrawImage(icon_x, icon_y-300, 128, 128, "images/pj2.png", 0, 0, 0, tocolor(color_three_down[1], color_three_down[2], color_three_down[3], alpha), false)
        dxDrawImage(icon_x+150, icon_y-300, 128, 128, "images/pj3.png", 0, 0, 0, tocolor(color_four_down[1], color_four_down[2], color_four_down[3], alpha), false)
        dxDrawImage(icon_x+300, icon_y-300, 128, 128, "images/pjx.png", 0, 0, 0, tocolor(color_five_down[1], color_five_down[2], color_five_down[3], alpha), false)
    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("onClientMarkerHit", resourceRoot, function(player, dimension)
    if player == localPlayer and dimension then
        if player.vehicle then
            if player.vehicle.controller == player then
                if player.vehicle.health > 800 then
                    showCursor(true, false)
                    --showChat(false)
                    alpha = 0
                    anim = "fadein"
                    --showChat(false)
                    showCursor(true, false)
                    ticks.animTick = getTickCount()
                    ticks.alphaTick = getTickCount()
                    player:setData("player:blackwhite", true)
                    player:setData("player:hud_visible", true)
                    setPlayerHudComponentVisible("radar", false)
                    addEventHandler("onClientRender", root, drawGUI)
                else
                    triggerEvent("onClientAddNotification", player, "Tw?j pojazd nie jest jest wystarczaj?co sprawny!", "error")
                end
            end
        end
    end
end)

addEventHandler("onClientMarkerLeave", resourceRoot, function(player, dimension)
    if player == localPlayer and dimension then
        showCursor(false)
        --showChat(true)
        player:setData("player:blackwhite", false)
        player:setData("player:hud_visible", false)
        setPlayerHudComponentVisible("radar", true)
        if isEventHandlerAdded("onClientRender", root, drawGUI) then removeEventHandler("onClientRender", root, drawGUI) end
    end
end)

local player = getLocalPlayer()

addEventHandler("onClientClick", root, function(button, state)
    if button == "left" and state == "down" then
        if isEventHandlerAdded("onClientRender", root, drawGUI) then
            if isMouseInPosition(icon_x-300, icon_y, 128, 128) then
                    closeGUI()
                    triggerServerEvent ("pj0", player, player)
                elseif isMouseInPosition(icon_x-150, icon_y, 128, 128) then
                    closeGUI()
                    triggerServerEvent ("pj1", player, player)
                elseif isMouseInPosition(icon_x, icon_y, 128, 128) then
                    closeGUI()
                    triggerServerEvent ("pj2", player, player)
                elseif isMouseInPosition(icon_x+150, icon_y, 128, 128) then
                    closeGUI()
                    triggerServerEvent ("pj3", player, player)
                elseif isMouseInPosition(icon_x+300, icon_y, 128, 128) then
                    closeGUI()
                    triggerServerEvent ("pjx", player, player)
                end
            end
        end
end)


Za dobr? odpowied? stawiam zimne :piwo: :piwo: :piwo:

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-13, 13:53


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Kod, kt?ry wys?a?e? dotyczy montowania pointjob?w.

Postaw piwo autorowi tego posta
 

 
Tagi: usuwanie :: możliwośći :: przecho
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