Wysłany: 2021-01-22, 01:51
NoNamik
Wiek: 35 Na forum: 2186 dni Posty: 289
Nick w MP: JestemNoNamem
Piwa : 374
witam mam bankomaty z pysa lecz postanowilem podpiac pieniadze z banku pod player:b_money by bylo latwiej lecz mam tylko problem z wyplacaniem pieniedzy z bankomatu
KOD Bankomaty
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:sid")
if not dbid then
triggerClientEvent(client,"doFillATMInfo", resourceRoot, false)
return
end
local sr=exports["DB2"]:pobierzWyniki("SELECT bank_money FROM pystories_users WHERE id="..(tonumber(dbid) or 0).." LIMIT 1")
if not sr or not sr.bank_money then
triggerClientEvent(client,"doFillATMInfo", resourceRoot, false)
return
end
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 kwota>0 and kwota>getPlayerMoney(client) then return end -- komunikat bledu po stronie klienta
local dbid=getElementData(client,"player:sid")
if not dbid then return end -- nie powinno sie zdarzyc
if kwota>0 then
if getPlayerMoney(client)<kwota then return end
takePlayerMoney(client, kwota)
setElementData(client,'player:b_money',getElementData(client,'player:b_money') + kwota)
outputChatBox("Pomy?lnie wp?acono pieni?dze",client)
--triggerEvent("broadcastCaptionedEvent", client, getPlayerName(client).." wp?aca pieni?dze do bankomatu", 3, 20, true)
elseif kwota<0 then
hajs = getElementData(client,'player:b_money')
if not sr or not sr.bank_money then return end -- nie opwinno sie wydarzyc
hajs=tonumber(sr.bank_money)
if (sr.bank_money<math.abs(kwota)) then
outputChatBox("* Nie posiadasz tyle ?rodk?w na koncie !", client, 255,0,0)
-- triggerClientEvent(client,"onAnnouncement3", root, "Nie masz tyle ?rodk?w na koncie!", 5)
return
end
outputChatBox("* Wyp?aci?e?(a?) pieni?dze z bankomatu.", client, 255,0,0)
exports["DB2"]:zapytanie("UPDATE pystories_users SET bank_money=bank_money-"..math.abs(tonumber(kwota)).." WHERE id="..tonumber(dbid).." LIMIT 1")
givePlayerMoney(client, math.abs(kwota))
end
end)
a tutaj kod wyplat
Kod: outputChatBox("* Wyp?aci?e?(a?) pieni?dze z bankomatu.", client, 255,0,0)
exports["DB2"]:zapytanie("UPDATE pystories_users SET bank_money=bank_money-"..math.abs(tonumber(kwota)).." WHERE id="..tonumber(dbid).." LIMIT 1")
givePlayerMoney(client, math.abs(kwota))
Wysłany: 2021-01-22, 02:07
Lucky!!! :)
Wiek: 20 Na forum: 2372 dni Posty: 121
Nick w MP: Lucky
Piwa : 1163
outputChatBox ( "* Wyp?aci?e?(a?) pieni?dze z bankomatu." , client , 255 , 0 , 0 )
exports [ "DB2" ]: zapytanie ( "UPDATE pystories_users SET bank_money=bank_money-" .. math . abs ( tonumber ( kwota )).. " WHERE id=" .. tonumber ( dbid ).. " LIMIT 1" )
givePlayerMoney ( client , kwota )
end
Sprawd? to
Wysłany: 2021-01-22, 02:40
NoNamik
Wiek: 35 Na forum: 2186 dni Posty: 289
Nick w MP: JestemNoNamem
Piwa : 374
Lucky!!! , nie dziala
[ Dodano : 2021-01-22, 02:40 ]
nie odejmuje kasy z banku ani nie dodaje musi byc to pod elementdate by to dzialalo
Wysłany: 2021-01-22, 05:18
MrVip615
witam
Wiek: 22 Na forum: 4307 dni Posty: 167
Nick w MP: ramzes
Piwa : 207
Zamiast wysylac zapytanie do bazy danych, po prostu zmieniaj element date graczowi.
givePlayerMoney ( client , math . abs ( kwota ))
setElementData ( client , 'player:b_money' , getElementData ( client , 'player:b_money' ) - math . abs ( kwota ))
Wysłany: 2021-01-22, 10:14
JakisPolak199
wieczny student
Wiek: 20 Na forum: 3510 dni Posty: 131
Nick w MP: bover.
Piwa : 905
Wysłany: 2021-01-22, 14:30
NoNamik
Wiek: 35 Na forum: 2186 dni Posty: 289
Nick w MP: JestemNoNamem
Piwa : 374
Tagi: bankomaty :: pys
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: