Advertisement
Guest User

Untitled

a guest
Jan 8th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. local dbname = "x"
  2. local host = "x"
  3. local username = "x"
  4. local pass = "x"
  5.  
  6.  
  7.  
  8. local db = dbConnect("mysql", "dbname="..dbname..";host="..host.."", ""..username.."",""..pass.."","share=1")
  9.  
  10.  
  11.  
  12. local function checkVips ()
  13. local q = dbQuery ( db, "SELECT * FROM FR_Vipy" )
  14. local w = dbPoll ( q, -1 )
  15. dbFree ( q )
  16. local time = getRealTime ()
  17. month = time.month + 1
  18. year = time.year + 1900
  19. if time.hour < 10 then
  20. time.hour = "0"..time.hour
  21. end
  22. if time.minute < 10 then
  23. time.minute = "0"..time.minute
  24. end
  25. if time.second < 10 then
  26. time.second = "0"..time.second
  27. end
  28. if month < 10 then
  29. month = "0"..month
  30. end
  31. if time.monthday < 10 then
  32. time.monthday = "0"..time.monthday
  33. end
  34. local czas = ""..year.."-"..month.."-"..time.monthday.." "..time.hour..":"..time.minute..":"..time.second..""
  35. for _,v in ipairs ( w ) do
  36. if v.Termin == czas then
  37. gracz = getPlayerFromName ( v.Login )
  38. dbExec ( db, "DELETE FROM FR_Vipy WHERE Login = ?", v.Login )
  39. end
  40. end
  41. if gracz then
  42. outputChatBox ( "Twój termin ważności dla konta "..getPlayerName ( gracz ).." VIP minął!", gracz, 255, 255, 255 )
  43. gracz = false or nil
  44. end
  45. end
  46. setTimer ( checkVips, 1000, 0 )
  47.  
  48.  
  49. local function isVip ( login )
  50. local query = dbQuery ( db, "SELECT * FROM FR_Vipy" )
  51. local wynik = dbPoll ( query, -1 )
  52. dbFree ( query )
  53. tablica = {}
  54. for _,v in ipairs ( wynik ) do
  55. table.insert ( tablica, v )
  56. end
  57. if #tablica == 0 then
  58. return false
  59. elseif #tablica > 0 or #tablica < 0 then
  60. return true
  61. end
  62. return false
  63. end
  64.  
  65.  
  66. addCommandHandler ( "daj.vip", function ( plr, cmd, gracz, rok, miesiac, dzien, godzina, minuta, sekunda )
  67. if rok and miesiac and dzien and godzina and minuta and sekunda then
  68. if isVip ( gracz ) then
  69. return outputChatBox ( "Gracz "..gracz.." posiada już rangę VIP", plr, 255, 255, 255 )
  70. end
  71. local time = getRealTime()
  72. local y = time.year + 1900
  73. if tonumber(rok) < tonumber(y) then
  74. return outputChatBox ( "Rok nie może być mniejszy niż "..y, plr, 255, 255, 255 )
  75. end
  76. if tonumber(miesiac) > tonumber(12) or tonumber(miesiac) < tonumber(1) then
  77. return outputChatBox ( "Zakres miesiąca to 1-12", plr, 255, 255, 255 )
  78. end
  79. if tonumber ( dzien ) > tonumber ( 31 ) or tonumber( dzien ) < tonumber ( 1 ) then
  80. return outputChatBox ( "Zakres dnia miesiąca to 1-31", plr, 255, 255, 255 )
  81. end
  82. if tonumber ( godzina ) == 24 then
  83. return outputChatBox ( "Zakres godzin to 0-23", plr, 255, 255, 255 )
  84. end
  85. if tonumber ( minuta ) == 60 then
  86. return outputChatBox ( "Zakres minut to 0-59", plr, 255, 255, 255 )
  87. end
  88. if tonumber ( sekunda ) == 60 then
  89. return outputChatBox ( "Zakres sekund to 0-59", plr, 255, 255, 255 )
  90. end
  91. if tonumber(miesiac) < 10 then
  92. miesiac = "0"..tonumber(miesiac)
  93. end
  94. if tonumber( dzien ) < 10 then
  95. dzien = "0"..tonumber( dzien )
  96. end
  97. if tonumber ( sekunda ) < 10 then
  98. sekunda = "0"..tonumber ( sekunda )
  99. end
  100. if tonumber ( minuta ) < 10 then
  101. minuta = "0"..tonumber ( minuta )
  102. end
  103. local data = ""..rok.."-"..miesiac.."-"..dzien.." "..godzina..":"..minuta..":"..sekunda..""
  104. x = dbExec ( db, "INSERT INTO FR_Vipy ( Login, Termin ) VALUES ( ?,? )", gracz, data )
  105. if x then
  106. outputChatBox ( "Nadano rangę VIP dla gracza "..gracz.." do dnia "..data, plr, 0, 255, 0 )
  107. end
  108. end
  109. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement