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

Wysłany: 2019-08-26, 09:12


DaVeCS

Mapper






Wiek: 31
Na forum: 3386 dni
Posty: 193
Nick w MP: DaVe

Piwa: 59

Respekt: 70,5

Witam, chcia?bym zwi?kszy? limit pieni?dzy tak jak to jest zrobione na jednym serwerze, lecz nie wiem jak to zmieni?. m?g?by kto? pom?c?

Tutaj umieszczam kod:
s.lua
addEvent("onPlayerRequestATMInfo"true)
addEventHandler("onPlayerRequestATMInfo"resourceRoot, function()
    local dbid=getElementData(client,"player:uid")
    if not dbid then
        triggerClientEvent(client,"doFillATMInfo"resourceRootfalse)
        return
    end
    local sr=exports["ogrpg-db"]:dbGet("SELECT bank_money FROM ogrpg_users WHERE id=? LIMIT 1",dbid)
    if not sr or #sr < 1 then
        triggerClientEvent(client,"doFillATMInfo"resourceRootfalse)
        return
    end
    local sr=sr[1]
    triggerClientEvent(client,"doFillATMInfo"resourceRoottruetonumber(sr.bank_money))
end)

addEvent("doATMOperation"true)
addEventHandler("doATMOperation"resourceRoot, function(kwota)
    if type(kwota) ~= "number" then outputDebugString("error") return end
    if kwota>and kwota>getPlayerMoney(clientthen return end -- komunikat bledu po stronie klienta
    local dbid=getElementData(client,"player:uid")
    local sr=exports["ogrpg-db"]:dbGet("SELECT `bank_money` FROM `ogrpg_users` WHERE id=? LIMIT 1",dbid)
    if not sr or #sr < 1 then return end
    sr=tonumber(sr[1].bank_money)
    if not dbid then return end -- nie powinno sie zdarzyc
    if kwota>0 then
        if getPlayerMoney(client)<kwota then return end
        takePlayerMoney(clientkwota)
        exports["ogrpg-db"]:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+?? WHERE id=? LIMIT 1",tonumber(kwota),dbid)
        local sr=exports["ogrpg-db"]:dbGet("SELECT `bank_money` FROM `ogrpg_users` WHERE id=? LIMIT 1",dbid)
        if not sr or #sr < 1 then return end
        sr=tonumber(sr[1].bank_money)
        triggerEvent("admin:logs"rootstring.format("WPLATA %d DO bankomatu (UID : %d) STAN KONTA %d",math.abs(tonumber(kwota)),dbid,sr))
        outputChatBox("Wp?aci?e?/as pieni?dz? do bankomatu.",client255,255,255)
    elseif kwota<0 then
        if (sr<math.abs(kwota)) then
            outputChatBox("Nie posiadasz tyle ?rodk?w.",client255,0,0)
            return
        end
        exports["ogrpg-db"]:dbSet("UPDATE ogrpg_users SET bank_money=bank_money-?? WHERE id=? LIMIT 1",math.abs(tonumber(kwota)),dbid)
        local sr=exports["ogrpg-db"]:dbGet("SELECT `bank_money` FROM `ogrpg_users` WHERE id=? LIMIT 1",dbid)
        if not sr or #sr < 1 then return end
        sr=tonumber(sr[1].bank_money)
        triggerEvent("admin:logs"rootstring.format("WYPLATA %d z bankomatu (UID : %d) STAN KONTA %d",math.abs(tonumber(kwota)),dbid,sr))
        outputChatBox("Wyp?aci?e?/as pieni?dz? z bankomatu."client255255255)
        givePlayerMoney(clientmath.abs(kwota))
    end
end)


c.lua
--[[
@author Lukasz Biegaj <wielebny@bestplay.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
]]--


local bankomaty={
{2206.87,2761.86,10.82-0.40.000.0000},
{2864.46,2224.00,10.89-0.40.000.00, -900},
{2551.38,1971.98,10.82-0.40.000.0000},
{2477.04,1326.34,10.83-0.40.000.00180,0},
{1019.61,1353.81,10.82-0.4, -0.000.000,0},
{2191.27,2010.34,10.83-0.4, -0.000.00220,0},
{2137.43,2362.19,10.82-0.4, -0.000.00180,0},
{2173.911401.8111.06-0.4, -0.000.00, -90,0},
{1966.952476.6811.18-0.4, -0.000.00160,0},
{1650.472187.7110.82-0.4, -0.000.0090,0},
{2007.76, -2226.5913.55-0.4, -0.000.00180,0},
{463.10, -1327.4615.37-0.4, -0.000.00210,0},
{1467.94, -1766.2918.80-0.4, -0.000.0090,0},
{2568.61951.0110.85-0.4, -0.000.00, -90,0},
{1918.57,2124.75,10.82-0.4,0,0,90,0},
{-2381.23,-144.72,34.92,0,0,90,0},
{-2043.66,173.89,28.50,0,0,90,0},
{-2016.30,474.54,34.77,0,0,90,0},
{-1967.19,291.77,34.86,0,0,-90,0},
{-2210.54,1028.09,79.61,0,0,0,0},
{-1764.46,1200.65,24.72,0,0,0,0},
{-1648.64,1202.50,6.85,0,0,90,0},
{2819.33,973.46,10.75-0.7,0,0,0,0},
{-1683.24,689.33,24.49,0,0,0,0},
{-1532.94,2649.29,55.44,0,0,0,0},
{412.73,2539.60,16.13,0,0,0,0},
{213.63,87.65,4.55,0,0,0,0},
{116.47,-181.38,1.09,0,0,0,0},
{-1305.31,-621.69,13.84,0,0,0},
{1054.82,2095.04,10.42,0,0,-90},
{871.71,-28.06,62.40,0,0,0},
{775.66,1882.83,4.58,0,0,0},
{1619.69,1819.95,10.42,0,0,0},
{2284.47,2431.40,10.42,0,0,0},
{2873.13,2442.29,10.67,0,0,0},
{2299.96,1002.66,10.49,0,0,0},
{1508.40,2364.20,10.42,0,0,0},
{1368.62,1801.98,10.42,0,0,0},
{-1639.04,-2244.08,31.08,0,0,0},
{1600.79,1002.71,10.42,0,0,0},
{2335.08,1521.21,42.42,0,0,0},
}

for i,v in ipairs(bankomaty) do

    v.obiekt=createObject(2942,v[1],v[2],v[3],v[4],v[5],v[6])
    v.mapicon=createBlip(v[1],v[2],v[3], 5215,255,5,255, -10000150)
    setElementInterior(v.obiekt,v[7] or 0)
    setElementDimension(v.obiekt,v[8] or 0)
    setElementFrozen(v.obiekt,true)
    setObjectBreakable v.obiektfalse )
    v.cs=createColSphere(v[1],v[2],v[3]+11.5)
    setElementInterior(v.cs,v[7] or 0)
    setElementDimension(v.cs,v[8] or 0)
    v.text=createElement('text')
    setElementData(v.text,"name","Bankomat\nCzynny 24h/7")
    setElementPosition(v.text,v[1],v[2],v[3])
end

local screenWscreenH guiGetScreenSize()

local bw={}
bw.lbl1 guiCreateLabel(0.780.400.170.07,"Stan konta:\n0 PLN",true)
local font0_money guiCreateFont(":Sublime-NameTagi/droid-sans.ttf"12)
local normalFont guiCreateFont":Sublime-NameTagi/droid-sans.ttf"12 )
guiSetFont(bw.lbl1font0_money)    
guiLabelSetVerticalAlign(bw.lbl1,"center")
guiLabelSetHorizontalAlign(bw.lbl1,"center",false)


bw.edt1 guiCreateEdit(0.7750.6050.080.04,"0",true) --wplac

bw.edt2 guiCreateEdit(0.7750.5050.080.04,"0",true) --wyplac


guiSetVisible(bw.lbl1false)
guiSetVisible(bw.edt1false)
guiSetVisible(bw.edt2false)

panel false

function BankGUI()
local r,g,b=interpolateBetween(255,255,255,20,250,0,(getTickCount()-czas)/1100,"SineCurve")
local r2,g2,b2=interpolateBetween(255,255,255,158,229,10,(getTickCount()-czas)/1100,"SineCurve")
dxDrawImage(screenW 0.7255screenH 0.3451screenW 0.7943screenH 0.5339"okn2.png"000tocolor(255255255180), false)
  
if not cursorPosition(screenW 0.8682screenH 0.5052screenW 0.0798screenH 0.0404then --wyplac
dxDrawImage(screenW 0.8448screenH 0.4466screenW 0.1340screenH 0.1497"przycisk.png"000tocolor(255,255,255255), false)
 
dxDrawText("Wyp?a?", (screenW 0.8690) + 1, (screenH 0.5052) + 1, (screenW 0.9480) + 1, (screenH 0.5430) + 1tocolor(000255), 1.12"default-bold""center""center"falsefalsefalsefalsefalse)
        
dxDrawText("Wyp?a?"screenW 0.8690screenH 0.5052screenW 0.9480screenH 0.5430tocolor(255255255255), 1.12"default-bold""center""center"falsefalsefalsefalsefalse)
  
else 
dxDrawImage(screenW 0.8448screenH 0.4466screenW 0.1340screenH 0.1497"przycisk.png"000tocolor(255,255,255255), false)

dxDrawText("Wyp?a?", (screenW 0.8690) + 1, (screenH 0.5052) + 1, (screenW 0.9480) + 1, (screenH 0.5430) + 1tocolor(000255), 1.05"default-bold""center""center"falsefalsefalsefalsefalse)
        
dxDrawText("Wyp?a?"screenW 0.8690screenH 0.5052screenW 0.9480screenH 0.5430tocolor(0,128,255255), 1.05"default-bold""center""center"falsefalsefalsefalsefalse)
   
end 
if not cursorPosition(screenW 0.8690screenH 0.6029screenW 0.0798screenH 0.0404then --wplac
dxDrawImage(screenW 0.8448screenH 0.5469screenW 0.1340screenH 0.1497"przycisk.png"000tocolor(255,255,255255), false)
 
dxDrawText("Wp?a?", (screenW 0.8697) + 1, (screenH 0.6042) + 1, (screenW 0.9488) + 1, (screenH 0.6432) + 1tocolor(000255), 1.12"default-bold""center""center"falsefalsefalsefalsefalse)
        
dxDrawText("Wp?a?"screenW 0.8697screenH 0.6042screenW 0.9488screenH 0.6432tocolor(255255255255), 1.12"default-bold""center""center"falsefalsefalsefalsefalse)

else 
dxDrawImage(screenW 0.8448screenH 0.5469screenW 0.1340screenH 0.1497"przycisk.png"000tocolor(255,255,255255), false)

 
dxDrawText("Wp?a?", (screenW 0.8697) + 1, (screenH 0.6042) + 1, (screenW 0.9488) + 1, (screenH 0.6432) + 1tocolor(000255), 1.05"default-bold""center""center"falsefalsefalsefalsefalse)
        
dxDrawText("Wp?a?"screenW 0.8697screenH 0.6042screenW 0.9488screenH 0.6432tocolor(0,128,255255), 1.05"default-bold""center""center"falsefalsefalsefalsefalse)
 
end 
if not cursorPosition(screenW 0.7943screenH 0.7839screenW 0.1340screenH 0.0547then --zamknij
dxDrawImage(screenW 0.7526screenH 0.7031screenW 0.2299screenH 0.2070"przycisk.png"000tocolor(255255255255), false)
dxDrawText("Zamknij", (screenW 0.7950) + 1, (screenH 0.7839) + 1, (screenW 0.9283) + 1, (screenH 0.8385) + 1tocolor(000255), 1.30"default-bold""center""center"falsefalsefalsefalsefalse)
dxDrawText("Zamknij"screenW 0.7950screenH 0.7839screenW 0.9283screenH 0.8385tocolor(255255255255), 1.30"default-bold""center""center"falsefalsefalsefalsefalse)
else 
dxDrawImage(screenW 0.7526screenH 0.7031screenW 0.2299screenH 0.2070"przycisk.png"000tocolor(255,255,255255), false)
dxDrawText("Zamknij", (screenW 0.7950) + 1, (screenH 0.7839) + 1, (screenW 0.9283) + 1, (screenH 0.8385) + 1tocolor(000255), 1.24"default-bold""center""center"falsefalsefalsefalsefalse)
dxDrawText("Zamknij"screenW 0.7950screenH 0.7839screenW 0.9283screenH 0.8385tocolor(0,128,255255), 1.24"default-bold""center""center"falsefalsefalsefalsefalseend 
dxDrawText("Bankomat", (screenW 0.7694) + 1, (screenH 0.3620) + 1, (screenW 0.9510) + 1, (screenH 0.3997) + 1tocolor(000255), 1.20"default-bold""center""center"falsefalsefalsefalsefalse)
dxDrawText("Bankomat"screenW 0.7694screenH 0.3620screenW 0.9510screenH 0.3997tocolor(255,255,255255), 1.20"default-bold""center""center"falsefalsefalsefalsefalse)
dxDrawText("U?ytkownik: "..getPlayerName(localPlayer):gsub("#%x%x%x%x%x%x","").."\nAby od?wie?y? stan konta wyjd?\ni wejd? do bankomatu", (screenW 0.7782) + 1, (screenH 0.7000) + 1, (screenW 0.9422) + 1, (screenH 0.7135) + 1tocolor(000255), 1"default-bold""center""center"falsefalsefalsefalsefalse)
dxDrawText("U?ytkownik: "..getPlayerName(localPlayer):gsub("#%x%x%x%x%x%x","").."\nAby od?wie?y? stan konta wyjd?\ni wejd? do bankomatu"screenW 0.7782screenH 0.7000screenW 0.9422screenH 0.7135tocolor(255255255255), 1"default-bold""center""center"falsefalsefalsefalsefalse)                             
end



addEventHandler("onClientColShapeHit"resourceRoot, function(el,md)
    if not md or el~=localPlayer then return end
                if panel == false then
                  addEventHandler("onClientRender",root,BankGUI)
                          czas getTickCount()
                                panel true
                                guiSetVisible(bw.lbl1true)
                                guiSetVisible(bw.edt1true)
                                guiSetVisible(bw.edt2true)
                                showCursor(true)
        guiSetText(bw.lbl1,"* Trwa otwieranie konta bankowego...")
        triggerServerEvent("onPlayerRequestATMInfo"resourceRoot)
        guiSetInputMode("no_binds_when_editing")
            end
end)

addEvent("doFillATMInfo"true)
addEventHandler("doFillATMInfo"resourceRoot, function(successbalance)
    if not success then
        guiSetText(bw.lbl1,"* Brak polaczenia mysql....")
        return
    end
    guiSetText(bw.lbl1,"Stan Twojego konta:".."\n".. balance.." PLN")
    guiSetFont(bw.lbl1normalFont)
    setElementData(bw.lbl1"balance"tonumber(balance))
    guiSetText(bw.edt2,100 balance and balance or 100)
    if balance>0 then
    end

    guiSetText(bw.edt1,balance)
end)

addEventHandler("onClientPlayerSpawn"localPlayercloseATM)


function Wplac(buttonstate)
if panel and button == "left" and state == "down" then
           if cursorPosition(screenW 0.8690screenH 0.6029screenW 0.0798screenH 0.0404then
    local kwotaee=tonumber(guiGetText(bw.edt1))
    if not kwotaee then return end
    local kwota=math.floor(kwotaee)
    if not kwota or kwota<1 then
        exports['noti']:showBox(client,"warning","Nieprawdi?owa kwota wp?aty.")
        return
    end
    
    
        if kwota>getPlayerMoney() then
            exports['noti']:showBox(client,"warning","Nie posiadasz tyle ?rodk?w.")
            return
        end
        
        triggerServerEvent("doATMOperation"resourceRootkwota)
    end

end
end
addEventHandler("onClientClick"getRootElement(), Wplac)

function Wyplac(buttonstate)
if panel and button == "left" and state == "down" then
           if cursorPosition(screenW 0.8682screenH 0.5052screenW 0.0798screenH 0.0404then
    if not tonumber(guiGetText(bw.edt2)) then return end
    local kwotae=tonumber(guiGetText(bw.edt2))
    if not kwotae then return end
    local kwota=math.floor(kwotae)
    if not kwota or kwota<1 then
        exports['noti']:showBox(client,"warning","Nieprawid?owa kwota wp?aty.")
        return
    end
    if getPlayerMoney()+kwota>900000000000 then
        exports['noti']:showBox(client,"info","Posiadasz ju? zbyt du?o got?wki przy sobie.")
        return
    end
    triggerServerEvent("doATMOperation"resourceRoot, -kwota)
end
end
end
addEventHandler("onClientClick"getRootElement(), Wyplac)

function Zamknij(buttonstate)
    if panel and button == "left" and state == "down" then
           if cursorPosition(screenW 0.7943screenH 0.7839screenW 0.1340screenH 0.0547then
                panel false 
                removeEventHandler ("onClientRender"rootBankGUI)
                showCursor(false)
                guiSetVisible(bw.lbl1false)
                guiSetVisible(bw.edt1false)
                guiSetVisible(bw.edt2false)
         end
    end
end
addEventHandler("onClientClick"getRootElement(), Zamknij)

addEventHandler("onClientPlayerWasted",getRootElement(),function()
    if panel then
                panel false 
                removeEventHandler ("onClientRender"rootBankGUI)
                showCursor(false)
                guiSetVisible(bw.lbl1false)
                guiSetVisible(bw.edt1false)
                guiSetVisible(bw.edt2false)
end
end)

function cursorPosition(xywh)
    if (not isCursorShowing()) then
        return false
    end
    local mxmy getCursorPosition()
    local fullxfully guiGetScreenSize()
    cursorxcursory mx*fullxmy*fully
    if cursorx and cursorx and cursory and cursory h then
        return true
    else
        return false
    end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-08-26, 09:49


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Musisz zamienic caly domy?lny system pieni?dzy z MTA na elementDate.
getPlayerMoney na getElementData
givePlayerMoney na setElementData

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 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