OldHero 12 Report post Posted January 6, 2017 Hello Guys. i have request do some have command script for /buff or like in spo /pot Hmm ??? 1 Quote Share this post Link to post Share on other sites
Rinor 59 Report post Posted January 6, 2017 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 ) Quote Share this post Link to post Share on other sites
OldHero 12 Report post Posted January 6, 2017 Ye bro i have that but still wer is comnmand script .. Quote Share this post Link to post Share on other sites
Guest Report post Posted January 6, 2017 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 Quote Share this post Link to post Share on other sites
MonkeyCode 453 Report post Posted January 6, 2017 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 Quote Share this post Link to post Share on other sites
Vasil 71 Report post Posted January 6, 2017 Without forgetting DelChaItem. Quote Share this post Link to post Share on other sites
Rinor 59 Report post Posted January 6, 2017 @KONG is this a new one? Quote Share this post Link to post Share on other sites
Rinor 59 Report post Posted January 6, 2017 (edited) 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 January 7, 2017 by Rinor Quote Share this post Link to post Share on other sites
OldHero 12 Report post Posted January 7, 2017 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 } Quote Share this post Link to post Share on other sites
Vasil 71 Report post Posted January 7, 2017 I answered that question already OldHero "DelChaItem" Quote Share this post Link to post Share on other sites
MonkeyCode 453 Report post Posted January 7, 2017 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 Quote Share this post Link to post Share on other sites
Fajar 1 Report post Posted January 15, 2017 @KONG where i can put ChatHandler? Quote Share this post Link to post Share on other sites
xEvo7 65 Report post Posted January 15, 2017 59 minutes ago, Fajar said: @KONG where i can put ChatHandler? Functions.lua or make an extension 1 Quote Hit Like If You Like It! Share this post Link to post Share on other sites
Fajar 1 Report post Posted January 15, 2017 Thanks @xEvo7 Quote Share this post Link to post Share on other sites