• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[TFS 1.0] TalkActions !commands

samuelav3

Member
Joined
Aug 18, 2014
Messages
95
Reaction score
5
hey friends someone could tell me how to make all the players command to see a list
 
PHP:
local config = {
   ingameGuilds = getBooleanFromString(getConfigValue('ingameGuildManagement'))
}

function onSay(cid, words, param, channel)
   if(not checkExhausted(cid, 666, 10)) then
     return false
   end

   local playerAccess, t = getPlayerAccess(cid), {}
   for i, talk in ipairs(getTalkActionList()) do
     if(not talk.hidden and playerAccess >= talk.access) then
       if(config.ingameGuilds or (talk.functionName ~= "guildjoin" and talk.functionName ~= "guildcreate")) then
         table.insert(t, talk)
       end
     end
   end

   table.sort(t, function(a, b) return a.access > b.access end)
   local lastAccess, str = -1, ""
   for i, talk in ipairs(t) do
     local line = ""
     if(lastAccess ~= talk.access) then
       if(i ~= 1) then
         line = "\n"
       end
       lastAccess = talk.access
     end
     str = str .. line .. talk.words .. "\n"
   end

   doShowTextDialog(cid, 6533, str)
   return true
end

Test this.
 
PHP:
local config = {
   ingameGuilds = getBooleanFromString(getConfigValue('ingameGuildManagement'))
}

function onSay(cid, words, param, channel)
   if(not checkExhausted(cid, 666, 10)) then
     return false
   end

   local playerAccess, t = getPlayerAccess(cid), {}
   for i, talk in ipairs(getTalkActionList()) do
     if(not talk.hidden and playerAccess >= talk.access) then
       if(config.ingameGuilds or (talk.functionName ~= "guildjoin" and talk.functionName ~= "guildcreate")) then
         table.insert(t, talk)
       end
     end
   end

   table.sort(t, function(a, b) return a.access > b.access end)
   local lastAccess, str = -1, ""
   for i, talk in ipairs(t) do
     local line = ""
     if(lastAccess ~= talk.access) then
       if(i ~= 1) then
         line = "\n"
       end
       lastAccess = talk.access
     end
     str = str .. line .. talk.words .. "\n"
   end

   doShowTextDialog(cid, 6533, str)
   return true
end

Test this.

WTF that has nothign to do with what he asked
 
I would done something like this:

Code:
local config = {
    listItemId = 1966,
    staffCommands = {
        '/ban',
        '/ipban',
        '/unban',
        '/up',
        '/down',
        '/c',
        '/goto',
        '/owner',
        '/t',
        '/town',
        '/a',
        '/pos',
        '/info',
        '/r',
        '/kick',
        '/openserver',
        '/closeserver',
        '/B',
        '/m',
        '/i',
        '/s',
        '/addtutor',
        '/removetutor',
        '/looktype',
        '/summon',
        '/chameleon',
        '/addskill',
        '/mccheck',
        '/ghost',
        '/clean',
        '/hide',
        '/save',
        '/gm'
    },
    playerCommands = {
        '!buypremium',
        '!buyhouse',
        '!leavehouse',
        '!changesex',
        '!uptime',
        '!deathlist',
        '!kills',
        '!online',
        '!serverinfo'
    }
}

function onSay(cid, words, param)
    local player = Player(cid)
    local storeCommands = {}
    local text = ''
    local line = 0

    if player:getGroup():getAccess() then
        for i = 1, #config.staffCommands do
            storeCommands[#storeCommands + 1] = config.staffCommands[i]
        end

        for i = 1, #config.playerCommands do
            storeCommands[#storeCommands + 1] = config.playerCommands[i]
        end       

        text = text .. 'Commands:'
        for _, t in ipairs(storeCommands) do
            line = line + 1
            text = text ..'\n '.. line ..'. '.. t ..''
        end
        player:showTextDialog(config.listItemId, text)
    else
        for i = 1, #config.playerCommands do
            storeCommands[#storeCommands + 1] = config.playerCommands[i]
        end
        text = text .. 'Commands:'
        for _, t in ipairs(storeCommands) do
            line = line + 1
            text = text ..'\n '.. line ..'. '.. t ..''
        end
        player:showTextDialog(config.listItemId, text)   
    end
    return false
end
 
I would done something like this:

Code:
local config = {
    listItemId = 1966,
    staffCommands = {
        '/ban',
        '/ipban',
        '/unban',
        '/up',
        '/down',
        '/c',
        '/goto',
        '/owner',
        '/t',
        '/town',
        '/a',
        '/pos',
        '/info',
        '/r',
        '/kick',
        '/openserver',
        '/closeserver',
        '/B',
        '/m',
        '/i',
        '/s',
        '/addtutor',
        '/removetutor',
        '/looktype',
        '/summon',
        '/chameleon',
        '/addskill',
        '/mccheck',
        '/ghost',
        '/clean',
        '/hide',
        '/save',
        '/gm'
    },
    playerCommands = {
        '!buypremium',
        '!buyhouse',
        '!leavehouse',
        '!changesex',
        '!uptime',
        '!deathlist',
        '!kills',
        '!online',
        '!serverinfo'
    }
}

function onSay(cid, words, param)
    local player = Player(cid)
    local storeCommands = {}
    local text = ''
    local line = 0

    if player:getGroup():getAccess() then
        for i = 1, #config.staffCommands do
            storeCommands[#storeCommands + 1] = config.staffCommands[i]
        end

        for i = 1, #config.playerCommands do
            storeCommands[#storeCommands + 1] = config.playerCommands[i]
        end      

        text = text .. 'Commands:'
        for _, t in ipairs(storeCommands) do
            line = line + 1
            text = text ..'\n '.. line ..'. '.. t ..''
        end
        player:showTextDialog(config.listItemId, text)
    else
        for i = 1, #config.playerCommands do
            storeCommands[#storeCommands + 1] = config.playerCommands[i]
        end
        text = text .. 'Commands:'
        for _, t in ipairs(storeCommands) do
            line = line + 1
            text = text ..'\n '.. line ..'. '.. t ..''
        end
        player:showTextDialog(config.listItemId, text)  
    end
    return false
end


Thank you very much, old post, still very usefull for me. (Runing on TFS 1.2)
 
Back
Top