View difference between Paste ID: EC7jBLDe and 7tiVbNt9
SHOW: | | - or go back to the newest paste.
1-
--[[ Coded by Asandru & Rochet2 ]]--
1+
-- command, minGMLevel, syntax
2
local Table =  {
3-
--[[ How to add a new function for a custom command?
3+
    ["vipinfo"]     = { 0, ".vipinfo <player name>" },
4-
    The function name should look like this, where "COMMAND" is your custom command
4+
    ["viplevel"]    = { 1, ".viplevel <player name> <new level>"},
5
}
6-
    function Commands.COMMAND(player, p)
6+
7-
    local pr = { }
7+
-- Here we check if the written command exists in the table
8-
    for param in string.gmatch(p, "([^ ]+)", 3) do table.insert(pr, param) end
8+
-- If command exists in table then we handle
9-
        -- now do stuff
9+
10
    local cmd, parameters = command:match("([^%s]+)%s?(.*)")
11-
]]--
11+
    if not cmd then
12
        return
13-
-- Those commands works only if they don't exist in core and if used ! or .
13+
14-
-- command, minGMLevel, parameters
14+
15-
local Commands = { }
15+
16
            player:HandleCommand(com, parameters)
17-
    ["transform"]    = { 0, "Syntax: .transform <player name> <morph id>" },
17+
            return false
18-
    ["scale"]          = { 1, "Syntax: .scale <player name> <new scale>"},
18+
19-
} 
19+
20
end
21-
-- [1] Handle Transform Command
21+
22-
function Commands.transform(player, p)
22+
-- Here we handle all available commands
23-
    local pr = { }
23+
-- We check if player has required gm level to use that command
24-
    for param in string.gmatch(p, "([^ ]+)", 3) do table.insert(pr, param) end
24+
function Player:HandleCommand(command, parameters)
25
    if (self:GetGMRank() >= Table[command][1]) then
26-
    target = GetPlayerByName(pr[1])
26+
        if (command == "vipinfo") then
27-
    mrophId = pr[2]
27+
            SendWorldMessage("Here we do something for command vipinfo")
28
        else
29-
    if (target) then
29+
            self:SendBroadcastMessage("|cffFF0000Command not yet handled!")
30-
        target:SetDisplayId(mrophId)
30+
31
    end
32
end
33
34-
-- [2] Handle Scale Command
34+