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

Wysłany: 2020-08-07, 21:43


xyzzzikk

.gg






Wiek: 19
Na forum: 2915 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6564

Respekt: 30,5

Czesc, mam problem z bankomatami, tzn. wp?acaj? pieni?dze na konto lecz nie ma ich na koncie, kod:

s.lua
--[[
Skrypt zosta? wykonany przez:
   -Asper (nezymr69@gmail.com).

Na potrzeby serwera:
   -WestRPG (2018).

Jedyne i wy??czone prawo do u?ywania kodu ma serwer WestRPG oraz autor skryptu. (Asper)
]]

local db = exports['pystories-db']
local noti = exports['n_noti']
local duty = exports['pystories-admin']

local bankomaty = {
    {1254.51,740.46,10.82},
}

for i,v in ipairs(bankomaty) do
    local csp = createColSphere(v[1], v[2], v[3]-0.15, 1.15)
    local obj = createObject(2942, v[1]-0.05, v[2]+0.05, v[3]-0.4, 0, 0, v[4])

    local blip = createBlip(v[1], v[2], v[3], 0, 1, 255, 150, 0)
    setBlipVisibleDistance(blip, 500)

    if v[5] then
        setElementDimension(obj, v[5])
        setElementDimension(csp, v[5])
    end
end

function getBankMoney(player)
    local q = db:dbGet('select * from pystories_users where login=? limit 1', getPlayerName(player))
    if q and #q > 0 then
        return q[1]['bank_money']
    end
    return 0
end

function getNewsPay(player)
    local q = db:dbGet('select * from pystories_users where login=? limit 1', getPlayerName(player))
    if q and #q > 0 then
        return q[1]['nowe_przelewy']
    end
    return 0
end

function getBankAccount(player)
    local q = db:dbGet('select * from pystories_users where login=? limit 1', getPlayerName(player))
    if q and #q > 0 then
        return q[1]['konto_bankowe']
    end
    return 0
end

addEventHandler('onColShapeHit', resourceRoot, function(hit, dim)
    if not hit or hit and not isElement(hit) or hit and isElement(hit) and getElementType(hit) ~= 'player' or hit and isElement(hit) and getElementType(hit) == 'player' and isPedInVehicle(hit) or not dim then return end

    if getBankAccount(hit) == 0 then
        triggerClientEvent(hit, 'goBankomat', resourceRoot, getBankMoney(hit), getNewsPay(hit))
        db:dbSet('update pystories_users set nowe_przelewy=0 where login=?', getPlayerName(hit))
    else
        noti:noti("Nie posidasz konta bankowanego.","error",3000,hit)
    end
end)

function formatMoney(money)
    while true do
        money, i = string.gsub(money, '^(-?%d+)(%d%d%d)', '%1,%2')
        if i == 0 then
            break
        end
    end
    return money
end

addEvent('bankomat:akcja', true)
addEventHandler('bankomat:akcja', resourceRoot, function(action, money, login)
    if action == 'WPLAC' then
        if string.len(money) < 1 then
            noti:addNotification(client, 'Najpierw wprowad? sum?.', 'error')
            return
        elseif string.len(money) > 8 or not tonumber(money) or tonumber(money) and tonumber(money) < 1 then
            return
        end

        money = tonumber(money)
        money = math.floor(money)

        if getPlayerMoney(client) >= money then
            noti:addNotification(client, 'Pomy?lnie wp?acono '..formatMoney(money)..'$ na konto bankowe.', 'success')
            takePlayerMoney(client, money)
            db:dbSet('update pystories_users set bank_money=bank_money+?, money=? where login=?', money, getPlayerMoney(client), getPlayerName(client))
            duty:addLogs('przelew', formatMoney(money)..'$', client, 'WPLATA')
            triggerClientEvent(client, 'update:saldo', resourceRoot, getBankMoney(client))
        else
            noti:addNotification(client, 'Brak wystarczaj?cych ?rodk?w.', 'error')
        end
    elseif action == 'WYPLAC' then
        if string.len(money) < 1 then
            noti:addNotification(client, 'Najpierw wprowad? sum?.', 'error')
            return
        elseif string.len(money) > 8 or not tonumber(money) or tonumber(money) and tonumber(money) < 1 then
            return
        end

        money = tonumber(money)
        money = math.floor(money)

        if getBankMoney(client) >= money then
            noti:addNotification(client, 'Pomy?lnie wyp?acono '..formatMoney(money)..'$ z konta bankowego.', 'success')
            givePlayerMoney(client, money)
            db:dbSet('update pystories_users set bank_money=bank_money-?, money=? where login=?', money, getPlayerMoney(client), getPlayerName(client))
            duty:addLogs('przelew', formatMoney(money)..'$', client, 'WYPLATA')
            triggerClientEvent(client, 'update:saldo', resourceRoot, getBankMoney(client))
        else
            noti:addNotification(client, 'Brak wystarczaj?cych ?rodk?w.', 'error')
        end
    end
end)


c.lua
--[[
Skrypt zosta? wykonany przez:
   -Asper (nezymr69@gmail.com).

Na potrzeby serwera:
   -WestRPG (2018).

Jedyne i wy??czone prawo do u?ywania kodu ma serwer WestRPG oraz autor skryptu. (Asper)
]]

local dxLibary = exports['dxLibaryWest']
local anim = exports['anim']

local sw, sh = guiGetScreenSize()
local scale = Vector2(sw < 1920 and math.min(2, 1920 / sw) or 1, sh < 1080 and math.min(2, 1080 / sh) or 1)

local tick = getTickCount()
local type = 'join'
local lived = false

function isMouseIn(x, y, w, h)
    if not isCursorShowing() then return end

    local pos = {getCursorPosition()}
    pos[1],pos[2] = (pos[1]*sw),(pos[2]*sh)

    if pos[1] >= x and pos[1] <= (x+w) and pos[2] >= y and pos[2] <= (y+h) then
        return true
    end
    return false
end

local bankomat = {
    saldo = 0,
    icon = dxLibary:createTexture(':pystories-bankomaty/images/w-icon.png', 'dxt5', false, 'clamp'),
    code = 'math.random(0,99)',
    balance = 0,
}

function formatMoney(money)
    while true do
        money, i = string.gsub(money, '^(-?%d+)(%d%d%d)', '%1,%2')
        if i == 0 then
            break
        end
    end
    return money
end

function guiBankomat()
    if type == 'join' then
        a,lived = anim:animation(tick, 0, 255, 500, 'Linear')
        a2 = anim:animation(tick, 0, 230, 500, 'Linear')
    elseif type == 'quit' then
        a,lived = anim:animation(tick, 255, 0, 250, 'Linear')
        a2 = anim:animation(tick, 230, 0, 250, 'Linear')

        if not lived then
            removeEventHandler('onClientRender', root, guiBankomat)
        end
    end
     
    local siddgracz = getElementData(localPlayer, "player:sid")
    local srl = getPlayerSerial(localPlayer)
    dxLibary:dxLibary_createWindowAlpha(606/scale.x, 244/scale.y, 709/scale.x, 593/scale.y, a)

    dxDrawImage(600/scale.x, 200/scale.y, 45/scale.x, 33/scale.y, bankomat['icon'], 0, 0, 0, tocolor(255, 255, 255, a), false)
    dxLibary:dxLibary_text('WestBank', 650/scale.x, 184/scale.y, 819/scale.x, 234/scale.y, tocolor(237, 237, 237, a), 10, 'default', 'left', 'bottom', false, false, false, false, false)

    dxLibary:dxLibary_text(getPlayerName(localPlayer), 637/scale.x, 244/scale.y, 819/scale.x, 294/scale.y, tocolor(237, 237, 237, a), 6, 'default', 'left', 'bottom', false, false, false, true, false)
    dxLibary:dxLibary_text('W?A?CICIEL KARTY', 637/scale.x, 294/scale.y, 768/scale.x, 319/scale.y, tocolor(237, 237, 237, a), 1, 'default', 'left', 'top', false, false, false, false, false)

    dxLibary:dxLibary_text(''..siddgracz..'9162'..siddgracz..' 2020', 637/scale.x, 334/scale.y, 819/scale.x, 384/scale.y, tocolor(237, 237, 237, a), 6, 'default', 'left', 'bottom', false, false, false, false, false)
    dxLibary:dxLibary_text('NUMER KARTY', 637/scale.x, 384/scale.y, 768/scale.x, 409/scale.y, tocolor(237, 237, 237, a), 1, 'default', 'left', 'top', false, false, false, false, false)

    dxLibary:dxLibary_createButtonAlpha('Wp?a?', 629/scale.x, 650/scale.y, 215/scale.x, 50/scale.y, 3, a2)
    dxLibary:dxLibary_createButtonAlpha('Wyp?a?', 629/scale.x, 707/scale.y, 215/scale.x, 50/scale.y, 3, a2)
    dxLibary:dxLibary_createButtonAlpha('Anuluj', 629/scale.x, 765/scale.y, 215/scale.x, 50/scale.y, 3, a2)

    dxLibary:dxLibary_text('$'..formatMoney(getPlayerMoney(localPlayer)), 1002/scale.x, 265/scale.y, 1128/scale.x, 305/scale.y, tocolor(0, 255, 0, a), 8, 'default', 'center', 'center', false, false, false, false, false)
    dxLibary:dxLibary_text('$'..formatMoney(bankomat['saldo']), 1157/scale.x, 265/scale.y, 1283/scale.x, 305/scale.y, tocolor(0, 100, 255, a), 8, 'default', 'center', 'center', false, false, false, false, false)
    dxLibary:dxLibary_text('GOT?WKA', 1002/scale.x, 300/scale.y, 1128/scale.x, 328/scale.y, tocolor(237, 237, 237, a), 1, 'default', 'center', 'top', false, false, false, false, false)
    dxLibary:dxLibary_text('SALDO BANKOWE', 1157/scale.x, 300/scale.y, 1283/scale.x, 328/scale.y, tocolor(237, 237, 237, a), 1, 'default', 'center', 'top', false, false, false, false, false)

    dxDrawRectangle(1012/scale.x, 347/scale.y, 261/scale.x, 54/scale.y, tocolor(30, 30, 30, a), false)
    dxLibary:dxLibary_text('$', 1022/scale.x, 347/scale.y, 1114/scale.x, 401/scale.y, tocolor(0, 100, 255, a), 8, 'default', 'left', 'center', false, false, false, false, false)
    dxLibary:dxLibary_text(bankomat['balance'], 1171/scale.x, 347/scale.y, 1263/scale.x, 401/scale.y, tocolor(207, 206, 206, a), 8, 'default', 'right', 'center', false, false, false, false, false)

    for i = 1,9 do
        local sX = 0
        local sY = 75/scale.x * (i - 1)

        if i >= 4 and i <= 6 then
            sX = 75/scale.y
            sY = 75/scale.x * (i - 4)
        elseif i >= 7 and i <= 9 then
            sX = (75 * 2)/scale.y
            sY = 75/scale.x * (i - 7)
        end

        dxDrawRectangle(1033/scale.x + sY, 420/scale.y + sX, 64/scale.x, 64/scale.y, tocolor(30, 30, 30, a), false)
        dxLibary:dxLibary_text(i, 1033/scale.x + sY, 420/scale.y + sX, 64/scale.x + 1033/scale.x + sY, 64/scale.y + 420/scale.y + sX, tocolor(207, 206, 206, a), 5, 'default', 'center', 'center', false, false, false, false, false)
    end

    local sX = (75 * 3)/scale.y
    dxDrawRectangle(1033/scale.x, 420/scale.y + sX, 64/scale.x, 64/scale.y, tocolor(30, 30, 30, a), false)
    dxLibary:dxLibary_text('0', 1033/scale.x, 420/scale.y + sX, 64/scale.x + 1033/scale.x, 64/scale.y + 420/scale.y + sX, tocolor(207, 206, 206, a), 5, 'default', 'center', 'center', false, false, false, false, false)

    local sY = 75/scale.x
    dxDrawRectangle(1033/scale.x + sY, 420/scale.y + sX, 64/scale.x, 64/scale.y, tocolor(30, 30, 30, a), false)
    dxLibary:dxLibary_text('C', 1033/scale.x + sY, 420/scale.y + sX, 64/scale.x + 1033/scale.x + sY, 64/scale.y + 420/scale.y + sX, tocolor(207, 206, 206, a), 5, 'default', 'center', 'center', false, false, false, false, false)

    local sY = (75 * 2)/scale.x
    dxDrawRectangle(1033/scale.x + sY, 420/scale.y + sX, 64/scale.x, 64/scale.y, tocolor(30, 30, 30, a), false)
    dxLibary:dxLibary_text('&#8592;', 1033/scale.x + sY, 420/scale.y + sX, 64/scale.x + 1033/scale.x + sY, 64/scale.y + 420/scale.y + sX, tocolor(207, 206, 206, a), 5, 'default', 'center', 'center', false, false, false, false, false)
