• 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!

Lua Need Command /Online What Show Name of Player Level and Vocation and Reset Storage of Reset: 54676

Solution
change
Lua:
strings[position] = strings[position] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
to
Lua:
strings[position] = strings[position] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "][" .. getVocationInfo(getPlayerVocation(pid)).name .. "][" .. getCreatureStorage(pid, 54676) .. "]"
XML:
<talkaction words="/Online" script="online.lua" />
Lua:
function onSay(player, words, param)
    local msg = player:getName() .. ", " .. player:getLevel() .. ", " .. player:getStorageValue(54676)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg)
    return false
end
 
Could revscript with what is already in the server base

Lua:
local config = {
    showGamemasters = getBooleanFromString(getConfigValue('displayGamemastersWithOnlineCommand'))
}

function onSay(cid, words, param, channel)
    local players = getPlayersOnline()
    local strings = {""}

    local i, position = 1, 1
    local added = false
    for _, pid in ipairs(players) do
        if(added) then
            if(i > (position * 7)) then
                strings[position] = strings[position] .. ","
                position = position + 1
                strings[position] = ""
            else
                strings[position] = i == 1 and "" or strings[position] .. ", "
            end
        end

        if((config.showGamemasters or getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) or not getPlayerCustomFlagValue(pid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)) and (not isPlayerGhost(pid) or getPlayerGhostAccess(cid) >= getPlayerGhostAccess(pid))) then
            strings[position] = strings[position] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
            i = i + 1
            added = true
        else
            added = false
        end
    end

    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (i - 1) .. " player(s) online:")
    for i, str in ipairs(strings) do
        if(str:sub(str:len()) ~= ",") then
            str = str .. "."
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
    end

    return true
end




@Xikini show that error on console: my use TFS 0.4 8.60

C++:
[20/04/2023 21:28:24] [Error - TalkAction Interface]
[20/04/2023 21:28:24] data/talkactions/scripts/online1.lua:onSay
[20/04/2023 21:28:24] Description:
[20/04/2023 21:28:24] data/talkactions/scripts/online1.lua:2: attempt to index local 'player' (a number value)
[20/04/2023 21:28:24] stack traceback:
[20/04/2023 21:28:24]     data/talkactions/scripts/online1.lua:2: in function <data/talkactions/scripts/online1.lua:1>
 
Last edited:
change
Lua:
strings[position] = strings[position] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
to
Lua:
strings[position] = strings[position] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "][" .. getVocationInfo(getPlayerVocation(pid)).name .. "][" .. getCreatureStorage(pid, 54676) .. "]"
 
Solution
Back
Top