• 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 Loot channel only for premium players

skic

Member
Joined
Aug 15, 2020
Messages
58
Reaction score
13
Hello guys, I'm using TFS 1.2 and I want to make loot channel available only for premium players.

chatchannels.xml

Lua:
<?xml version="1.0" encoding="UTF-8"?>
<channels>
    <channel id="2" name="Tutor" script="tutor.lua" />
    <channel id="3" name="World Chat" public="1" script="worldchat.lua" />
    <channel id="7" name="Help" public="1" script="help.lua" />
    <channel id="8" name="Gamemaster" script="gamemaster.lua" />
    <channel id="9" name="Loot" public="1" script="loot.lua" />
</channels>

there is registerEvent("loot") in login.lua:
Code:
function onLogin(player)
    local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "! Say !buypremium to buy premmy days"
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. " Please choose your outfit."
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local playerId = player:getId()

    local time = 10 -- 10 seconds cooldown until they can logout
    setPlayerStorageValue(cid, 3333, os.time()+time)

    -- Stamina
    nextUseStaminaTime[player.uid] = 0


    -- STAMINA DEVIDO A QUEDAS START
 
    --local stamina_full = 42 * 60 -- config. 42 = horas
   -- if player:getStamina() >= stamina_full then
      --  player:sendCancelMessage("Your stamina is already full.")
   -- elseif player:getPremiumDays() < 1 then
     --   player:sendCancelMessage("You must have a premium account.")
   -- else
      --  player:setStamina(stamina_full)
     -- player:sendTextMessage(MESSAGE_INFO_DESCR, "Your stamina has been refilled.")    
   -- end
 
    -- STAMINA DEVIDO A QUEDAS END


    -- Promotion
    local vocation = player:getVocation()
    local promotion = vocation:getPromotion()
    if player:isPremium() then
        local value = player:getStorageValue(STORAGEVALUE_PROMOTION)
        if not promotion and value ~= 1 then
            player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
        elseif value == 1 then
            player:setVocation(promotion)
        end
    elseif not promotion then
        player:setVocation(vocation:getDemotion())
    end

    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!autoloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items"..'\n'.."!autoloot clear - clears your current auto loot items")

    -- Events
    player:registerEvent("pvpenfo")
    player:registerEvent("logoutdelay")
    player:registerEvent("PlayerDeath")
    player:registerEvent("DropLoot")
    player:registerEvent("SvargrondArenaKill")
    player:registerEvent("broadcast_deaths")
    player:registerEvent("loot")
    player:registerEvent("KillingInTheNameOf")
    return true
end

and here is loot.lua
Code:
function onLogin(cid)
local player = Player(cid)
    player:openChannel(9)
    return true
end

Is there a way to hide this loot channel for non-premium players somehow or to make that they can't open it?
I found a way that they can't receive loot message's if they are not premium but I'm curious is there a way to hide it.
 
Dear skic

Can you show me ur lua what you type that script ? I try to add below function but still can open channel,


Lua:
function canJoin(player)
    return player:isPremium()
end
 
Back
Top