include('autorun/sh_donate.lua')
include('cfg_server.lua')
print('sv donate podgruzilsa')
resource.AddSingleFile "materials/donate/skidki.png"
resource.AddSingleFile 'materials/donate/qiwi.png'
resource.AddSingleFile 'materials/donate/promo.png'
resource.AddSingleFile 'materials/donate/tovari.png'
resource.AddSingleFile 'materials/donate/back.png'
require 'tmysql4'
local PLAYER= FindMetaTable('Player')
local xxxbreak,continuex=tmysql:Connect(db_ip,db_login,db_pass,db_db,3306,nil,CLIENT_MULTI_STATEMENTS)
if continuex then
print("+----------------------------------+
| Ошибка Donat Mysql не подключен! |
+----------------------------------+")
end
util.AddNetworkString('donate_promoactivate')
util.AddNetworkString('donate_buydonate')
util.AddNetworkString('donatenotify')
util.AddNetworkString('donatenopen')
donate.LOG_Addpaylog=function(id,str,wha)
local newstr="INSERT INTO `donate_logs` (`id`, `log`, `payid`) VALUES (NULL, '"..'[QIWI]'..id..obf'задонатил'..str..' рублей'..obf' PayID:'..'[#'..wha..']'..', '..wha..');'
xxxbreak["Query"](newstr)
end
donatesetnw = function(p,tbl)
p:SetNetworkedInt('donate_balance',tbl[1]['data'][1]['money'])
end
donate.AddMoneyPlayer=function(int,str)
local xxtrue="UPDATE `donate_players` SET `money` = `money` + '"..str.."' WHERE `donate_players`.`steamid` = '"..int.."';"
xxxbreak["Query"](xxtrue)
for _,x in pairs(player.GetAll()) do
if x:SteamID()==int then
net.Start('donatenotify')
net.WriteString('Вы успешно пополнили счет на:'..str..' ₽')
net.Send(x)
xxxbreak["Query"]("SELECT * FROM `donate_players` WHERE steamid='".. x:SteamID(x).."';",donatesetnw)
end
end
end
local localxxxxxxx={['Accept']='application/json',['Authorization']='Bearer'..donate_token}
donate.LOG_CheckPlog= function(a,b,c)
checklog=function(g)
if g[1]['affected']==0 then
timer.Remove(xthen)
print(obf'+1')
donate.LOG_Addpaylog(c,b,a)donate['AddMoneyPlayer'](c,b)
end
end
xxxbreak["Query"]("SELECT * FROM `donate_logs` WHERE `payid` = '"..a.."';",checklog)
end
local continuexxx=function(str)
for z,x in pairs(str['data']) do
local j=str['data'][z]
local w=j['txnId']
if j['comment']~=nil then
if j['comment']==p then
local total=j['total']['amount']
donate.LOG_CheckPlog(w,total,p)
end
end
end
end
donate.CheckPayment=function(p)
local xthen='PayChk'..p
obf'477661657061'
local xxxxxxxxnil=function()
http.Fetch('[URL]https://edge.qiwi.com/payment-history/v2/persons/'..donate['qiwi']..obf'/payments?operation=IN&rows=3[/URL]',
function (b,a,m,k)
continuexxx(util.JSONToTable(b))
end,
function (xfunction)
print('Something went wrong :/')
print('ErrCode:'..xfunction)
end,
localxxxxxxx)
end
timer.Create(xthen,30,16,xxxxxxxxnil)
end
util.AddNetworkString('checkbuy')
net.Receive('checkbuy',function(L,p)
donate.CheckPayment(p:SteamID())
end)
net.Receive('donate_promoactivate',function(l,p)
local xxlocal=net.ReadString()
local int=0
promovalid = function(a)
for _,x in pairs(a[1]['data']) do
if x['promo_name']==xxlocal then
int=x[obf'promo_money']
checkusability=function (name)
if name[1][obf'affected']==0 then
xxxbreak["Query"]("INSERT INTO `donate_promologs` (`id`, `promo_name`, `steamid`) VALUES (NULL, '"..xxlocal.."', '"..p:SteamID().."');")
xxxbreak["Query"]("UPDATE `donate_promo` SET `promo_available` = `promo_available` - '1' WHERE `donate_promo`.`promo_name` = '"..xxlocal.."';")
xxxbreak["Query"]("UPDATE `donate_players` SET `money` = `money` + '"..int.."' WHERE `donate_players`.`steamid` = '"..p:SteamID().."';")
xxxbreak["Query"]("SELECT * FROM `donate_players` WHERE steamid='"..p:SteamID().."';",function(da)
timer.Create('givebalance',2,1,function()
p:SetNetworkedInt("donate_balance",da[1]['data'][1]['money'])
end)
end)
net.Start('donatenotify')
net.WriteString('Вы успешно активировали промокод!')
net.Send(p)
end
end
xxxbreak["Query"]("SELECT * FROM `donate_promologs` WHERE `steamid`= '"..p:SteamID().."' AND `promo_name` = '"..xxlocal.."';",checkusability)
end
end
end
xxxbreak["Query"]('SELECT * FROM `donate_promo`;', promovalid)
end)
donatecreateadwa=function (p,da)
if da[1]['affected']==0 then
xxxbreak["Query"]("INSERT INTO `donate_players` (`id`, `steamid`, `money`) VALUES (NULL, '"..p:SteamID().."', '0');")
end
end
donatesetnw=function(p,d)
p:SetNetworkedInt("donate_balance",(d[1]['data'][1]['money'] and d[1]['data'][1][bf'money'] or 0))
end
hook.Add('PlayerInitialSpawn','donatecreateifnotexist',function(p)
if !IsValid(p) or p:IsBot() then return end
xxxbreak["Query"]("SELECT * FROM `donate_players` WHERE steamid='"..p:SteamID(p).."';",donatecreateadwa)
timer.Create('donatecreatespawn'..p:UserID(),2,0,function()
if !IsValid(p) then return end
xxxbreak["Query"]("SELECT * FROM `donate_players` WHERE steamid='"..p:SteamID(p).."';",donatesetnw)
end)
timer.Create(obf'606b6a657061677661657061'..p[obf'517761764d40'](p),60,0,function()
if !IsValid(p)then return end
xxxbreak["Query"]("SELECT * FROM `donate_players` WHERE steamid='"..p:SteamID(p).."';",donatecreateadwa)
xxxbreak["Query"](xxxbreak,"SELECT * FROM `donate_players` WHERE steamid='"..p:SteamID(p).."';",donatesetnw)
end)
end)
net.Receive('donate_buydonate',function (_,p)
local dat=net.ReadString()
local steamid=p:SteamID(p)
for z,x in pairs(donate['items'])do
if dat==x['item_id']then
if p:GetRank()==x['group'] then
net.Start('donatenotify')
net.WriteString('Ошибка! У вас уже есть:'..x['group'])
net.Send(p)
return
end
checkcanbuy=function(da_)
if (da_[1]['data'][1]['money']-x['price'])<0 then
net.Start('donatenotify')
net.WriteString('Ошибка! У вас не достаточно денежных средств')
net.Send(p)
return
end
buydonate=function()
if x['onebuy'] then
checklogbuy = function(log)
if log[1]['affected']==0 then
if x['isgroup'] then
xxxbreak["Query"](obf"INSERT INTO `donate_items` (`id`, `player_steamid`, `item_id`) VALUES (NULL, '"..steamid.."', '"..x['item_id'].."');")
if x['days'] !=0 then
RunConsoleCommand('ba','setgroup',p:SteamID64(),x['group'],x['days']..'d')//,'user')
else
RunConsoleCommand('ba', 'setgroup',p:SteamID64(),x['group'])
end
net.Start('donatenotify')
net.WriteString('Вы успешно приобрели:'..x['item_name'])
net.Send(p)
else
net.Start('donatenotify')
net.WriteString('Вы успешно приобрели:'..x['item_name'])
net.Send(p)x[obf'676568686665676f'](p)
end
end
end
xxxbreak["Query"]("SELECT * FROM `donate_items` WHERE `player_steamid` = '"..steamid.."' AND `item_id` = '"..x['item_id'].."';",checklogbuy)
else
if x['isgroup']then
if x['days']!=0 then
RunConsoleCommand("ba","setgroup",p:SteamID64(),x['group'],x['days']..'d')//,obf'71776176')
else
RunConsoleCommand("ba","setgroup",p:SteamID64(),x['group'])
end
net.Start("donatenotify")
net.WriteString('Вы успешно приобрели:'..x['item_name'])
net.Send(p)
else
x['callback'](p)
net.Start("donatenotify")
net.WriteString('Вы успешно приобрели:'..x['item_name'])
net.Send(p)
end
end
end
xxxbreak["Query"]("UPDATE `donate_players` SET `money` = `money` - '"..x['price'].."' WHERE `donate_players`.`steamid` = '"..steamid.."';",buydonate)
end
xxxbreak["Query"](xxxbreak,"SELECT * FROM `donate_players` WHERE steamid='"..steamid.."';",checkcanbuy)
end
end
end)
hook.Add('PlayerButtonDown','OpenDonateMenu',function (p,btn)
if btn==KEY_F6 then
net.Start('donatenopen')
net.Send(p)
end
end )
donate['AddDonateWeapon']=function(ty,p)
xxxbreak['Query']("INSERT INTO `donate_weapons` (`id`, `steamid`, `classname`) VALUES (NULL, '"..ty:SteamID().."', '"..p.."');")
end
donate['AddPlayerToPropLimit']=function(p,don)
xxxbreak['Query']("INSERT INTO `donate_props` (`id`, `steamid`, `count`) VALUES (NULL, '"..p:SteamID().."', '"..don.."');")
end
hook.Add('PlayerSpawn','GiveDonateWeapon',function(p)
if !IsValid(p) then return end
if p:IsBot() then return end
if !p:Alive() then return end
xxxbreak['Query']("SELECT * FROM `donate_weapons` WHERE steamid='"..p:SteamID().."';",function(d)
if d[1]['affected']==0 then return end
for z,x in pairs(d[1]['data'])do
p:Give(x['classname'])
end
end)
end)
hook.Add('PlayerSpawn','GiveLimitProp',function(p)
if !IsValid(p)then return end
if p:IsBot() then return end
if !p:Alive() then return end
if !p.limitprops then p.limitprops=0 end
xxxbreak['Query']("SELECT * FROM `donate_props` WHERE steamid='"..p:SteamID().."';",function(d)
if d[1]['affected']==0 then return end
for z,x in pairs(d[1]['data']) do
p.limitprops=p.limitprops+x['count']
end
end)
end)