• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

RevScripts what's wrong? script not being initialized

ForgottenNot

Banned User
Joined
Feb 10, 2023
Messages
303
Reaction score
29
Hi

i've made an script added some prints to check things but im not having any prints i use latest canary server

LUA:
local STORAGEVALUE_LOOT = 12345

local lootChannel = CreatureEvent("onLootChannel")
lootChannel:type("login")
lootChannel:register(function(player)
    print("Login event triggered for player: " .. player:getName())
    local storageValue = player:getStorageValue(STORAGEVALUE_LOOT)
    print("Storage value for " .. player:getName() .. ": " .. storageValue)
    
    if storageValue == -1 then  -- If storage value is not set
        player:setStorageValue(STORAGEVALUE_LOOT, 12345)
        print("Set storage value for " .. player:getName() .. " to 12345")
    end
    
    if storageValue == 12345 then
        local channel = Game.getChannelById(13)
        if channel then
            player:openChannel(13)
            print("Channel 13 opened for " .. player:getName())
        else
            print("Channel 13 does not exist")
        end
    else
        print("Storage value not set to 12345 for " .. player:getName())
    end
    return true
end)

local lootChannelLeave = CreatureEvent("onLootChannelLeave")
lootChannelLeave:type("logout")
lootChannelLeave:register(function(player)
    print("Logout event triggered for player: " .. player:getName())
    if player:getStorageValue(STORAGEVALUE_LOOT) == 12345 then
        player:closeChannel(13)
        print("Channel 13 closed for " .. player:getName())
    end
    return true
end)

-- Register the events
lootChannel:register()
lootChannelLeave:register()

-- Function to manually open the channel (for testing purposes)
function openLootChannelManually(playerName)
    local player = Player(playerName)
    if player then
        player:openChannel(13)
        print("Manually opened channel 13 for " .. player:getName())
    else
        print("Player not found")
    end
end

-- You can call this function from the console or another script for testing
-- Example: openLootChannelManually("YourPlayerName")
 
To help you with debugging and ensuring your script works correctly on the latest Canary server, let's go through your script step by step and ensure everything is set up properly. Below are the steps to debug and test your script effectively:

  1. Verify Script Loading:Ensure that your script is being loaded by the server. Add a print statement at the top of your script to verify this.
  2. Register Events Correctly:Ensure that your events are registered correctly and the event handling is set up properly.
  3. Check for Console Output:Ensure that you are looking at the correct console or log files where the server prints its output.
Here’s your script with added comments and additional print statements for better debugging:

LUA:
local STORAGEVALUE_LOOT = 12345

-- Create the lootChannel event
local lootChannel = CreatureEvent("onLootChannel")
lootChannel:type("login")
lootChannel:register(function(player)
    print("Login event triggered for player: " .. player:getName())
    
    local storageValue = player:getStorageValue(STORAGEVALUE_LOOT)
    print("Storage value for " .. player:getName() .. ": " .. storageValue)
    
    if storageValue == -1 then  -- If storage value is not set
        player:setStorageValue(STORAGEVALUE_LOOT, 12345)
        print("Set storage value for " .. player:getName() .. " to 12345")
    end
    
    if storageValue == 12345 then
        local channel = Game.getChannelById(13)
        if channel then
            player:openChannel(13)
            print("Channel 13 opened for " .. player:getName())
        else
            print("Channel 13 does not exist")
        end
    else
        print("Storage value not set to 12345 for " .. player:getName())
    end
    return true
end)

-- Create the lootChannelLeave event
local lootChannelLeave = CreatureEvent("onLootChannelLeave")
lootChannelLeave:type("logout")
lootChannelLeave:register(function(player)
    print("Logout event triggered for player: " .. player:getName())
    if player:getStorageValue(STORAGEVALUE_LOOT) == 12345 then
        player:closeChannel(13)
        print("Channel 13 closed for " .. player:getName())
    end
    return true
end)

-- Register the events
lootChannel:register()
lootChannelLeave:register()

-- Function to manually open the channel (for testing purposes)
function openLootChannelManually(playerName)
    local player = Player(playerName)
    if player then
        player:openChannel(13)
        print("Manually opened channel 13 for " .. player:getName())
    else
        print("Player not found")
    end
end

-- Print statement to confirm script is loaded
print("Loot channel script loaded")
 
use latest canary server
I've checked canary events and they all look like this:
login:
LUA:
local freeQuests = CreatureEvent("FreeQuests")

function freeQuests.onLogin(player)

    return true
end

freeQuests:register()
logout:
LUA:
local playerLogout = CreatureEvent("HERE_NAME_OF_EVENT")

function playerLogout.onLogout(player)

    return true
end

playerLogout:register()
There is a variable assigned with event object with event name ex. local freeQuests = CreatureEvent("FreeQuests").
Then there is a function defined with name of given event callback ex. function freeQuests.onLogin(player)
and then an event is registered ex. freeQuests:register().

and your events look like this:
LUA:
local lootChannelLeave = CreatureEvent("onLootChannelLeave")
lootChannelLeave:type("logout") -- WHAT IS THAT?
lootChannelLeave:register(function(player) -- WHY CALL "register" once with a function as parameter

    return true
end)
lootChannelLeave:register() -- AND THEN second time with no parameter
IDK if it's valid event format.

Your script converted to event format like in other canary scripts:
LUA:
local STORAGEVALUE_LOOT = 12345

local lootChannel = CreatureEvent("onLootChannel")
function lootChannel.onLogin(player)
    print("Login event triggered for player: " .. player:getName())
    local storageValue = player:getStorageValue(STORAGEVALUE_LOOT)
    print("Storage value for " .. player:getName() .. ": " .. storageValue)
   
    if storageValue == -1 then  -- If storage value is not set
        player:setStorageValue(STORAGEVALUE_LOOT, 12345)
        print("Set storage value for " .. player:getName() .. " to 12345")
    end
   
    if storageValue == 12345 then
        local channel = Game.getChannelById(13)
        if channel then
            player:openChannel(13)
            print("Channel 13 opened for " .. player:getName())
        else
            print("Channel 13 does not exist")
        end
    else
        print("Storage value not set to 12345 for " .. player:getName())
    end
    return true
end

local lootChannelLeave = CreatureEvent("onLootChannelLeave")
function lootChannelLeave.onLogout(player)
    print("Logout event triggered for player: " .. player:getName())
    if player:getStorageValue(STORAGEVALUE_LOOT) == 12345 then
        player:closeChannel(13)
        print("Channel 13 closed for " .. player:getName())
    end
    return true
end

-- Register the events
lootChannel:register()
lootChannelLeave:register()

-- Function to manually open the channel (for testing purposes)
function openLootChannelManually(playerName)
    local player = Player(playerName)
    if player then
        player:openChannel(13)
        print("Manually opened channel 13 for " .. player:getName())
    else
        print("Player not found")
    end
end

-- You can call this function from the console or another script for testing
-- Example: openLootChannelManually("YourPlayerName")
 
sti
I've checked canary events and they all look like this:
login:
LUA:
local freeQuests = CreatureEvent("FreeQuests")

function freeQuests.onLogin(player)

    return true
end

freeQuests:register()
logout:
LUA:
local playerLogout = CreatureEvent("HERE_NAME_OF_EVENT")

function playerLogout.onLogout(player)

    return true
end

playerLogout:register()
There is a variable assigned with event object with event name ex. local freeQuests = CreatureEvent("FreeQuests").
Then there is a function defined with name of given event callback ex. function freeQuests.onLogin(player)
and then an event is registered ex. freeQuests:register().

and your events look like this:
LUA:
local lootChannelLeave = CreatureEvent("onLootChannelLeave")
lootChannelLeave:type("logout") -- WHAT IS THAT?
lootChannelLeave:register(function(player) -- WHY CALL "register" once with a function as parameter

    return true
end)
lootChannelLeave:register() -- AND THEN second time with no parameter
IDK if it's valid event format.

Your script converted to event format like in other canary scripts:
LUA:
local STORAGEVALUE_LOOT = 12345

local lootChannel = CreatureEvent("onLootChannel")
function lootChannel.onLogin(player)
    print("Login event triggered for player: " .. player:getName())
    local storageValue = player:getStorageValue(STORAGEVALUE_LOOT)
    print("Storage value for " .. player:getName() .. ": " .. storageValue)
  
    if storageValue == -1 then  -- If storage value is not set
        player:setStorageValue(STORAGEVALUE_LOOT, 12345)
        print("Set storage value for " .. player:getName() .. " to 12345")
    end
  
    if storageValue == 12345 then
        local channel = Game.getChannelById(13)
        if channel then
            player:openChannel(13)
            print("Channel 13 opened for " .. player:getName())
        else
            print("Channel 13 does not exist")
        end
    else
        print("Storage value not set to 12345 for " .. player:getName())
    end
    return true
end

local lootChannelLeave = CreatureEvent("onLootChannelLeave")
function lootChannelLeave.onLogout(player)
    print("Logout event triggered for player: " .. player:getName())
    if player:getStorageValue(STORAGEVALUE_LOOT) == 12345 then
        player:closeChannel(13)
        print("Channel 13 closed for " .. player:getName())
    end
    return true
end

-- Register the events
lootChannel:register()
lootChannelLeave:register()

-- Function to manually open the channel (for testing purposes)
function openLootChannelManually(playerName)
    local player = Player(playerName)
    if player then
        player:openChannel(13)
        print("Manually opened channel 13 for " .. player:getName())
    else
        print("Player not found")
    end
end

-- You can call this function from the console or another script for testing
-- Example: openLootChannelManually("YourPlayerName")
ll not opening the channel on log in :/
Can you check if your script file have ".lua" extension?
yes it does i use win 11
 
Back
Top