TFS 1.X+ admin giving a gift to all the active players by Command

abdala ragab

Advanced OT User
Joined
Aug 18, 2018
Messages
240
Solutions
7
Reaction score
233
when i was playing tibia 860 The admin was giving a gift to all the active players
Do you know this commanda
How is it added?
Thanks in advance
 

Alpha

Relentless
Premium User
Joined
Apr 3, 2011
Messages
703
Solutions
37
Reaction score
518
Location
South Korea
Lua:
local giftId = 1234
for _, onlinePlayer in pairs(Game.getPlayers()) do
    local gift = Game.createItem(giftId, 1)
    local message = ("You have received %s."):format(gift:getNameDescription(gift:getSubType(), true))
    if not onlinePlayer:addItemEx(gift, false) then
        onlinePlayer:getInbox():addItemEx(gift, FLAG_NOLIMIT)
        message = ("%s It has been sent to your inbox because it couldn't be carried."):format(message)
    end

    onlinePlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
end
 
Last edited:
OP
OP
abdala ragab

abdala ragab

Advanced OT User
Joined
Aug 18, 2018
Messages
240
Solutions
7
Reaction score
233
Lua:
local giftId = 1234
for _, onlinePlayer in pairs(Game.getPlayers()) do
    local gift = Game.createItem(giftId, 1)
    local message = ("You have received %s."):format(gift:getNameDescription(gift:getSubType(), true))
    if not onlinePlayer:addItemEx(gift, false) then
        onlinePlayer:getInbox():addItemEx(gift, FLAG_NOLIMIT)
        message = ("%s It has been sent to your inbox because it couldn't be carried."):format(message)
    end

    onlinePlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
end
Please give me the steps to do it
What commands are used to do that
Thanks for the help, I wish you good luck
 
OP
OP
abdala ragab

abdala ragab

Advanced OT User
Joined
Aug 18, 2018
Messages
240
Solutions
7
Reaction score
233
Lua:
local giftId = 1234
for _, onlinePlayer in pairs(Game.getPlayers()) do
    local gift = Game.createItem(giftId, 1)
    local message = ("You have received %s."):format(gift:getNameDescription(gift:getSubType(), true))
    if not onlinePlayer:addItemEx(gift, false) then
        onlinePlayer:getInbox():addItemEx(gift, FLAG_NOLIMIT)
        message = ("%s It has been sent to your inbox because it couldn't be carried."):format(message)
    end

    onlinePlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
end

Lua Script Error: [Test Interface]
data/talkactions/scripts/Admin.lua
data/talkactions/scripts/Admin.lua:4: attempt to call method 'getNameDescription' (a nil value)
stack traceback:
[C]: in function 'getNameDescription'
data/talkactions/scripts/Admin.lua:4: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/Admin.lua
 

dewral

Intermediate OT User
Joined
Dec 4, 2019
Messages
211
Solutions
9
Reaction score
109
What engine you're using? Because i have no problems with this on tfs 1.5

Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end
    local giftId = 5092
    for _, onlinePlayer in pairs(Game.getPlayers()) do
    local gift = Game.createItem(giftId, 1)
    local message = ("You have received %s."):format(gift:getNameDescription(gift:getSubType(), true))
    if not onlinePlayer:addItemEx(gift, false) then
        onlinePlayer:getDepotChest(1, true):addItemEx(gift, FLAG_NOLIMIT)
        message = ("%s It has been sent to your inbox because it couldn't be carried."):format(message)
    end
        onlinePlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
    end
end
 
OP
OP
abdala ragab

abdala ragab

Advanced OT User
Joined
Aug 18, 2018
Messages
240
Solutions
7
Reaction score
233
What engine you're using? Because i have no problems with this on tfs 1.5

Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end
    local giftId = 5092
    for _, onlinePlayer in pairs(Game.getPlayers()) do
    local gift = Game.createItem(giftId, 1)
    local message = ("You have received %s."):format(gift:getNameDescription(gift:getSubType(), true))
    if not onlinePlayer:addItemEx(gift, false) then
        onlinePlayer:getDepotChest(1, true):addItemEx(gift, FLAG_NOLIMIT)
        message = ("%s It has been sent to your inbox because it couldn't be carried."):format(message)
    end
        onlinePlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
    end
end
tfs 1.2 Tell me in detail where to add it?
What command should I use for this as well?
 

dewral

Intermediate OT User
Joined
Dec 4, 2019
Messages
211
Solutions
9
Reaction score
109
data/talkactions/scripts create file gift.lua and paste the script
open talkactions.xml and put something like this on admin commands
Lua:
    <talkaction words="/gift" script="gift.lua" />
 
Top