• 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 /promote and /demote command for TFS1.5

Atxsu

New Member
Joined
Jun 30, 2022
Messages
11
Reaction score
4
GitHub
sl1ghtly
Hi again! I need a command for /promote <playername> and /demote <playername> where their group id goes up or down.

I tried messing around with some of the lua code from /promote /demote (https://otland.net/threads/promote-demote.195857/) but it didn't seem to work(I changed getPlayerByNameWildcard() to getPlayerByName() because there was an error on line 11, but then another one shows up at line 33)

This is the code I have at the moment:

Lua:
local config = {
    broadcast = true
}

function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return true
    end

    local pid = getPlayerByName(param)
    if(not pid) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " not found.")
        return true
    end

    if(getPlayerAccess(pid) >= getPlayerAccess(cid)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot perform action.")
        return true
    end

    local g = 1
    if(words:sub(2, 2) == "d") then
        g = -1
    end

    local newId = getPlayerGroupId(pid) + g
    if(newId <= 0 or not setPlayerGroupId(pid, newId)) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot perform action.")
        return true
    end

    local str = "been " .. (g == 1 and "promoted" or "demoted") .. " to " .. getGroupInfo(newId).name .. "."
    if(not config.broadcast) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param .. " has " .. str)
    else
        doBroadcastMessage(param .. " has " .. str, MESSAGE_EVENT_ADVANCE)
    end

    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You have " .. str)
    return true
end

Any help would be kindly appreciated!

JFC: I am using Nekiro's TFS 1.5 downgrade to 8.6.
 

Attachments

  • Tibia_190Ovc7nhw.png
    Tibia_190Ovc7nhw.png
    19.2 KB · Views: 8 · VirusTotal
Check this
Lua:
function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendCancel(cid, 'Prosze wpisac imie gracza.')
        return true
    end

    local playername = string.lower(param)
    local targetPlayer = getPlayerByNameWildcard(playername)
  
    if(targetPlayer == 0) then
        doPlayerSendCancel(cid, 'Nie znaleziono takiego gracza.')
        return true
    end

    local groupid = getPlayerGroupId(targetPlayer)
    local newgroupid = groupid + 1
  
    if(newgroupid > getHighestGroupId()) then
        doPlayerSendCancel(cid, 'Nie mozna promowac gracza wyzej.')
        return true
    end
  
    setPlayerGroupId(targetPlayer, newgroupid)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Gracz ' .. getPlayerName(targetPlayer) .. ' zostal promowany do rangi ' .. getGroupNameByGroupId(newgroupid) .. '.')
    doPlayerSendTextMessage(targetPlayer, MESSAGE_INFO_DESCR, 'Zostales promowany do rangi ' .. getGroupNameByGroupId(newgroupid) .. ' przez ' .. getPlayerName(cid) .. '.')
    return true
end
/Promote name
 
Just for those using TFS 1.5 I'll link the answer I gave to OP in my thread:
 
Back
Top