Advertisement
Rochet2

PvP timed msg

Apr 10th, 2012
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. local T, OnChat, GetList = {}
  2. local low, high = 1, 50
  3.  
  4. function OnChat(event, pPlayer, pMessage, pType, pLanguage, pMisc)
  5.     local msg = pMessage:lower()
  6.     if(msg:find("[.!]top .+") == 1) then
  7.         local Amount = tonumber(msg:match("[.!]top (.+)"))
  8.         if(Amount) then
  9.             local str = tostring(pPlayer)
  10.             if(Amount <= high and Amount >= low) then
  11.                 GetList(pPlayer, Amount)
  12.                 if(T[str]) then
  13.                     DestroyLuaEvent(T[str])
  14.                 end
  15.                 T[str] = CreateLuaEvent(function() GetList(pPlayer,Amount); end, 60000, 0)
  16.             else
  17.                 pPlayer:SendBroadcastMessage("Bad value. "..low.."-"..high.." accepted. Use \"Stop\" to stop.")
  18.             end
  19.         else
  20.             pPlayer:SendBroadcastMessage("Stopped PvP message")
  21.             if(T[str]) then
  22.                 DestroyLuaEvent(T[str])
  23.             end
  24.         end
  25.         return false
  26.     end
  27. end
  28.  
  29. function GetList(pPlayer, Amount)
  30.     local Q = CharDBQuery("SELECT name, pvprank FROM Characters ORDER BY pvprank DESC LIMIT "..Amount)
  31.     if(Q) then
  32.         for i = 1, Q:GetRowCount() do
  33.             pPlayer:SendBroadcastMessage(i..". "..Q:GetColumn(0):GetString().." - "..Q:GetColumn(1):GetULong().." kills")
  34.             Q:NextRow()
  35.         end
  36.     else
  37.         pPlayer:SendBroadcastMessage("No players found")
  38.     end
  39. end
  40.  
  41. RegisterServerHook(16, OnChat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement