Jump to content
LuffyDragon

Function - HandleChat

Recommended Posts

Hello! I'm in need of a help with the functions HandleChat, the one used to open the bank, forge, fusion, appfusion, appupgrade on any map using the symbol / (ex: / Bank), I installed the unit.lua everything right, so that I still could not, they could pass me the step by step...

Share this post


Link to post
Share on other sites

You need V3ctor Gameserver.exe with HandleChat

 

make addon.lua and put code:

 

<QUOTE>

-----------------------
--     Function      --
-----------------------
--Commands
CMD_HANDLER_GM = {}
CMD_HANDLER_NORMAL = {}

--Eudaemon pages
EUDAEMON_CMDS = 1

LocalChat = {}
-- Main chat handling function
function HandleChat(role, message)

    if (string.find(message, "/") == 1) then
    
        local command = string.sub(message, 2)
        if (command == "") then
            SystemNotice(role, "Unknown command! Type /cmds to see a list of commands.")
            return 0
        end
        
        local param = {n = 0}
        params = string.find(command, " ")
        if (params == nil) then
            cmd = string.lower(command)
        else
            cmd = string.lower(explode(" ", command)[0])
            params = string.sub(command, params + 1)
            param = explode(",", params)
            param.n = table.getn(param)
        end
        
        if (CMD_HANDLER_NORMAL[cmd] ~= nil) then
        
            CMD_HANDLER_NORMAL[cmd](role, param)
            return 0
        end
        
        if (GetGmLv(role) == 99) then
        
            if (CMD_HANDLER_GM[cmd] ~= nil) then
            
                CMD_HANDLER_GM[cmd](role, param)
                return 0
            
            end
        
        end
        
        SystemNotice(role, "Unknown command! Type /cmds to see a list of commands.")
        
        return 0
    
    end
    
    -- Muting Spammer
--[[    local minute = os.date("%M")
    if (LocalChat[role] == nil) then
        LocalChat[role] = {}
    else

        if (LocalChat[role].minute == minute) then
            
            -- 25 messages are maximum
            if (LocalChat[role].number > 15) then
                -- Mute player
                SystemNotice(role, "Don't flood in local chat please! You are now temporarily muted.")
                return 0
            else
                LocalChat[role].number = LocalChat[role].number + 1
            end
            
        else
            LocalChat[role].minute = minute
            LocalChat[role].number = 1
        end
]]--    end
    
    return 1

end

function trim(s)
    return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end

function explode(separator, str)
    local pos, i, arr = 0, 0, {}
    for st, sp in function() return string.find(str, separator, pos, true) end do
        table.insert(arr, i, trim(string.sub(str, pos, st-1)))
        pos = sp + 1
        i = i + 1
    end
    table.insert(arr, i, trim(string.sub(str, pos)))
    return arr
end

function ShowWindow(role, page)

    local ret, npc = GetEudemon()
    local ret, id = GetScriptID(npc)
    
    JumpPage(role, npc, NpcInfoList[id].page, page)
    
end

function ShowTrade(role)

    local ret, npc = GetEudemon()
    local ret, id = GetScriptID(npc)
    
    BuyPage(role, npc, NpcInfoList[id].trade)
end

function ShowText(role, text)

    local packet = GetPacket();
    WriteCmd(packet, CMD_MC_TALKPAGE);
    WriteDword(packet, -1)
    WriteByte(packet, -1)
    WriteString(packet, text)
    SendPacket(role, packet);

end

-- User defined commands
CMD_HANDLER_GM["cmds"] = function(role, param)
    HelpInfo(role, 0, "GM Command List:_/online - Check Online Player_/time - Check server time_/buff - Give full buffs_/teleport - Teleport you anywhere_/bank - Open Bank_/forge - Forging System_/socket - Socket System_/fusion - Apparel Fusion System_/appupgrade - Apparel Upgrade System_/combine - Gem Combine System_/extract - Extract System_/setupgrade - Upgrading System_/cash - Gives 1B Gold_/summon - Summon a monster")
end

CMD_HANDLER_GM["buff"] = function(role, param)
    Buff_scripts(role)
end

CMD_HANDLER_GM["make"] = function(role, param)
    if param.n ~= 2 then
    BickerNotice(role, 'This command requires 2 paramenters! /make itemid,itemqty')
    return
    end
    param[1] = tonumber(param[1])
    param[2] = tonumber(param[2])
    local itemid, itemqty
    if type(param[1]) == 'number' and type(param[2]) == 'number' then
        itemid = tonumber(param[1])
        itemqty = tonumber(param[2])
    else
        BickerNotice(role, 'Parameters of /make must be numerical values!')
        return
    end
    GiveItem(role, 0, itemid, itemqty, 4)
end    

CMD_HANDLER_GM["gmlv"] = function(role, param)
    if param.n ~= 0 then
        BickerNotice(role, 'This command requires zero parameters! /gmlv')
        return
    end
    BickerNotice(role, 'Account: '..GetActName(role)..' GM Level '..GetGmLv(role))
    return
end

-- GM commands
CMD_HANDLER_GM["online"] = function(role, param)
    SystemNotice(role, 'Players Online: '..GetOnlineCount())
end    


CMD_HANDLER_GM["onlinegm"] = function(role, param)
    local enable = false;
    if enable == true then
        if param.n ~= 0 then
            BickerNotice(role, 'This command requires zero parameters! /onlinegm')
            return
        end
        local a = {}
        for i,v in pairs(GPBN.role) do
            if GetGmLv(v) > 0 then
                table.insert(a, i)
            end
        end
        if table.getn(a) ~= 0 then
            SystemNotice(role, 'Total gms online:')
            for t = 1, table.getn(a) do
                SystemNotice(role, '- '..a[t])
            end
        else
            SystemNotice(role, 'No gms found online!')
            return
        end
    else
        SystemNotice(role, 'This command is currently disabled!')
        return
    end
end

CMD_HANDLER_GM["time"] = function(role, param)
    local Hour   = os.date("%I")    -- Hour Scripts
    local Minute = os.date("%M")    -- Minute Scripts
    local Second = os.date("%p")    -- AM/PM
    local Day   = os.date("%d")    -- Day Scripts
    local Month = os.date("%b")    -- Month Scripts
    local Year = os.date("%Y")    -- Year Scripts
    local DD = os.date("%A") -- Day Name
    SystemNotice(role, "--------- Server Status ----------  ")
    SystemNotice ( role, "Server Time: "..Hour..":"..Minute..":"..Second.." ")
    SystemNotice ( role, "Server Date: "..Month..":"..Day..":"..Year.." "..DD.."")
    SystemNotice(role, "---------------------------------- ")
end    

CMD_HANDLER_GM["buff"] = function(role, param)
    Buff_scripts(role)
end    

CMD_HANDLER_GM["teleport"] = function(role, param)
    if (param.n ~= 1) then
        ShowWindow(role, EUDAEMON_TELEPORT)
        return
    end
    
    for key, map in pairs(TeleMapList) do
    
        if (param[0] == key) then
        
            GoTo(role, map.xpos, map.ypos, map.name)
        end
    end
end

CMD_HANDLER_GM["bank"] = function(role, param)
    OpenBank(role, role)
end

CMD_HANDLER_GM["forge"] = function(role, param)
    OpenForge(role, role)
end

CMD_HANDLER_GM["socket"] = function(role, param)
    OpenMilling(role, role)
end

CMD_HANDLER_GM["fusion"] = function(role, param)
    OpenFusion(role, role)
end

CMD_HANDLER_GM["appupgrade"] = function(role, param)
    OpenUpgrade(role, role)
end

CMD_HANDLER_GM["combine"] = function(role, param)
    OpenUnite(role, role)
end

CMD_HANDLER_GM["extract"] = function(role, param)
    OpenGetStone(role, role)
end

CMD_HANDLER_GM["setupgrade"] = function(role, param)
    OpenItemTiChun(role, role)
end

CMD_HANDLER_GM["cash"] = function(role, param)
     local gm_cash = 1000000000
    AddMoney ( role , 0 , gm_cash )
end
    
CMD_HANDLER_GM["forgep"] = function(role, param)
    local item = GetChaItem(role, 2, param[0])
    local itemParam = GetItemForgeParam(item, 1)
    --print(itemParam)
end

CMD_HANDLER_GM["forgeps"] = function(role, param)
    local item = GetChaItem(role, 2, param[0])
    SetItemForgeParam(item, 1, param[1])
end


CMD_HANDLER_GM["eff"] = function(role, param)
    PlayEffect(role, param[0])
end

CMD_HANDLER_GM["effad"] = function(role, param)
    AddState(role, role, param[0], param[1], 3600)
end

CMD_HANDLER_GM["effre"] = function(role, param)
    RemoveState(role, param[0])
end

CMD_HANDLER_GM["summon"] = function(role, param)
    local x, y = GetChaPos(role)
    local monster = CreateChaX(param[0], x, y, 145, 3700, role)
    SetChaLifeTime(monster, param[1])
    SetChaAIType(monster, param[2])
end

CMD_HANDLER_GM["itemattr"] = function(role, param)
    if (param.n == 2) then
    
        local item = GetChaItem(role, 2, param[0])
        --print(item)
        local attr = GetItemAttr(item, param[1])
        --print(attr)
        SystemNotice(role, attr)
    
    elseif (param.n == 3) then
    
        local item = GetChaItem(role, 2, param[0])
        SetItemAttr(item, param[1], param[2])
    
    else
        SystemNotice(role, "Error")
    end
end

CMD_HANDLER_GM["fusion2"] = function(role, param)
    local apparel = GetChaItem(role, 2, param[0])
    local equipment = GetChaItem(role, 2, param[1])
    local equipmentID = GetItemID(equipment)
    SetItemAttr(apparel, ITEMATTR_VAL_FUSIONID, equipmentID)
    FusionItem(apparel, equipment)
end

CMD_HANDLER_GM["dropevet"] = function(role, param)
    local CoordX, CoordY = GetChaPos(role)
    local ItemID, Quantity = param[0], param[1]
    local MapCopy = GetChaMapCopy(role)
    if CoordX == nil or CoordY == nil or ItemID == nil or Quantity == nil or MapCopy == nil then return end
    MonsterItem = CreateChaEx(param[2], CoordX, CoordY, 145, 50, MapCopy)
    SetChaLifeTime(MonsterItem, 1)
    SystemNotice(role, param[0].."/"..param[1].."/"..param[2].."/"..param[3].."/"..param[4].."/"..param[5].."/"..param[6])
    GiveItem(MonsterItem, 0, ItemID, Quantity, 4)
    RemoveChaItem(MonsterItem, ItemID, Quantity, param[3], param[4], param[5], param[6])
end

CMD_HANDLER_GM["attr"] = function(role, param)
    local attr = GetChaAttr(role, param[0])
    SystemNotice(role, attr)
end

CMD_HANDLER_GM["getido"] = function(role, param)
    local cha = GetChaPlayer(role)
    local id = GetPlayerID(cha)
    --print(id)
end

CMD_HANDLER_GM["getmac"] = function(role, param)
    local player = GetChaPlayer(role)
    local playerID = GetPlayerID(player)
    local mac = GetMac(playerID)
    SystemNotice(role, "Your MAC address is "..mac)
end

CMD_HANDLER_GM["eff"] = function(role, param)
    
    PlayEffect(role, param[0])

end

-- Players CMD
CMD_HANDLER_NORMAL["name"] = function(player, param)

    if (param.n == 0)then
    
        ShowText(player, "Please enter a name");
        return;
    
    end
    
    if (param.n > 1)then
    
        ShowText(player, "Cannot use space in name");
        return;
    
    end
    
    if (string.len(param[0]) > 15)then
    
        ShowText(player, "Cannot be longer than 15 characters");
        return
    
    end
    
    if (CheckBagItem(player, 9441) == 0)then
    
        ShowText(player, "You don't have change name card");
        return;
    
    end
    
    TakeItem(player, 0, 9441, 1);
    ShowText(player, "Your name has been changed! Please relog to apply changes. Thank you.");
    ChangeName(player, param[0]);

end

CMD_HANDLER_NORMAL["cmds"] = function(role, param)
    HelpInfo(role, 0, "Command List:_/bank - Open Bank_/forge - Forging System_/socket - Socket System_/fusion - Apparel Fusion System_/appupgrade - Apparel Upgrade System_/combine - Gem Combine System_/extract - Extract System_/setupgrade - Upgrading System")
end

CMD_HANDLER_NORMAL["bank"] = function(role, param)
    OpenBank(role, role)
end

CMD_HANDLER_NORMAL["forge"] = function(role, param)
    OpenForge(role, role)
end

CMD_HANDLER_NORMAL["socket"] = function(role, param)
    OpenMilling(role, role)
end

CMD_HANDLER_NORMAL["fusion"] = function(role, param)
    OpenFusion(role, role)
end

CMD_HANDLER_NORMAL["appupgrade"] = function(role, param)
    OpenUpgrade(role, role)
end

CMD_HANDLER_NORMAL["combine"] = function(role, param)
    OpenUnite(role, role)
end

CMD_HANDLER_NORMAL["extract"] = function(role, param)
    OpenGetStone(role, role)
end

CMD_HANDLER_NORMAL["setupgrade"] = function(role, param)
    OpenItemTiChun(role, role)
end</QUOTE>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...