SHOW:
|
|
- or go back to the newest paste.
1 | - | local T, OnChat, GetList = {} |
1 | + | local 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) |
11 | + | local Q = CharDBQuery("SELECT name, pvprank FROM Characters ORDER BY pvprank DESC LIMIT "..Amount) |
12 | - | if(T[str]) then |
12 | + | if(Q) then |
13 | - | DestroyLuaEvent(T[str]) |
13 | + | for i = 1, Q:GetRowCount() do |
14 | pPlayer:SendBroadcastMessage(i..". "..Q:GetColumn(0):GetString().." - "..Q:GetColumn(1):GetULong().." kills") | |
15 | - | T[str] = CreateLuaEvent(function() GetList(pPlayer,Amount); end, 60000, 0) |
15 | + | Q:NextRow() |
16 | end | |
17 | - | pPlayer:SendBroadcastMessage("Bad value. "..low.."-"..high.." accepted. Use \"Stop\" to stop.") |
17 | + | else |
18 | pPlayer:SendBroadcastMessage("No players found") | |
19 | - | else |
19 | + | |
20 | - | pPlayer:SendBroadcastMessage("Stopped PvP message") |
20 | + | |
21 | - | if(T[str]) then |
21 | + | pPlayer:SendBroadcastMessage("Bad value. "..low.."-"..high.." accepted.") |
22 | - | DestroyLuaEvent(T[str]) |
22 | + | |
23 | end | |
24 | return false | |
25 | end | |
26 | end | |
27 | ||
28 | RegisterServerHook(16, OnChat) |