Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
1,009
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.37 KB | None | 0 0
  1. --[[
  2.     KOD    
  3. --]]
  4.  
  5. local utils = exports["dmta_utils"]
  6.  
  7. function getPremiumDate(player)
  8.     local q = exports["dmta_xdb"]:wykonaj("SELECT id, premiumdate FROM pystories_users WHERE id=? AND premiumdate > NOW() LIMIT 1", getElementData(player, "player:sid"))
  9.     if q and #q > 0 then
  10.         return q[1].premiumdate
  11.     else
  12.         return false
  13.     end
  14. end
  15.  
  16. function getGoldDate(player)
  17.     local q = exports["dmta_xdb"]:wykonaj("SELECT id, golddate FROM pystories_users WHERE id=? AND golddate > NOW() LIMIT 1", getElementData(player, "player:sid"))
  18.     if q and #q > 0 then
  19.         return q[1].golddate
  20.     else
  21.         return false
  22.     end
  23. end
  24.  
  25. function addPremiumDays(player, count)
  26.     if getPremiumDate(player) then
  27.         exports["dmta_xdb"]:wykonaj("UPDATE pystories_users SET premiumdate = DATE(premiumdate) + INTERVAL ? DAY WHERE id=? LIMIT 1", count, getElementData(player, "player:sid"))
  28.     else
  29.         exports["dmta_xdb"]:wykonaj("UPDATE pystories_users SET premiumdate = NOW() + INTERVAL ? DAY WHERE id=? LIMIT 1", count, getElementData(player, "player:sid"))
  30.     end
  31.     triggerEvent("save:player", root, player)
  32.     triggerEvent("load:player", root, player)
  33. end
  34.  
  35. function addGoldDays(player, count)
  36.     if getGoldDate(player) then
  37.         exports["dmta_xdb"]:wykonaj("UPDATE pystories_users SET golddate = DATE(golddate) + INTERVAL ? DAY WHERE id=? LIMIT 1", count, getElementData(player, "player:sid"))
  38.     else
  39.         exports["dmta_xdb"]:wykonaj("UPDATE pystories_users SET golddate = NOW() + INTERVAL ? DAY WHERE id=? LIMIT 1", count, getElementData(player, "player:sid"))
  40.     end
  41.     triggerEvent("save:player", root, player)
  42.     triggerEvent("load:player", root, player)
  43. end
  44.  
  45. addCommandHandler("nadaj.premium", function(player, cmd, target, days)
  46.     if getElementData(player, "player:level") ~= 4 and getElementType(player) ~= "console" then return end
  47.     if not target or not days or not tonumber(days) then
  48.         outputChatBox("dmta_itemshop > Poprawne użycie: /"..cmd.." <id/nick> <ilość_dni>", player)
  49.         return
  50.     end
  51.     local t = exports["dmta_core"]:findPlayer(player, target)
  52.     if not t then
  53.         outputChatBox("dmta_itemshop > Nie odnaleziono podanego gracza.", player)
  54.         return
  55.     end
  56.     addPremiumDays(t, days)
  57.     outputChatBox("dmta_itemshop > Nadałeś konto premium graczowi: "..utils:removeHex(getPlayerName(t))..", na "..days.." dni.", player)
  58.     outputChatBox("dmta_itemshop > Otrzymałeś konto premium na "..days.." dni", t)
  59.     outputChatBox("#fcc603[dmta_itemshop] > #ffffff"..utils:removeHex(getPlayerName(t)).." #ffd952zakupił konto premium na #ffffff"..days.." #ffd952dni, dziękujemy za wsparcie!", getRootElement(), 255, 255, 255, true)
  60. end)
  61.  
  62. addCommandHandler("nadaj.gold", function(player, cmd, target, days)
  63.     if getElementData(player, "player:level") ~= 4 and getElementType(player) ~= "console" then return end
  64.     if not target or not days or not tonumber(days) then
  65.         outputChatBox("dmta_itemshop > Poprawne użycie: /"..cmd.." <id/nick> <ilość_dni>", player)
  66.         return
  67.     end
  68.     local t = exports["dmta_core"]:findPlayer(player, target)
  69.     if not t then
  70.         outputChatBox("dmta_itemshop > Nie odnaleziono podanego gracza.", player)
  71.         return
  72.     end
  73.     addGoldDays(t, days)
  74.     outputChatBox("dmta_itemshop > Nadałeś konto gold graczowi: "..utils:removeHex(getPlayerName(t))..", na "..days.." dni.", player)
  75.     outputChatBox("dmta_itemshop > Otrzymałeś konto gold na "..days.." dni", t)
  76.     outputChatBox("#fcc603[dmta_itemshop] > #ffffff"..utils:removeHex(getPlayerName(t)).." #ffd952zakupił konto gold na #ffffff"..days.." #ffd952dni, dziękujemy za wsparcie!", getRootElement(), 255, 255, 255, true)
  77. end)
  78.  
  79. addCommandHandler("premium",function(plr,cmd)
  80.         outputChatBox("-------------------------------------------------------------------------------------------------------------------", plr)
  81.         outputChatBox("✔ Aby zakupić premium/golda udaj się na stronę: http://denvermta-shop.mtasa.eu/", plr)
  82.         outputChatBox("✔ Po dokonanym zakupie automatycznie zostaniesz dodany do graczy premium!", plr)
  83.         outputChatBox("✔ Korzyści z posiadania usługi premium oraz golda znajdują się na stronie.", plr)
  84.         outputConsole("✔ Link do premium: http://denvermta-shop.mtasa.eu/", plr)
  85.         outputChatBox("-------------------------------------------------------------------------------------------------------------------", plr)
  86. end)
  87.  
  88. addCommandHandler("podmianki",function(plr,cmd)
  89.     outputChatBox("-------------------------------------------------------------------------------------------------------------------", plr)
  90.     outputChatBox("✔ Poniżej umieszczono listę pojazdów za realne pieniądze:", plr)
  91.     outputChatBox("✔ Audi A5, BMW e30, Bentley, BMW M2, Lamborghini, Corvette, Mercedes C63 AMG, Ferrari, Infernus GT, Agera", plr)
  92.     outputChatBox("✔ Cennik: 20 PSC/PayPal/Przelew/SMS", plr)
  93.     outputChatBox("✔ Dostępne podmianki możesz zobaczyć również w górnym salonie w LV!", plr)
  94.     outputChatBox("✔ Aby zakupić podmiankę zgłoś się do właścicieli!", plr)
  95.     outputChatBox("-------------------------------------------------------------------------------------------------------------------", plr)
  96. end)
  97.  
  98. losowanie = false
  99.  
  100. local wygrane = {
  101.     [1] = {wygrana = "premium na 1 dzień", type = "premium", procent = 40},
  102.     [2] = {wygrana = 1000000, type = "money", procent = 30},
  103.     [3] = {wygrana = "-50 RP", type = "rp", procent = 15},
  104.     [4] = {wygrana = -150000, type = "money", procent = 20},
  105.     [5] = {wygrana = 5000000, type = "money", procent = 10},
  106.     [6] = {wygrana = "unikatowa podmianka", type = "veh", procent = 1},
  107.  
  108. }
  109.  
  110. addCommandHandler("losowanie.gold", function(plr, cmd)
  111.     local zetony = tonumber(getElementData(plr, "player:zeton"))
  112.     if not zetony or zetony < 1 then
  113.         outputChatBox("* Nie posiadasz żetonów!", plr, 255, 0, 0)
  114.         return
  115.     end
  116.     if losowanie == true then
  117.         outputChatBox("* Już trwa jedno losowanie!", plr, 255, 0, 0)
  118.         return
  119.     end
  120.     setElementData(plr, "player:zeton", zetony-1)
  121.     losowanie = true
  122.     outputChatBox("* Ilość Twoich żetonów: "..getElementData(plr, "player:zeton"), plr, 255, 0, 0)
  123.     outputChatBox("* Losowanie rozpocznie się za: 3", plr, 255, 0, 0)
  124.     setTimer(function()
  125.         outputChatBox("* Losowanie rozpocznie się za: 2", plr, 255, 0, 0)
  126.     end, 1000, 1)
  127.     setTimer(function()
  128.         outputChatBox("* Losowanie rozpocznie się za: 1", plr, 255, 0, 0)
  129.     end, 2000, 1)
  130.     setTimer(function()
  131.         outputChatBox("* Losowanie rozpoczęto, proszę czekać..", plr, 0, 255, 0)
  132.     end, 3000, 1)
  133.    
  134.     setTimer(function(player)
  135.         for i = 1, #wygrane do
  136.             local r = math.random(1, 100)
  137.             if r > 0 and r <= wygrane[i].procent then
  138.                 outputChatBox("Losowanie zakończono, wygrałeś: "..wygrane[i].wygrana, plr, 0, 255, 0)
  139.                 if wygrane[i].type == "money" then
  140.                     givePlayerMoney(plr, wygrane[i].wygrana)
  141.                 elseif wygrane[i].type == "veh" then
  142.                               local los = math.random(1, 4)
  143.                               if los == 1 then
  144.                               exports["dmta_xdb"]:wykonaj("INSERT INTO `xyrusek_vehicles` (`model`, `mileage`, `fuel`, `owner`) VALUES (?, ?, ?, ?)", 502, 0, "40,40,0", getElementData(plr, "player:sid"))
  145.  
  146.                             elseif los == 2 then
  147.                                 exports["dmta_xdb"]:wykonaj("INSERT INTO `xyrusek_vehicles` (`model`, `mileage`, `fuel`, `owner`) VALUES (?, ?, ?, ?)", 421, 0, "40,40,0", getElementData(plr, "player:sid"))
  148.                               elseif los == 3 then
  149.                                 exports["dmta_xdb"]:wykonaj("INSERT INTO `xyrusek_vehicles` (`model`, `mileage`, `fuel`, `owner`) VALUES (?, ?, ?, ?)", 527, 0, "40,40,0", getElementData(plr, "player:sid"))
  150.                               elseif los == 4 then
  151.                                 exports["dmta_xdb"]:wykonaj("INSERT INTO `xyrusek_vehicles` (`model`, `mileage`, `fuel`, `owner`) VALUES (?, ?, ?, ?)", 529, 0, "40,40,0", getElementData(plr, "player:sid"))
  152.                               end
  153.                             elseif wygrane[i].type == "rp" then
  154.                     rp = getElementData(plr, "player:srp")
  155.                     setElementData(plr, "player:srp", rp-50)
  156.                 elseif wygrane[i].type == "premium" then
  157.                     addPremiumDays(plr,1)
  158.                 end
  159.                 return
  160.             end
  161.         end
  162.         outputChatBox("Losowanie zakończono, wygrałeś: nic", plr, 0, 255, 0)
  163.     end, 5000, 1, plr)
  164.     setTimer(function()
  165.    
  166.         losowanie = false
  167.  
  168.     end, 6000, 1)
  169. end)
  170.  
  171. addCommandHandler("dodaj.zetony", function(plr, cmd, cel, value )
  172.     if not exports["bmta_sadm"]:getAdmin(plr, 4) then return end
  173.     if not cel or not value then
  174.         outputChatBox("* Prawidłowe użycie komendy: /dodaj.zetony <nick/id> <ilość>", plr, 255, 0, 0)
  175.         return
  176.     end
  177.     local target = exports["dmta_core"]:findPlayer(plr, cel)
  178.     local zetonki = tonumber(getElementData(target, "player:zeton"))
  179.     setElementData(target, "player:zeton", zetonki+value)
  180.     outputChatBox("* Dodano "..value.." żetonów graczowi "..getPlayerName(target), plr, 255, 0, 0)
  181.     outputChatBox("* Otrzymano "..value.." żetonów od "..getPlayerName(plr), target, 255, 0, 0)
  182.     print(getElementData(target, "player:zeton"))
  183.  
  184. end)
  185.  
  186. addCommandHandler("autost", function(plr, cmd, uid, pojazd)
  187.     if getElementType(plr) ~= "console" then return end
  188.     if not uid then return end
  189.     if not pojazd then return end
  190.     model = getVehicleModelFromName(pojazd)
  191.          exports["dmta_xdb"]:wykonaj("INSERT INTO `xyrusek_vehicles` (`model`, `mileage`, `fuel`, `owner`, `tunning`) VALUES (?, ?, ?, ?)", model, 0, "40,40,0", uid, "1086, 1010")
  192.    outputConsole("Dodano furę ze stereo i nitro - chojnas")
  193. end
  194.  
  195.  
  196.  
  197. function removeHex(string)
  198.     return utils:removeHex(string)
  199. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement