• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Improved !online

Erexo

Kage
Premium User
Joined
Mar 27, 2010
Messages
742
Solutions
5
Reaction score
198
Location
Pr0land
GitHub
Erexo
Hello,
Ive changed `!online` talkaction, that it now shows specific levels if you set param.
Ex:
If you write `!online 100`, script will only show online players with level 100 and above.
Its very useful if you want to check bots or something.

Code:
local config = {
    showGamemasters = getBooleanFromString(getConfigInfo('displayGamemastersWithOnlineCommand'))
}

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

    local i = 1
    local position = 1
    for _, pid in ipairs(players) do
        seal = true
        if param ~= "" then
            setPlayerStorageValue(cid, 30112, param)
            if getPlayerLevel(pid) < getPlayerStorageValue(cid, 30112) then
                seal = false
            end
        end
        if seal 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

            if((config.showGamemasters == TRUE or getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) == TRUE or getPlayerCustomFlagValue(pid, PlayerCustomFlag_GamemasterPrivileges) ~= TRUE) and (isPlayerGhost(pid) ~= TRUE or getPlayerAccess(cid) > getPlayerAccess(pid))) then
                strings[position] = strings[position] .. getCreatureName(pid) .. " [" .. getPlayerLevel(pid) .. "]"
                i = i + 1
            end
        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

I know it looks terrible, but I didnt had much time, and lua forgot about `continue` statement :S

Greetings.
 
Last edited:
it's nice of you to contribute this to OTland but I don't get why anyone will want to use it (no offence @ all) cus who will want to check online players by levels? -.-
 
Nice script, might even be more useful with level range like !online 120 140.

Some advice:
- You should always add the server version with so many floating around
- not sure why you used that storage value
- seal can be defined as local
- checking for == true is rarely needed
 
- not sure why you used that storage value
Becouse Ive got some strange errors when I want to put param intro variable (like param wasnt a string). idk why, and as I said I needed it fast, so here you are.

- seal can be defined as local
Can but dont have to ^^

- checking for == true is rarely needed
That part wasnt actually mine, it was from oryginal online script, i dont like that too.

I dont know if someone might need that, I found this useful, so I just want to share it with you guys.
 
Last edited:
Back
Top