• 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 [TFS 0.X] Talkaction that sends items to the Depot

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,397
Solutions
17
Reaction score
148
Location
Brazil
I need a talkaction that sends a certain item (my choice) to the DP of all players (online and offline). I've tested some but they have some bugs or don't work. can you help me?

Talkaction example:

/additem 2160,10

Add 10 crystal coins (id 2160) for all players.
 

Hey bro, I really don't know if that gonna work, but you can give a try and test/change the code to see.
That script sends a parcel to player

/sparcel PLAYERName, ITEMID OR NAME, AMOUNT OR NOT

XML:
<talkaction log="yes" group="4" access="3" words="/sparcel" event="script" value="sendItem.lua"/>

Lua:
local DefaultTownId = 1 -- town id that sends the parcel

function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return true
    end

    local t = string.explode(param, ",")
    if(not t[2]) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough params.")
        return true
    end

    local pid = getPlayerByNameWildcard(t[1]) -- check player name
    if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
        return true
    end

    local id = tonumber(t[2]) -- check item id or name
    if(not id) then
        errors(false)
        id = getItemIdByName(t[2])
        errors(true)

        if(not id) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item with such name does not exists.")
            return true
        end
    end

    local amount = tonumber(t[3]) -- check if has amount or not
    if(not amount or amount == 0) then
        amount = 1
    end

    local parcel = doCreateItemEx(2595) -- make a parcel
    local letter = doAddContainerItem(received, 2598, 1) -- make a letter inside parcel
    doSetItemText(letter, "TEXT OF LETTER HERE", "NAME", os.time()) -- DISPLAY TEXT, NAME WHO SEND OR ANOTHER NAME AND HOUR SEND
    doAddContainerItem(parcel, id, amount)
    doPlayerSendMailByName(getPlayerNameByGUID(pid), parcel, DefaultTownId)
    return true
end
 
Hey bro, I really don't know if that gonna work, but you can give a try and test/change the code to see.
That script sends a parcel to player

/sparcel PLAYERName, ITEMID OR NAME, AMOUNT OR NOT

XML:
<talkaction log="yes" group="4" access="3" words="/sparcel" event="script" value="sendItem.lua"/>

Lua:
local DefaultTownId = 1 -- town id that sends the parcel

function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return true
    end

    local t = string.explode(param, ",")
    if(not t[2]) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough params.")
        return true
    end

    local pid = getPlayerByNameWildcard(t[1]) -- check player name
    if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
        return true
    end

    local id = tonumber(t[2]) -- check item id or name
    if(not id) then
        errors(false)
        id = getItemIdByName(t[2])
        errors(true)

        if(not id) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item with such name does not exists.")
            return true
        end
    end

    local amount = tonumber(t[3]) -- check if has amount or not
    if(not amount or amount == 0) then
        amount = 1
    end

    local parcel = doCreateItemEx(2595) -- make a parcel
    local letter = doAddContainerItem(received, 2598, 1) -- make a letter inside parcel
    doSetItemText(letter, "TEXT OF LETTER HERE", "NAME", os.time()) -- DISPLAY TEXT, NAME WHO SEND OR ANOTHER NAME AND HOUR SEND
    doAddContainerItem(parcel, id, amount)
    doPlayerSendMailByName(getPlayerNameByGUID(pid), parcel, DefaultTownId)
    return true
end
I need one who send to all players, its.possible?
 
Back
Top