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

Wysłany: 2020-04-29, 01:37


HEATEX







Wiek: 25
Na forum: 2250 dni
Posty: 109
Nick w MP: HEATEX

Piwa: 1336

Respekt: 50

Ostrzeżeń: 20%
Witam chcialbym zrobic tak aby pobieralo hajs z banku zamiast z gotowki w skrypcie na mk
s.lua

elements = {}
elements["positions"] = {
    ["EZ 1"]={
        marker = {1249.42, -1824.1813.41},
        cuboid = {1249.42, -1824.1813.415},
        text "Monta? wzmocnie?"
    }
}

local napis=createElement("text")
setElementData(napis"name""Dost?pne ulepszenia\n(brak mo?liwo??i demonta?u)\n\nUlepszenie silnika - 50kk\nUlepszenie silnika - 99kk\nNitro sta?e - 90kk")
setElementPosition(napis1249.42, -1824.1813.5)

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"3326412850)
end

addEvent("mk1"true)
addEventHandler("mk1"getRootElement(), function()
    local hajs getPlayerMoney(source)
    local ccar getPedOccupiedVehicle(source)
    local cena 50000000
    
    if getElementData(ccar"vehicle:ownedPlayer") == getElementData(client"player:sid"then
        if hajs cena then triggerClientEvent(client"onClientAddNotification"client"Nie sta? Ci? aby zakupi? to ulepszenie!""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 qr exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND mk1=?",getElementData(ccar"vehicle:id"), "1")
        if #qr == 1 then triggerClientEvent(client, "onClientAddNotification", client, "Posiadasz ju? to ulepszenie!", "error") return end
        exports["pystories-vehicles"]:onSaveVehicle(ccar)
        destroyElement(ccar)
        exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET parking=1,tp_to_parking=? WHERE id=?","Eazy Workshop - US1"id)
        exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET mk1=1 WHERE id=?"id)
        triggerClientEvent(client"onClientAddNotification"client"Pomy?lnie zamontowano \n'Ulepszenie Silnika (poz. 1)""success")
        takePlayerMoney(sourcecena)
        exports["pystories-db"]:dbSet("update ez_logi set ile=ile+1 where usluga=? limit 1","us1")
    else
        triggerClientEvent(client"onClientAddNotification"client"To nie jest Tw?j pojazd!""warning")
    end
end)

addEvent("mk2"true)
addEventHandler("mk2"getRootElement(), function()
    local hajs getPlayerMoney(source)
    local ccar getPedOccupiedVehicle(source)
    local cena 99000000
    
    if getElementData(ccar"vehicle:ownedPlayer") == getElementData(client"player:sid"then
    if hajs cena then triggerClientEvent(client"onClientAddNotification"client"Nie sta? Ci? aby zakupi? to ulepszenie!""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 qr exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND mk2=?",getElementData(ccar"vehicle:id"), "1")
    if #qr == 1 then triggerClientEvent(client, "onClientAddNotification", client, "Posiadasz ju? to ulepszenie!", "error") return end
    exports["pystories-vehicles"]:onSaveVehicle(ccar)
    destroyElement(ccar)
    exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET parking=1,tp_to_parking=? WHERE id=?","Eazy Workshop - US2"id)
    exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET mk2=1 WHERE id=?"id)
    triggerClientEvent(client"onClientAddNotification"client"Pomy?lnie zamontowano 'Ulepszenie Silnika (poz. 2)'""success")
    takePlayerMoney(sourcecena)
    exports["pystories-db"]:dbSet("update ez_logi set ile=ile+1 where usluga=? limit 1""us2")
    else
        triggerClientEvent(client"onClientAddNotification"client"To nie jest Tw?j pojazd!""warning")
    end
end)

addEvent("nitro"true)
addEventHandler("nitro"getRootElement(), function()
    local hajs getPlayerMoney(source)
    local ccar getPedOccupiedVehicle(source)
    local tuning getVehicleUpgradeOnSlot(ccar,8)
    local cena 90000000

    if getElementData(ccar"vehicle:ownedPlayer") == getElementData(client"player:sid"then
    if tuning == 1010 then triggerClientEvent(client"onClientAddNotification"client"Posiadasz ju? nitro!""error") return end
    if hajs cena then triggerClientEvent(client"onClientAddNotification"client"Nie sta? Ci? aby zakupi? to ulepszenie!""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
    addVehicleUpgrade(ccar,1010)
    takePlayerMoney(sourcecena)
    exports["pystories-db"]:dbSet("update ez_logi set ile=ile+1 where usluga=? limit 1""nitro")
    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 falseupper falseupperLock falsegridlist falseedits = {}, actual falselink}
local serials = {}

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

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-150icon_y128128then color_one_down = {36175178} else color_one_down = {255255255end
    if isMouseInPosition(icon_xicon_y128128then color_two_down = {36175178} else color_two_down = {255255255end
    if isMouseInPosition(icon_x+150icon_y128128then color_three_down = {36175178} else color_three_down = {255255255end
    if isMouseInPosition(icon_x-150icon_y-300128128then color_one_up = {36175178} else color_one_up = {255255255end
    if isMouseInPosition(icon_xicon_y-300128128then color_two_up = {36175178} else color_two_up = {255255255end
    if isMouseInPosition(icon_x+150icon_y-300128128then color_three_up = {36175178} else color_three_up = {255255255end
    
    if not data.upper then
        dxDrawImage(icon_x-150icon_y+up128128"images/mk1.png"000tocolor(color_one_down[1], color_one_down[2], color_one_down[3], alpha), false)
        dxDrawImage(icon_xicon_y+up128128"images/mk2.png"000tocolor(color_two_down[1], color_two_down[2], color_two_down[3], alpha), false)
        dxDrawImage(icon_x+150icon_y+up128128"images/nitro.png"000tocolor(color_three_down[1], color_three_down[2], color_three_down[3], alpha), false)
    else
    if not data.upperLock then
        progress = (getTickCount()-ticks.upperTick)/1500
        change interpolateBetween(30000000progress"Linear")
        dxDrawImage(icon_x-150icon_y-300+change128128"images/mk1.png"000tocolor(color_one_up[1], color_one_up[2], color_one_up[3], alpha), false)
        dxDrawImage(icon_xicon_y-300+change128128"images/mk2.png"000tocolor(color_two_up[1], color_two_up[2], color_two_up[3], alpha), false)
        dxDrawImage(icon_x+150icon_y-300+change128128"images/nitro.png"000tocolor(color_three_up[1], color_three_up[2], color_three_up[3], alpha), false)
    else
        dxDrawImage(icon_x-150icon_y-300128128"images/mk1.png"000tocolor(color_one_up[1], color_one_up[2], color_one_up[3], alpha), false)
        dxDrawImage(icon_xicon_y-300128128"images/mk2.png"000tocolor(color_two_up[1], color_two_up[2], color_two_up[3], alpha), false)
        dxDrawImage(icon_x+150icon_y-300128128"images/nitro.png"000tocolor(color_three_up[1], color_three_up[2], color_three_up[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(playerdimension)
    if player == localPlayer and dimension then
        if player.vehicle then
            if player.vehicle.controller == player then
                if player.vehicle.health 800 then
                    showCursor(truefalse)
                    --showChat(false)
                    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)
                else
                    triggerEvent("onClientAddNotification"player"Tw?j pojazd nie jest jest wystarczaj?co sprawny!""error")
                end
            end
        end
    end
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(playerdimension)
    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"rootdrawGUIthen removeEventHandler("onClientRender"rootdrawGUIend
    end
end)

local player getLocalPlayer()

addEventHandler("onClientClick"root, function(buttonstate)
    if button == "left" and state == "down" then
        if isEventHandlerAdded("onClientRender"rootdrawGUIthen
            if isMouseInPosition(icon_x-150icon_y128128then
                    closeGUI()
                    triggerServerEvent ("mk1"playerplayer)
                elseif isMouseInPosition(icon_xicon_y128128then
                    closeGUI()
                    triggerServerEvent ("mk2"playerplayer)
                elseif isMouseInPosition(icon_x+150icon_y128128then
                    closeGUI()
                    triggerServerEvent ("nitro"playerplayer)
                end
            end
        end
end)

defs_c.lua

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

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


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-04-29, 08:27


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-04-29, 14:29


vAnimo

Zielony w luła






Wiek: 19
Na forum: 2312 dni
Posty: 165
Nick w MP: vAnimo

Piwa: 882

Respekt: 70

Kod:

addEvent("mk2", true)
addEventHandler("mk2", getRootElement(), function()
local hajs=exports['DB2']:pobierzWyniki("SELECT bank_money FROM pystories-users WHERE id=?", getElementData(client,"player:sid"))
local ccar = getPedOccupiedVehicle(source)
local cena = 99000000

if getElementData(ccar, "vehicle:ownedPlayer") == getElementData(client, "player:sid") then
if tonumber(hajs.bank_money) < cena then triggerClientEvent(client, "onClientAddNotification", client, "Nie sta? Ci? aby zakupi? to ulepszenie!", "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 qr = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND mk2=?",getElementData(ccar, "vehicle:id"), "1")
if #qr == 1 then triggerClientEvent(client, "onClientAddNotification", client, "Posiadasz ju? to ulepszenie!", "error") return end
exports["pystories-vehicles"]:onSaveVehicle(ccar)
destroyElement(ccar)
exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET parking=1,tp_to_parking=? WHERE id=?","Eazy Workshop - US2", id)
exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET mk2=1 WHERE id=?", id)
triggerClientEvent(client, "onClientAddNotification", client, "Pomy?lnie zamontowano 'Ulepszenie Silnika (poz. 2)'", "success")



--takePlayerMoney(source, cena) # zamiast tego dajesz to

exports['pystories-db']:dbSet("UPDATE pystories_users SET bank_money=bank_money-? WHERE id=?", cena, getElementData(client,"player:sid"))

exports["pystories-db"]:dbSet("update ez_logi set ile=ile+1 where usluga=? limit 1", "us2")
else
triggerClientEvent(client, "onClientAddNotification", client, "To nie jest Tw?j pojazd!", "warning")
end
end)


Licze na zimne :piwo: :piwo:

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
HEATEX
Wysłany: 2020-05-14, 16:26


HEATEX







Wiek: 25
Na forum: 2250 dni
Posty: 109
Nick w MP: HEATEX

Piwa: 1336

Respekt: 50

Ostrzeżeń: 20%
Dzieki za pomoc zamykam oczywiscie zostawiam :piwo:

Postaw piwo autorowi tego posta
 

 
Tagi: ulepszanie :: mki :: bankomat
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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