DaVeCS
Mapper
Wiek: 31 Na forum: 3386 dni Posty: 193
Nick w MP: DaVe
Piwa : 59
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" , 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 )
if type ( kwota ) ~= "number" then outputDebugString ( "error" ) 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 ))
outputChatBox ( "Wp?aci?e?/as pieni?dz? do bankomatu." , client , 255 , 255 , 255 )
elseif kwota < 0 then
if ( sr < math . abs ( kwota )) then
outputChatBox ( "Nie posiadasz tyle ?rodk?w." , client , 255 , 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" , root , string . 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." , client , 255 , 255 , 255 )
givePlayerMoney ( client , math . 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.4 , 0.00 , 0.00 , 0 , 0 },
{ 2864.46 , 2224.00 , 10.89 - 0.4 , 0.00 , 0.00 , - 90 , 0 },
{ 2551.38 , 1971.98 , 10.82 - 0.4 , 0.00 , 0.00 , 0 , 0 },
{ 2477.04 , 1326.34 , 10.83 - 0.4 , 0.00 , 0.00 , 180 , 0 },
{ 1019.61 , 1353.81 , 10.82 - 0.4 , - 0.00 , 0.00 , 0 , 0 },
{ 2191.27 , 2010.34 , 10.83 - 0.4 , - 0.00 , 0.00 , 220 , 0 },
{ 2137.43 , 2362.19 , 10.82 - 0.4 , - 0.00 , 0.00 , 180 , 0 },
{ 2173.91 , 1401.81 , 11.06 - 0.4 , - 0.00 , 0.00 , - 90 , 0 },
{ 1966.95 , 2476.68 , 11.18 - 0.4 , - 0.00 , 0.00 , 160 , 0 },
{ 1650.47 , 2187.71 , 10.82 - 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 },
{ 2568.61 , 951.01 , 10.85 - 0.4 , - 0.00 , 0.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 ], 52 , 1 , 5 , 255 , 5 , 255 , - 10000 , 150 )
setElementInterior ( v . obiekt , v [ 7 ] or 0 )
setElementDimension ( v . obiekt , v [ 8 ] or 0 )
setElementFrozen ( v . obiekt , true )
setObjectBreakable ( v . obiekt , false )
v . cs = createColSphere ( v [ 1 ], v [ 2 ], v [ 3 ]+ 1 , 1.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 screenW , screenH = guiGetScreenSize ()
local bw ={}
bw . lbl1 = guiCreateLabel ( 0.78 , 0.40 , 0.17 , 0.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 . lbl1 , font0_money )
guiLabelSetVerticalAlign ( bw . lbl1 , "center" )
guiLabelSetHorizontalAlign ( bw . lbl1 , "center" , false )
bw . edt1 = guiCreateEdit ( 0.775 , 0.605 , 0.08 , 0.04 , "0" , true ) -- wplac
bw . edt2 = guiCreateEdit ( 0.775 , 0.505 , 0.08 , 0.04 , "0" , true ) -- wyplac
guiSetVisible ( bw . lbl1 , false )
guiSetVisible ( bw . edt1 , false )
guiSetVisible ( bw . edt2 , false )
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.7255 , screenH * 0.3451 , screenW * 0.7943 , screenH * 0.5339 , "okn2.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 180 ), false )
if not cursorPosition ( screenW * 0.8682 , screenH * 0.5052 , screenW * 0.0798 , screenH * 0.0404 ) then -- wyplac
dxDrawImage ( screenW * 0.8448 , screenH * 0.4466 , screenW * 0.1340 , screenH * 0.1497 , "przycisk.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "Wyp?a?" , ( screenW * 0.8690 ) + 1 , ( screenH * 0.5052 ) + 1 , ( screenW * 0.9480 ) + 1 , ( screenH * 0.5430 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.12 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Wyp?a?" , screenW * 0.8690 , screenH * 0.5052 , screenW * 0.9480 , screenH * 0.5430 , tocolor ( 255 , 255 , 255 , 255 ), 1.12 , "default-bold" , "center" , "center" , false , false , false , false , false )
else
dxDrawImage ( screenW * 0.8448 , screenH * 0.4466 , screenW * 0.1340 , screenH * 0.1497 , "przycisk.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "Wyp?a?" , ( screenW * 0.8690 ) + 1 , ( screenH * 0.5052 ) + 1 , ( screenW * 0.9480 ) + 1 , ( screenH * 0.5430 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.05 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Wyp?a?" , screenW * 0.8690 , screenH * 0.5052 , screenW * 0.9480 , screenH * 0.5430 , tocolor ( 0 , 128 , 255 , 255 ), 1.05 , "default-bold" , "center" , "center" , false , false , false , false , false )
end
if not cursorPosition ( screenW * 0.8690 , screenH * 0.6029 , screenW * 0.0798 , screenH * 0.0404 ) then -- wplac
dxDrawImage ( screenW * 0.8448 , screenH * 0.5469 , screenW * 0.1340 , screenH * 0.1497 , "przycisk.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "Wp?a?" , ( screenW * 0.8697 ) + 1 , ( screenH * 0.6042 ) + 1 , ( screenW * 0.9488 ) + 1 , ( screenH * 0.6432 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.12 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Wp?a?" , screenW * 0.8697 , screenH * 0.6042 , screenW * 0.9488 , screenH * 0.6432 , tocolor ( 255 , 255 , 255 , 255 ), 1.12 , "default-bold" , "center" , "center" , false , false , false , false , false )
else
dxDrawImage ( screenW * 0.8448 , screenH * 0.5469 , screenW * 0.1340 , screenH * 0.1497 , "przycisk.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "Wp?a?" , ( screenW * 0.8697 ) + 1 , ( screenH * 0.6042 ) + 1 , ( screenW * 0.9488 ) + 1 , ( screenH * 0.6432 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.05 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Wp?a?" , screenW * 0.8697 , screenH * 0.6042 , screenW * 0.9488 , screenH * 0.6432 , tocolor ( 0 , 128 , 255 , 255 ), 1.05 , "default-bold" , "center" , "center" , false , false , false , false , false )
end
if not cursorPosition ( screenW * 0.7943 , screenH * 0.7839 , screenW * 0.1340 , screenH * 0.0547 ) then -- zamknij
dxDrawImage ( screenW * 0.7526 , screenH * 0.7031 , screenW * 0.2299 , screenH * 0.2070 , "przycisk.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "Zamknij" , ( screenW * 0.7950 ) + 1 , ( screenH * 0.7839 ) + 1 , ( screenW * 0.9283 ) + 1 , ( screenH * 0.8385 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.30 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Zamknij" , screenW * 0.7950 , screenH * 0.7839 , screenW * 0.9283 , screenH * 0.8385 , tocolor ( 255 , 255 , 255 , 255 ), 1.30 , "default-bold" , "center" , "center" , false , false , false , false , false )
else
dxDrawImage ( screenW * 0.7526 , screenH * 0.7031 , screenW * 0.2299 , screenH * 0.2070 , "przycisk.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "Zamknij" , ( screenW * 0.7950 ) + 1 , ( screenH * 0.7839 ) + 1 , ( screenW * 0.9283 ) + 1 , ( screenH * 0.8385 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.24 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Zamknij" , screenW * 0.7950 , screenH * 0.7839 , screenW * 0.9283 , screenH * 0.8385 , tocolor ( 0 , 128 , 255 , 255 ), 1.24 , "default-bold" , "center" , "center" , false , false , false , false , false )
end
dxDrawText ( "Bankomat" , ( screenW * 0.7694 ) + 1 , ( screenH * 0.3620 ) + 1 , ( screenW * 0.9510 ) + 1 , ( screenH * 0.3997 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.20 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Bankomat" , screenW * 0.7694 , screenH * 0.3620 , screenW * 0.9510 , screenH * 0.3997 , tocolor ( 255 , 255 , 255 , 255 ), 1.20 , "default-bold" , "center" , "center" , false , false , false , false , false )
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 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1 , "default-bold" , "center" , "center" , false , false , false , false , false )
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 , screenH * 0.7000 , screenW * 0.9422 , screenH * 0.7135 , tocolor ( 255 , 255 , 255 , 255 ), 1 , "default-bold" , "center" , "center" , false , false , false , false , false )
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 . lbl1 , true )
guiSetVisible ( bw . edt1 , true )
guiSetVisible ( bw . edt2 , true )
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( success , balance )
if not success then
guiSetText ( bw . lbl1 , "* Brak polaczenia mysql...." )
return
end
guiSetText ( bw . lbl1 , "Stan Twojego konta:" .. "\n" .. balance .. " PLN" )
guiSetFont ( bw . lbl1 , normalFont )
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" , localPlayer , closeATM )
function Wplac ( button , state )
if panel and button == "left" and state == "down" then
if cursorPosition ( screenW * 0.8690 , screenH * 0.6029 , screenW * 0.0798 , screenH * 0.0404 ) then
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" , resourceRoot , kwota )
end
end
end
addEventHandler ( "onClientClick" , getRootElement (), Wplac )
function Wyplac ( button , state )
if panel and button == "left" and state == "down" then
if cursorPosition ( screenW * 0.8682 , screenH * 0.5052 , screenW * 0.0798 , screenH * 0.0404 ) then
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 ( button , state )
if panel and button == "left" and state == "down" then
if cursorPosition ( screenW * 0.7943 , screenH * 0.7839 , screenW * 0.1340 , screenH * 0.0547 ) then
panel = false
removeEventHandler ( "onClientRender" , root , BankGUI )
showCursor ( false )
guiSetVisible ( bw . lbl1 , false )
guiSetVisible ( bw . edt1 , false )
guiSetVisible ( bw . edt2 , false )
end
end
end
addEventHandler ( "onClientClick" , getRootElement (), Zamknij )
addEventHandler ( "onClientPlayerWasted" , getRootElement (),function()
if panel then
panel = false
removeEventHandler ( "onClientRender" , root , BankGUI )
showCursor ( false )
guiSetVisible ( bw . lbl1 , false )
guiSetVisible ( bw . edt1 , false )
guiSetVisible ( bw . edt2 , false )
end
end )
function cursorPosition ( x , y , w , h )
if ( not isCursorShowing ()) then
return false
end
local mx , my = getCursorPosition ()
local fullx , fully = guiGetScreenSize ()
cursorx , cursory = mx * fullx , my * fully
if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
return true
else
return false
end
end