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

Wysłany: 2017-06-05, 19:26


Pemo97







Wiek: 26
Na forum: 3822 dni
Posty: 49

Piwa: 3

Respekt: 45,3

Witam mam co? z bankomatami z paczki IYW oto wycinek z konsoli
Kod:

[2017-06-05 19] ERROR: Client (#4060e0pemson) triggered serverside event onPlayerRequestATMInfo, but event is not added serverside



KOD(serwer):
Kod:

--[[
@author Lukasz Biegaj <wielebny@bestplay.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
@todo przerobic z zasobu DB na DB2
]]--




addEvent("onPlayerRequestATMInfo", true)
addEventHandler("onPlayerRequestATMInfo", resourceRoot, function()
local dbid=getElementData(client,"player:uid")
if not dbid then
triggerClientEvent(client,"doFillATMInfo", resourceRoot, false)
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", resourceRoot, false)
return
end
local sr=sr[1]
triggerClientEvent(client,"doFillATMInfo", resourceRoot, true, tonumber(sr.bank_money))
end)

addEvent("doATMOperation", true)
addEventHandler("doATMOperation", resourceRoot, function(kwota)
-- kwota dodatnia - wplata
-- kwota ujemna - wyplata
if type(kwota) ~= "number" then outputDebugString("Blad bankomatu xDDDDD") return end
if kwota>0 and kwota>getPlayerMoney(client) then 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(client, kwota)
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", root, string.format("WPLATA %d DO bankomatu (UID : %d) STAN KONTA %d",math.abs(tonumber(kwota)),dbid,sr))
--triggerEvent("broadcastCaptionedEvent", client, getPlayerName(client).." wp?aca pieni?dze do bankomatu", 3, 20, true)
outputChatBox("Wplaciles pieni?dze", client, 255,0,0)
elseif kwota<0 then
if (sr<math.abs(kwota)) then
outputChatBox("Nie masz tyle ?rodk?w na koncie!", client, 255,0,0)
-- triggerClientEvent(client,"onAnnouncement3", root, "Nie masz tyle ?rodk?w na koncie!", 5)
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", root, string.format("WYPLATA %d z bankomatu (UID : %d) STAN KONTA %d",math.abs(tonumber(kwota)),dbid,sr))
outputChatBox("Wyplaciles pieni?dze", client, 255,0,0)
givePlayerMoney(client, math.abs(kwota))
end


end)


KOD(client)
Kod:

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


local bankomaty={
--x,y,z, rx, ry, rz, INT, DIM,
{1041.16, -1339.48, 13.73-0.4, 0.00, 0.00, 180, 0},
{1489.23, -1715.34, 14.05-0.4, 0.00, 0.00, -90, 0},
{1381.12, -1668.06, 13.41-0.4, 0.00, 0.00, -90, 0},
{1628.93, -1171.92, 24.08-0.4, 0.00, 0.00, 180,0},
{1579.94, -1401.13, 13.95-0.4, -0.00, 0.00, 90,0},
{1808.30, -1370.08, 15.08-0.4, -0.00, 0.00, 90,0},
{1775.68, -1867.34, 13.57-0.4, -0.00, 0.00, 180,0},
{2105.45, -1808.15, 13.55-0.4, -0.00, 0.00, -90,0},
{2204.52, -1138.73, 25.82-0.4, -0.00, 0.00, 160,0},
{1238.77, -2042.61, 59.87-0.4, -0.00, 0.00, 90,0},
{2007.76, -2226.59, 13.55-0.4, -0.00, 0.00, 180,0},
{463.10, -1327.46, 15.37-0.4, -0.00, 0.00, 210,0},
{1467.94, -1766.29, 18.80-0.4, -0.00, 0.00, 90,0},
{1811.07, -1073.81, 24.09-0.4, -0.00, 0.00, -90,0}
}

for i,v in ipairs(bankomaty) do

v.obiekt=createObject(2942,v[1],v[2],v[3],v[4],v[5],v[6])
setElementInterior(v.obiekt,v[7] or 0)
setElementDimension(v.obiekt,v[8] or 0)
setElementFrozen(v.obiekt,true)
setObjectBreakable ( v.obiekt, false )

-- v.mapicon=createBlip(v[1],v[2],v[3], 52, 2, 255,255,255,255, -1000, 300)
v.mapicon=createBlip(v[1],v[2],v[3], 52, 1, 5,255,5,255, -10000, 150)
setElementInterior(v.mapicon,v[7] or 0)
setElementDimension(v.mapicon,v[8] or 0)

v.cs=createColSphere(v[1],v[2],v[3]+1, 1)
setElementInterior(v.cs,v[7] or 0)
setElementDimension(v.cs,v[8] or 0)
v.text=createElement('text')
setElementData(v.text,"name","Bankomat")
setElementPosition(v.text,v[1],v[2],v[3])
setElementInterior(v.text,v[7] or 0)
setElementDimension(v.text,v[8] or 0)
end


local bw={}
bw.win = guiCreateWindow(0.7236,0.3398,0.2314,0.5,"Bankomat",true)
guiWindowSetMovable(bw.win,false)
guiWindowSetSizable(bw.win,false)
bw.lbl1 = guiCreateLabel(0.0633,0.0997,0.903,0.1571,"Stan konta:\n0PLN",true,bw.win)
local font0_money = guiCreateFont(":ogrpg-gui/fonts/money.ttf", 14)
guiSetFont(bw.lbl1, font0_money)
guiLabelSetVerticalAlign(bw.lbl1,"center")
guiLabelSetHorizontalAlign(bw.lbl1,"center",false)
local font1_money = guiCreateFont(":ogrpg-gui/droid-sans.ttf", 7)

bw.lbl2 = guiCreateLabel(0.0759,0.2734,0.8861,0.0695,"Wp?ata ───────────────────────",true,bw.win)


bw.edt1 = guiCreateEdit(0.0675,0.3385,0.8608,0.0859,"0",true,bw.win)
bw.btn_wplac = guiCreateButton(0.0717,0.4427,0.8608,0.0911,"Wp?a?",true,bw.win)

bw.lbl3 = guiCreateLabel(0.0759,0.5626,0.8861,0.0695,"Wyp?ata ".."───────────────────────",true,bw.win)
bw.edt2 = guiCreateEdit(0.0675,0.6276,0.8608,0.0859,"0",true,bw.win)
bw.btn_wyplac = guiCreateButton(0.0717,0.7344,0.8608,0.0911,"Wyp?a?",true,bw.win)

bw.btn_zamknij = guiCreateButton(0.0717,0.888,0.8608,0.0859,"Zamknij",true,bw.win)
guiSetFont(bw.win, font1_money)
guiSetFont(bw.lbl2, font1_money)
guiSetFont(bw.edt1, font1_money)
guiSetFont(bw.btn_wplac, font1_money)
guiSetFont(bw.lbl3, font1_money)
guiSetFont(bw.edt2, font1_money)
guiSetFont(bw.btn_wyplac, font1_money)
guiSetFont(bw.btn_zamknij, font1_money)


guiSetVisible(bw.win, false)



addEventHandler("onClientColShapeHit", resourceRoot, function(el,md)
if not md or el~=localPlayer then return end
-- outputChatBox("Bankomat pokazuje napis: AWARIA.")
-- if getPlayerName(localPlayer)=="Carolynn_Trench" or getPlayerName(localPlayer)=="Bob_Euler" then


guiSetVisible(bw.win, true)
guiSetEnabled(bw.btn_wyplac, false)
guiSetEnabled(bw.btn_wplac, false)
guiSetText(bw.lbl1,"Trwa otwieranie konta bankowego...")
triggerServerEvent("onPlayerRequestATMInfo", resourceRoot)
--showCursor(true,true)
guiSetInputMode("no_binds_when_editing")
guiSetText(bw.win, string.format("Bankomat F3-KURSOR (UID:%d)",getElementData(el,"player:uid")))
guiSetText(bw.lbl2, "Wp?ata ───────────────────────")
guiSetText(bw.lbl3, "Wyp?ata ───────────────────────")
guiSetVisible(bw.btn_wyplac, true)
guiSetPosition(bw.btn_wplac, 0.0717,0.4427, true)
-- end
end)

local function closeATMWin()
if guiGetVisible(bw.win) then
guiSetVisible(bw.win, false)
--showCursor(false)
end
end

addEventHandler("onClientGUIClick", bw.btn_zamknij, closeATMWin, false)
addEventHandler("onClientColShapeLeave", resourceRoot, function(el,md)
if el~=localPlayer then return end
closeATMWin()
end)

-- triggerClientEvent(client,"doFillATMInfo", resourceRoot, true, sr.bank_money)
addEvent("doFillATMInfo", true)
addEventHandler("doFillATMInfo", resourceRoot, function(success, balance)
if not success then
guiSetText(bw.lbl1,"Testowany.") --Musisz by? zarejestrowanym graczem aby skorzysta? z bankomatu.
return
end
guiSetText(bw.lbl1,"Stan Twojego konta:".."\n".. balance.." PLN")
setElementData(bw.win, "balance", tonumber(balance))
guiSetText(bw.edt2,100 > balance and balance or 100)
if balance>0 then
guiSetEnabled(bw.btn_wyplac, true)
end

guiSetText(bw.edt1,balance)
guiSetEnabled(bw.btn_wplac, true)
end)

addEventHandler("onClientPlayerSpawn", localPlayer, closeATMWin)


addEventHandler("onClientGUIClick", bw.btn_wplac, function()
local kwotae=tonumber(guiGetText(bw.edt1))
if not kwotae then return end
local kwota=math.floor(kwotae)
if not kwota or kwota<1 then
-- triggerEvent("onAnnouncement3", root, "Nieprawid?owa kwota wp?aty.", 4)
outputChatBox("Nieprawid?owa kwota wp?aty!", 255,0,0)
return
end

if guiGetVisible(bw.btn_wyplac) then --normalna wplata

if kwota>getPlayerMoney() then
outputChatBox("Nie masz tyle got?wki!", 255,0,0)
return
end

closeATMWin()
triggerServerEvent("doATMOperation", resourceRoot, kwota)
end

end, false)

addEventHandler("onClientGUIClick", bw.btn_wyplac, function()
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
-- triggerEvent("onAnnouncement3", root, "Nieprawid?owa kwota wyp?aty.", 4)
outputChatBox("Nieprawid?owa kwota wp?aty!", 255,0,0)
return
end
if getPlayerMoney()+kwota>99999999 then
-- triggerEvent("onAnnouncement3", root, "Nie mo?esz mie? tyle got?wki przy sobie.", 4)
outputChatBox("Maksymalna ilo?? got?wki kt?r? mo?esz mie? przy sobie to 999999.99 PLN", 255,0,0)
return
end
closeATMWin()
triggerServerEvent("doATMOperation", resourceRoot, -kwota)

end, false)


Ostatnio zmieniony przez Pemo97 2017-06-05, 19:30, w całości zmieniany 2 razy  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-06-05, 20:52


eject

kurdebele






Wiek: 30
Na forum: 3659 dni
Posty: 182
Nick w MP: EjecT

Piwa: 2456

Respekt: 85,8

Ostrzeżeń: 60%
addEvent("onPlayerRequestATMInfo"trueaddEventHandler("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[1triggerClientEvent(client,"doFillATMInfo"resourceRoottruetonumber(sr.bank_money)) 
endaddEvent("doATMOperation"trueaddEventHandler("doATMOperation"resourceRoot, function(kwota) 
-- kwota dodatnia wplata 
-- kwota ujemna wyplata 
if type(kwota) ~= "number" then outputDebugString("Blad bankomatu xDDDDD") 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(clientkwotaexports["ogrpg-db"]:dbSet("UPDATE ogrpg_users SET bank_money=bank_money+?? WHERE id=? LIMIT 1",tonumber(kwota),dbidlocal 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_moneytriggerEvent("admin:logs"rootstring.format("WPLATA %d DO bankomatu (UID : %d) STAN KONTA %d",math.abs(tonumber(kwota)),dbid,sr)) 
--triggerEvent("broadcastCaptionedEvent"clientgetPlayerName(client).." wp?aca pieni?dze do bankomatu"320trueoutputChatBox("Wplaciles pieni?dze"client255,0,0) 
elseif kwota<0 then 
if (sr<math.abs(kwota)) then 
outputChatBox("Nie masz tyle ?rodk?w na koncie!"client255,0,0end
end)


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