Jump to content
Sign in to follow this  
OldHero

Command Request

Recommended Posts

56 minutes ago, OldHero said:

Hello Guys. i have request do some have command script for

/buff or like in spo /pot

Hmm ???

Take V3ct0r gameserver and use Handle Chat for that.
( You can get them at Archive - mega.nz/#F!OUMUgTYb!jtCsqh7halK_O9uzWyaG0g!Sd0V1Tga )

Share this post


Link to post
Share on other sites
Guest
5 minutes ago, OldHero said:

Ye bro i have that but still wer is comnmand script .. 

Very nice attitude, so polite also.

function HandleChat(role, message)
if (message == "/buff") then
AddState (role, role, STATE_XLZH, 10, 300)

AddState (role, role, STATE_SHPF, 10, 300)

AddState (role, role, STATE_MLCH, 10, 300)

AddState (role, role, STATE_FZLZ, 10, 300)

AddState (role, role, STATE_JSFB, 10, 300)

AddState (role, role, STATE_TSHD, 10, 300)

return 0

end

return 1

end

Share this post


Link to post
Share on other sites
print( "Loading ChatHandler.lua" )

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

cmd = {} local cmd = cmd
cmd.symbol = '/'
cmd.list = {}

function HandleChat(role, message)
    if string.find(message, cmd.symbol) == 1 then
        local t = string.lower(string.sub(message, 2))
        if t == '' then
            BickerNotice(role, 'Enter a command after the dash: / or for more help, enter /help')
            return 0
        end
        local param = {n = 0}
        local r = string.find(t, ' ')
        if r == nil then     t = string.sub(message, 2)
        else                 t = string.sub(message, 2, r)
                            local arg = string.sub(message, r + 2)
                            param = explode(',', arg)
                            param.n = table.getn(param)
        end
        if cmd.list[t] ~= nil then
            local NocLock =    KitbagLock(role, 0)
            if NocLock ~= LUA_FALSE then
                if not cmd.canexecute(role, t, param) then
                    return 0
                end
                cmd.list[t].func(role, param)
                return 0
            else
                BickerNotice(role, 'Unlock inventory before inputting a command!');
                return 0;
            end
        else
            BickerNotice(role, 'Entered an invalid command!')
            return 0
        end
        return 0
    end
    return 1
end

cmd.checkparam = function(role, t, name)
    for i = 1, table.getn(cmd.list[name].param) do
        local func;
        if cmd.list[name].param[i] == 'number' then
            func = tonumber
        elseif cmd.list[name].param[i] == 'string' then
            func = tostring
        end
        t[i] = func(t[i])
        if type(t[i]) ~= cmd.list[name].param[i] then
            BickerNotice(role, 'Parameter '..i..' must be a '..cmd.list[name].param[i]..'!')
            return false
        end
    end
    return true
end

cmd.canexecute = function(role, name, param)
    if GetGmLv(role) < cmd.list[name].gm then
        BickerNotice(role, 'This command requires GM Lv'..cmd.list[name].gm..' authorization!')
        return false
    end
    if param.n ~= table.getn(cmd.list[name].param) then
        BickerNotice(role, 'This command requires '..table.getn(cmd.list[name].param)..' paramenters! '..cmd.list[name].info..'')
        return false
    end
    if not cmd.checkparam(role, param, name) then
        return false
    end
    return true
end

 

example usage:

cmd.list['make'] = {
    gm = 99,
    param = {'number','number'},
    info = '/make itemid, itemqty',
    help = 'Creates an item and it\'s amount',
    func = function(role, param)
        GiveItem(role, 0, param[1], param[2], 4)
    end
}

cmd.list['gmnotice'] = {
    gm = 99,
    param = {'string'},
    info = '/gmnotice msg',
    help = 'Display message on the GM Panel',
    func = function(role, param)
        GMNotice(param[1])
    end
}

local a = ''
for i,v in pairs(cmd.list) do
    a = a..v.info..'_'..
    '    GM lv required: '..v.gm..'_'..
    '    Arguments: '..table.getn(v.param)..'_'..
    '    Info: '..v.help..'_'
end
cmd.list['help'] = {
    gm = 0,
    param = {},
    info = '/help',
    help = 'Display all available commands',
    func = function(role, param)
        HelpInfo(role, 0, a)
    end
}

note the array

cmdlist[*].param = {...}

-- this determines how many param should this command have and what is the type() of that param.

cmdlist[*].gm -- this determine the gm level required to execute the function


kong.png

a2.png

Share this post


Link to post
Share on other sites
On 1/6/2017 at 4:03 PM, OldHero said:

Hello Guys. i have request do some have command script for

/buff or like in spo /pot

Hmm ???

Check and use the one @KONG just posted..
Here how you make buff:
Before this:

local a = ''
for i,v in pairs(cmd.list) do

Add this:

cmd.list['buff'] = {
    gm = 0,
    param = {'number'},
    info = '/buff',
    help = 'Gives Buff to Player',
    func = function(role, param)
    if param.n ~= 1 then
        BickerNotice(role, 'This command requires one parameters! /buff minutes')
        return
    end
    param[1] = tonumber(param[1])
    if type(param[1]) == 'number' then
        SystemNotice(role, 'Player granted '..param[1]..' min(s) of buff!')
        param[1] = param[1] * 60
        AddState(role, role, STATE_XLZH, 10, param[1])
        AddState(role, role, STATE_SHPF, 10, param[1])
        AddState(role, role, STATE_TSHD, 10, param[1])
        AddState(role, role, STATE_MLCH, 10, param[1])
        AddState(role, role, STATE_FZLZ, 10, param[1])
        return
    else
        BickerNotice(role, 'Parameters of /buff must be numerical values!')
        return
    end
end
}

Ingame use command: /buff 1 or /buff 99   ( 1 = 1 minute, 99 = 99 minutes.. etc.. )
I tested it already and works fine.

Edited by Rinor

Share this post


Link to post
Share on other sites

Ty Guys 1x more request in this  how i can make when you use that command so it take you 5 fairy coin example  hmm?? 

cmd.list['buff'] = {
    gm = 0,
    param = {'number'},
    info = '/buff',
    help = 'Gives Buff to Player',
    func = function(role, param)
    if param.n ~= 1 then
        BickerNotice(role, 'This command requires one parameters! /buff minutes')
        return
    end
    param[1] = tonumber(param[1])
    if type(param[1]) == 'number' then
        SystemNotice(role, 'Player granted '..param[1]..' min(s) of buff!')
        param[1] = param[1] * 60
        AddState(role, role, STATE_XLZH, 10, param[1])
        AddState(role, role, STATE_SHPF, 10, param[1])
        AddState(role, role, STATE_TSHD, 10, param[1])
        AddState(role, role, STATE_MLCH, 10, param[1])
        AddState(role, role, STATE_FZLZ, 10, param[1])
        return
    else
        BickerNotice(role, 'Parameters of /buff must be numerical values!')
        return
    end
end
}

Share this post


Link to post
Share on other sites
cmd.list['buff'] = {
    gm = 0,
    param = {'number'},
    info = '/buff',
    help = 'Gives Buff to Player',
    func = function(role, param)
        SystemNotice(role, 'Player granted '..param[1]..' min(s) of buff!')
        param[1] = param[1] * 60
        AddState(role, role, STATE_XLZH, 10, param[1])
        AddState(role, role, STATE_SHPF, 10, param[1])
        AddState(role, role, STATE_TSHD, 10, param[1])
        AddState(role, role, STATE_MLCH, 10, param[1])
        AddState(role, role, STATE_FZLZ, 10, param[1])
    end
}

You can just do that because:

14 hours ago, KONG said:

note the array

cmdlist[*].param = {...}

-- this determines how many param should this command have and what is the type() of that param.

cmdlist[*].gm -- this determine the gm level required to execute the function

 


kong.png

a2.png

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.

Sign in to follow this  

×
×
  • Create New...