• 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!

TFS 1.X+ Missing name for a globalevent

MaR0

Banned User
Joined
Apr 16, 2018
Messages
272
Solutions
3
Reaction score
29
Hello i'm trying to add this script to my server it's globalevent with think type "lottery system"
while i try to launch my server this error comes.. i'm using tfs 1.2 ninja sources 8.00
Code:
[Error - GlobalEvent::configureEvent] Missing name for a globalevent
[Warning - BaseEvents::loadFromXml] Failed to configure event
here is the script
Lua:
local rewards = {
   {itemid = 2160, count = 100},
    {itemid = 24774, count = 5}
}

function onThink(interval, lastExecution)
    local players = Game.getPlayers()
    if #players > 0 then
        while true do
            local player = players[math.random(#players)]
            if not player:hasAccess() and player:getAccountType() == ACCOUNT_TYPE_NORMAL then
                local reward = rewards[#rewards]
                local item = player:addItem(reward.itemid, math.random(reward.count))
                local itemName = item:getCount() > 1 and item:getPluralName() or item:getName()
                Game.broadcastMessage(('[LOTTERY] %s has won %d %s, next lottery in 30 minutes'):format(player:getName(), item:getCount(), itemName), MESSAGE_STATUS_CONSOLE_ORANGE)
                break
            end
        end
    end
    return true
end
XML:
   <globalevent type="think" interval="3500000" script="lottery.lua"/>
 
bummpppppppppppppppppppppp
Code:
local itemName = reward.count > 1 and item:getPluralName() or item:getName()
This line is the problem.
getPluralName()

Most singular items that are not stackable, such as bags, don't have a plural name by default.

I actually don't understand why you'd want to tell people you got 8 bags of items though.. as you'd normally want to tell them the reward they are receiving, not the item that the reward is being held in.

In either case, for any items that are in your rewards, and the bag, you'd want to add their plural name into items.xml

Alternatively, you could add the plural names into your table and call them manually, but that would probably be annoying.

secondary option, would be get rid of plural names altogether, but then your broadcasted message might not be fully correct.
Code:
local itemName = item:getName()
 
Back
Top