end

function key(key, press)
    if press then
        if tonumber(key) and tonumber(key) >= 0 and tonumber(key) <= 9 then
            if tonumber(bankomat['balance']) == 0 then
                bankomat['balance'] = ''
            end

            if bankomat['balance']:len() < 8 then
                bankomat['balance'] = bankomat['balance'] .. tonumber(key)
            end
        elseif key == 'backspace' then
            bankomat['balance'] = string.sub(bankomat['balance'], 1, string.len(bankomat['balance']) - 1)

            if bankomat['balance'] == '' then
                bankomat['balance'] = 0
            end
        elseif key == 'c' then
            bankomat['balance'] = 0
        end
    end
end

function clicked(btn, state)
    if btn ~= 'state' and state ~= 'down' then return end

    for i = 1,9 do
        local sX = 0
        local sY = 75/scale.x * (i - 1)

        if i >= 4 and i <= 6 then
            sX = 75/scale.y
            sY = 75/scale.x * (i - 4)
        elseif i >= 7 and i <= 9 then
            sX = (75 * 2)/scale.y
            sY = 75/scale.x * (i - 7)
        end

        if isMouseIn(1033/scale.x + sY, 420/scale.y + sX, 64/scale.x, 64/scale.y) then
            if tonumber(bankomat['balance']) == 0 then
                bankomat['balance'] = ''
            end

            if bankomat['balance']:len() < 8 then
                bankomat['balance'] = bankomat['balance'] .. i
            end
        end
    end

    local sX = (75 * 3)/scale.y
    local sY = 75/scale.x
    local _sY = (75 * 2)/scale.x
    if isMouseIn(1033/scale.x, 420/scale.y + sX, 64/scale.x, 64/scale.y) then
        if tonumber(bankomat['balance']) == 0 then
            bankomat['balance'] = ''
        end

        if bankomat['balance']:len() < 8 and tonumber(bankomat['balance']) ~= 0 then
            bankomat['balance'] = bankomat['balance'] .. '0'
        end
    elseif isMouseIn(1033/scale.x + sY, 420/scale.y + sX, 64/scale.x, 64/scale.y) then
        bankomat['balance'] = 0
    elseif isMouseIn(1033/scale.x + _sY, 420/scale.y + sX, 64/scale.x, 64/scale.y) then
        bankomat['balance'] = string.sub(bankomat['balance'], 1, string.len(bankomat['balance']) - 1)

        if bankomat['balance'] == '' then
            bankomat['balance'] = 0
        end
    elseif isMouseIn(629/scale.x, 765/scale.y, 215/scale.x, 50/scale.y) then
        type = 'quit'
        tick = getTickCount()
        setElementFrozen(localPlayer, false)
        showChat(true)
        showCursor(false)
        removeEventHandler('onClientClick', root, clicked)
        removeEventHandler('onClientKey', root, key)
        setElementData(localPlayer, 'grey_shader', 0)
        setElementData(localPlayer, 'pokaz:hud', true)
        guiSetInputEnabled(false)
    elseif isMouseIn(1183/scale.x - 35/scale.x, 646/scale.y, 64/scale.y + 20/scale.x, 35/scale.y) then
        bankomat['balance'] = string.sub(bankomat['balance'], 1, string.len(bankomat['balance'])-1)

        if bankomat['balance'] == '' then
            bankomat['balance'] = 0
        end
    elseif isMouseIn(1033/scale.x + 15/scale.x, 646/scale.y, 64/scale.x + 20/scale.x, 35/scale.y) then
        bankomat['balance'] = 0
    elseif isMouseIn(629/scale.x, 650/scale.y, 215/scale.x, 50/scale.y) then
        triggerServerEvent('bankomat:akcja', resourceRoot, 'WPLAC', tonumber(bankomat['balance']), false)
    elseif isMouseIn(629/scale.x, 707/scale.y, 215/scale.x, 50/scale.y) then
        triggerServerEvent('bankomat:akcja', resourceRoot, 'WYPLAC', tonumber(bankomat['balance']), false)
    end
