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
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")