end

addEvent('goBankomat', true)
addEventHandler('goBankomat', resourceRoot, function(money)
    if lived then return end

    if money then
        bankomat['saldo'] = money
    end

    addEventHandler('onClientRender', root, guiBankomat)
    setElementData(localPlayer, 'grey_shader', 1)
    setElementData(localPlayer, 'pokaz:hud', false)
    setElementFrozen(localPlayer, true)
    addEventHandler('onClientClick', root, clicked)
    addEventHandler('onClientKey', root, key)
    showChat(false)
    showCursor(true)
    tick = getTickCount()
    type = 'join'

    guiSetInputEnabled(true)

    if bankomat['code'] == '?' then
        bankomat['code'] = getPlayerName(localPlayer)--string.sub(getPlayerSerial(localPlayer), 1, 4)..' '..string.sub(getElementData(localPlayer, 'player:registerdate'), 1, 4)..' '..string.format('%04d', string.sub(getElementData(localPlayer, 'player:sid'), 1, 4))..' 2020'
    end

    bankomat['balance'] = 0
end)

addEvent('update:saldo', true)
addEventHandler('update:saldo', resourceRoot, function(saldo)
    bankomat['saldo'] = saldo
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-07, 22:53


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Kolumny w bazie i element daty lub nazwa gracza si? zgadza? B??dy db3?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-07, 23:06


xyzzzikk

.gg






Wiek: 19
Na forum: 2915 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6564

Respekt: 30,5

"Wilq" napisał/a:

Kolumny w bazie i element daty lub nazwa gracza si? zgadza? B??dy db3?


Tak, zgadzaj? si? a b??d?w w DB3 nie ma

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-07, 23:10


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Pieni?dze dodaj? si? do kolumny bank_money, a nie ma ich w kolumnie money (lub vice versa)?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-07, 23:21


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4536 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

Znajdz sobie i sprobuj podmienic ten u?amek kodu


if getPlayerMoney(source) >= tonumber(money) then
    noti:addNotification(source, 'Pomy?lnie wp?acono '..formatMoney(money)..'$ na konto bankowe.', 'success')
    takePlayerMoney(source, tonumber(money))
    db:dbSet('UPDATE pystories_users SET bank_money=bank_money+?, money=? WHERE login=?', tonumber(money), getPlayerMoney(source), getPlayerName(source))
    duty:addLogs('przelew', formatMoney(money)..'$', source, 'WPLATA')
    triggerClientEvent(source, 'update:saldo', resourceRoot, getBankMoney(source))
else
    noti:addNotification(source, 'Brak wystarczaj?cych ?rodk?w.', 'error')
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-08, 12:15


xyzzzikk

.gg






Wiek: 19
Na forum: 2915 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6564

Respekt: 30,5

"Wilq" napisał/a:

Pieni?dze dodaj? si? do kolumny bank_money, a nie ma ich w kolumnie money (lub vice versa)?

S? w kolumnie money, ale nie ma w bank_money,


"Shuffle" napisał/a:

if getPlayerMoney(source) >= tonumber(money) then
noti:addNotification(source, 'Pomy?lnie wp?acono '..formatMoney(money)..'$ na konto bankowe.', 'success')
takePlayerMoney(source, tonumber(money))
db:dbSet('UPDATE pystories_users SET bank_money=bank_money+?, money=? WHERE login=?', tonumber(money), getPlayerMoney(source), getPlayerName(source))
duty:addLogs('przelew', formatMoney(money)..'$', source, 'WPLATA')
triggerClientEvent(source, 'update:saldo', resourceRoot, getBankMoney(source))
else
noti:addNotification(source, 'Brak wystarczaj?cych ?rodk?w.', 'error')
end


Da?em to, i potym nawet wp?acanie nie dzia?a, a wczesniej wp?aca?o ale nie by?o tego w banku.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-08, 13:38


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4536 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

Dobra widz? ju? b??d za chwile ci podesle kod.

[ Dodano: 2020-08-08, 13:40 ]
Podmien i testuj

--[[
Skrypt zosta? wykonany przez:
   -Asper (nezymr69@gmail.com).

Na potrzeby serwera:
   -WestRPG (2018).

Jedyne i wy??czone prawo do u?ywania kodu ma serwer WestRPG oraz autor skryptu. (Asper)
]]

local db = exports['pystories-db']
local noti = exports['n_noti']
local duty = exports['pystories-admin']

local bankomaty = {
    {1254.51,740.46,10.82},
}

for i,v in ipairs(bankomaty) do
    local csp = createColSphere(v[1], v[2], v[3]-0.15, 1.15)
    local obj = createObject(2942, v[1]-0.05, v[2]+0.05, v[3]-0.4, 0, 0, v[4])

    local blip = createBlip(v[1], v[2], v[3], 0, 1, 255, 150, 0)
    setBlipVisibleDistance(blip, 500)

    if v[5] then
        setElementDimension(obj, v[5])
        setElementDimension(csp, v[5])
    end
end

function getBankMoney(player)
    local q = db:dbGet('select * from pystories_users where login=? limit 1', getPlayerName(player))
    if q and #q > 0 then
        return q[1]['bank_money']
    end
    return 0
end

function getNewsPay(player)
    local q = db:dbGet('select * from pystories_users where login=? limit 1', getPlayerName(player))
    if q and #q > 0 then
        return q[1]['nowe_przelewy']
    end
    return 0
end

function getBankAccount(player)
    local q = db:dbGet('select * from pystories_users where login=? limit 1', getPlayerName(player))
    if q and #q > 0 then
        return q[1]['konto_bankowe']
    end
    return 0
end

addEventHandler('onColShapeHit', resourceRoot, function(hit, dim)
    if not hit or hit and not isElement(hit) or hit and isElement(hit) and getElementType(hit) ~= 'player' or hit and isElement(hit) and getElementType(hit) == 'player' and isPedInVehicle(hit) or not dim then return end

    if getBankAccount(hit) == 0 then
        triggerClientEvent(hit, 'goBankomat', resourceRoot, getBankMoney(hit), getNewsPay(hit))
        db:dbSet('update pystories_users set nowe_przelewy=0 where login=?', getPlayerName(hit))
    else
        noti:noti("Nie posidasz konta bankowanego.","error",3000,hit)
    end
end)

function formatMoney(money)
    while true do
        money, i = string.gsub(money, '^(-?%d+)(%d%d%d)', '%1,%2')
        if i == 0 then
            break
        end
    end
    return money
end

addEvent('bankomat:akcja', true)
addEventHandler('bankomat:akcja', resourceRoot, function(action, money, login)
    if action == 'WPLAC' then
        if string.len(money) < 1 then
            noti:addNotification(client, 'Najpierw wprowad? sum?.', 'error')
            return
        elseif string.len(money) > 8 or not tonumber(money) or tonumber(money) and tonumber(money) < 1 then
            return
        end

        money = tonumber(money)
        money = math.floor(money)

        if getPlayerMoney(client) >= money then
            noti:addNotification(client, 'Pomy?lnie wp?acono '..formatMoney(money)..'$ na konto bankowe.', 'success')
            takePlayerMoney(client, money)
            x=db:dbGet("SELECT * FROM pystories_users WHERE login=?",getPlayerName(client))
            w=dbPoll(x,-1)
            bank=tonumber(x[1].bank_money)+tonumber(money)
            db:dbSet('update pystories_users set bank_money=?, money=? where login=?', bank, getPlayerMoney(client), getPlayerName(client))
            duty:addLogs('przelew', formatMoney(money)..'$', client, 'WPLATA')
            triggerClientEvent(client, 'update:saldo', resourceRoot, getBankMoney(client))
        else
            noti:addNotification(client, 'Brak wystarczaj?cych ?rodk?w.', 'error')
        end
    elseif action == 'WYPLAC' then
        if string.len(money) < 1 then
            noti:addNotification(client, 'Najpierw wprowad? sum?.', 'error')
            return
        elseif string.len(money) > 8 or not tonumber(money) or tonumber(money) and tonumber(money) < 1 then
            return
        end

        money = tonumber(money)
        money = math.floor(money)

        if getBankMoney(client) >= money then
            noti:addNotification(client, 'Pomy?lnie wyp?acono '..formatMoney(money)..'$ z konta bankowego.', 'success')
            givePlayerMoney(client, money)
            db:dbSet('update pystories_users set bank_money=bank_money-?, money=? where login=?', money, getPlayerMoney(client), getPlayerName(client))
            duty:addLogs('przelew', formatMoney(money)..'$', client, 'WYPLATA')
            triggerClientEvent(client, 'update:saldo', resourceRoot, getBankMoney(client))
        else
            noti:addNotification(client, 'Brak wystarczaj?cych ?rodk?w.', 'error')
        end
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-08, 20:51


xyzzzikk

.gg






Wiek: 19
Na forum: 2915 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6564

Respekt: 30,5

"Shuffle" napisał/a:

Dobra widz? ju? b??d za chwile ci podesle kod.

[ Dodano: 2020-08-08, 13:40 ]
Podmien i testuj

--[[
Skrypt zosta? wykonany przez:
   -Asper (nezymr69@gmail.com).

Na potrzeby serwera:
   -WestRPG (2018).

Jedyne i wy??czone prawo do u?ywania kodu ma serwer WestRPG oraz autor skryptu. (Asper)
]]

local db = exports['pystories-db']
local noti = exports['n_noti']
local duty = exports['pystories-admin']

local bankomaty = {
    {1254.51,740.46,10.82},
}

for i,v in ipairs(bankomaty) do
    local csp = createColSphere(v[1], v[2], v[3]-0.15, 1.15)
    local obj = createObject(2942, v[1]-0.05, v[2]+0.05, v[3]-0.4, 0, 0, v[4])

    local blip = createBlip(v[1], v[2], v[3], 0, 1, 255, 150, 0)
    setBlipVisibleDistance(blip, 500)

    if v[5] then
        setElementDimension(obj, v[5])
        setElementDimension(csp, v[5])
    end
end

function getBankMoney(player)
    local q = db:dbGet('select * from pystories_users where login=? limit 1', getPlayerName(player))
    if q and #q > 0 then
        return q[1]['bank_money']
    end
    return 0
end

function getNewsPay(player)
    local q = db:dbGet('select * from pystories_users where login=? limit 1', getPlayerName(player))
    if q and #q > 0 then
        return q[1]['nowe_przelewy']
    end
    return 0
end

function getBankAccount(player)
    local q = db:dbGet('select * from pystories_users where login=? limit 1', getPlayerName(player))
    if q and #q > 0 then
        return q[1]['konto_bankowe']
    end
    return 0
end

addEventHandler('onColShapeHit', resourceRoot, function(hit, dim)
    if not hit or hit and not isElement(hit) or hit and isElement(hit) and getElementType(hit) ~= 'player' or hit and isElement(hit) and getElementType(hit) == 'player' and isPedInVehicle(hit) or not dim then return end

    if getBankAccount(hit) == 0 then
        triggerClientEvent(hit, 'goBankomat', resourceRoot, getBankMoney(hit), getNewsPay(hit))
        db:dbSet('update pystories_users set nowe_przelewy=0 where login=?', getPlayerName(hit))
    else
        noti:noti("Nie posidasz konta bankowanego.","error",3000,hit)
    end
end)

function formatMoney(money)
    while true do
        money, i = string.gsub(money, '^(-?%d+)(%d%d%d)', '%1,%2')
        if i == 0 then
            break
        end
    end
    return money
end

addEvent('bankomat:akcja', true)
addEventHandler('bankomat:akcja', resourceRoot, function(action, money, login)
    if action == 'WPLAC' then
        if string.len(money) < 1 then
            noti:addNotification(client, 'Najpierw wprowad? sum?.', 'error')
            return
        elseif string.len(money) > 8 or not tonumber(money) or tonumber(money) and tonumber(money) < 1 then
            return
        end

        money = tonumber(money)
        money = math.floor(money)

        if getPlayerMoney(client) >= money then
            noti:addNotification(client, 'Pomy?lnie wp?acono '..formatMoney(money)..'$ na konto bankowe.', 'success')
            takePlayerMoney(client, money)
            x=db:dbGet("SELECT * FROM pystories_users WHERE login=?",getPlayerName(client))
            w=dbPoll(x,-1)
            bank=tonumber(x[1].bank_money)+tonumber(money)
            db:dbSet('update pystories_users set bank_money=?, money=? where login=?', bank, getPlayerMoney(client), getPlayerName(client))
            duty:addLogs('przelew', formatMoney(money)..'$', client, 'WPLATA')
            triggerClientEvent(client, 'update:saldo', resourceRoot, getBankMoney(client))
        else
            noti:addNotification(client, 'Brak wystarczaj?cych ?rodk?w.', 'error')
        end
    elseif action == 'WYPLAC' then
        if string.len(money) < 1 then
            noti:addNotification(client, 'Najpierw wprowad? sum?.', 'error')
            return
        elseif string.len(money) > 8 or not tonumber(money) or tonumber(money) and tonumber(money) < 1 then
            return
        end

        money = tonumber(money)
        money = math.floor(money)

        if getBankMoney(client) >= money then
            noti:addNotification(client, 'Pomy?lnie wyp?acono '..formatMoney(money)..'$ z konta bankowego.', 'success')
            givePlayerMoney(client, money)
            db:dbSet('update pystories_users set bank_money=bank_money-?, money=? where login=?', money, getPlayerMoney(client), getPlayerName(client))
            duty:addLogs('przelew', formatMoney(money)..'$', client, 'WYPLATA')
            triggerClientEvent(client, 'update:saldo', resourceRoot, getBankMoney(client))
        else
            noti:addNotification(client, 'Brak wystarczaj?cych ?rodk?w.', 'error')
        end
    end
end)


Tak jak na pocz?tku, zabiera pieni?dze lecz nie dodaje do banku.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-08, 21:32


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4536 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

1. Sprawdz przez outputchatbox/print co zwraca zmienna "bank" ktora ci dalem.
2. Sprawdz czy typ tabeli bank_money to INTEGER

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-08, 21:38


xyzzzikk

.gg






Wiek: 19
Na forum: 2915 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6564

Respekt: 30,5

Troche poszpera?em, i b??d naprawi?em ten b??d, do zamkni?cia

Postaw piwo autorowi tego posta
 

 
Tagi: bankomaty
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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