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

TalkAction Add Items Depot from player [Online/Offline]

Critico

Sexy
Joined
Mar 25, 2010
Messages
370
Reaction score
176
Description: is a command to send items directly to the depot of the player, even though he is online or offline!

Tested: in Sqlite version, do not know if it supports version Mysql / Sql

additemdepot.lua
Lua:
function doPlayerAddDepotItems(pid, item, count) --By magus and edited by vodkart
    local item,count = {item},{(count or 1)}
    for k,v in ipairs(item) do
        local ls = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..pid.." ORDER BY `sid` DESC LIMIT 1")
        return db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ("..pid..", "..(ls:getDataInt("sid")+1)..", 101, "..v..", "..count[k]..", '')") or false
    end
end

function onSay(cid, words, param)
    local t = string.explode(param:lower(),",")
    if not t[1] then doPlayerSendCancel(cid, "digite Nome, Item ID, quantidade.")
        return true
    elseif not getPlayerByNameWildcard(t[1]) and not getPlayerGUIDByName(t[1]) then
        doPlayerSendCancel(cid, "Você deve digitar um Nome Válido.")
        return true
    elseif not tonumber(t[2]) or not tonumber(t[3]) or tonumber(t[3]) < 1 or tonumber(t[3]) > 999 or not isItemStackable(t[2]) and tonumber(t[3]) > 10 then
        doPlayerSendCancel(cid, "você deve digitar NOME,ID,QUANTIDADE(maior que 0"..(not isItemStackable(t[2]) and " até 10 se não for empilhavel." or " até 1000 se for empilhavel.")..").")
        return true
    elseif not isItemMovable(t[2]) or not getItemNameById(tonumber(t[2])) then
        doPlayerSendCancel(cid, "Este item não existe ou não pode ser adicionado ao jogador.")
        return true
    end
    local player = getPlayerByNameWildcard(t[1])
    if player then
        parcel = doCreateItemEx(ITEM_PARCEL)
        if isItemStackable(t[2]) or tonumber(t[3]) == 1 then
            doAddContainerItem(parcel, t[2], t[3])
        else
            for i = 1, t[3] do
                doAddContainerItem(parcel, t[2], 1)
            end
        end
        doPlayerSendMailByName(getPlayerNameByGUID(getPlayerGUIDByName(t[1])), parcel, 1)
    else
        local getPlayer = getPlayerGUIDByName(t[1])
        if isItemStackable(t[2]) or tonumber(t[3]) == 1 then
            doPlayerAddDepotItems(getPlayer, t[2], t[3])
        else
            for i = 1, t[3] do
            doPlayerAddDepotItems(getPlayer, t[2], 1)
            end
        end
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"você adicionou "..t[3].." "..getItemNameById(t[2]).." ao depot do jogador "..t[1])
    return true
end

Tag
Code:
<talkaction log="yes" access="5" words="/adddepot" event="script" value="additemdepot.lua"/>


Exemple:

/adddepot vodkart,2160,500

or

/adddepot vodkart,2494,6
 
Last edited:
Looks great! I'm going to test it on TFS 1.0 later.
Edit: dafuq? 1.0 doesn't read string.explode, lol

Here is translated version:
Lua:
function doPlayerAddDepotItems(pid, item, count) --By magus and edited by vodkart
local item,count = {item},{(count or 1)}
    for k,v in ipairs(item) do
    local ls = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..pid.." ORDER BY `sid` DESC LIMIT 1")
    return db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ("..pid..", "..(ls:getDataInt("sid")+1)..", 101, "..v..", "..count[k]..", '')") or false
    end
end
function onSay(cid, words, param)
local t = string.explode(param:lower(),",")
if not t[1] then doPlayerSendCancel(cid, "Please insert player name, itemid and amount.") return true
elseif not getPlayerByNameWildcard(t[1]) and not getPlayerGUIDByName(t[1]) then doPlayerSendCancel(cid, "Please insert valid player name.") return true 
elseif not tonumber(t[2]) or not tonumber(t[3]) or tonumber(t[3]) < 1 or tonumber(t[3]) > 999 or not isItemStackable(t[2]) and tonumber(t[3]) > 10 then doPlayerSendCancel(cid, "Please insert valid player name, itemid and amount(higher than 0,"..(not isItemStackable(t[2]) and " up to 10 if item doesn't stack." or " up to 1000, if item is stackable.")..").") return true
elseif not isItemMovable(t[2]) or not getItemNameById(tonumber(t[2])) then  doPlayerSendCancel(cid, "This item doesn't exist or couldn't be added.") return true
end
local player = getPlayerByNameWildcard(t[1])
if player then
local parcel = doCreateItemEx(ITEM_PARCEL)
if isItemStackable(t[2]) or tonumber(t[3]) == 1 then
doAddContainerItem(parcel, t[2], t[3])
else
for i = 1, t[3] do
doAddContainerItem(parcel, t[2], 1)
end
end
doPlayerSendMailByName(getPlayerNameByGUID(getPlayerGUIDByName(t[1])), parcel, 1)
else
local getPlayer = getPlayerGUIDByName(t[1])
if isItemStackable(t[2]) or tonumber(t[3]) == 1 then
doPlayerAddDepotItems(getPlayer, t[2], t[3])
else
for i = 1, t[3] do
doPlayerAddDepotItems(getPlayer, t[2], 1)
end
end
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"you added "..t[3].." "..getItemNameById(t[2]).." to "..t[1].."'s depot.")
return true
end
 
Last edited:
In my server it works only while receiver is offline. Any ideas why?
 
Looks great! I'm going to test it on TFS 1.0 later.
Edit: dafuq? 1.0 doesn't read string.explode, lol

Here is translated version:
Lua:
function doPlayerAddDepotItems(pid, item, count) --By magus and edited by vodkart
local item,count = {item},{(count or 1)}
    for k,v in ipairs(item) do
    local ls = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..pid.." ORDER BY `sid` DESC LIMIT 1")
    return db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ("..pid..", "..(ls:getDataInt("sid")+1)..", 101, "..v..", "..count[k]..", '')") or false
    end
end
function onSay(cid, words, param)
local t = string.explode(param:lower(),",")
if not t[1] then doPlayerSendCancel(cid, "Please insert player name, itemid and amount.") return true
elseif not getPlayerByNameWildcard(t[1]) and not getPlayerGUIDByName(t[1]) then doPlayerSendCancel(cid, "Please insert valid player name.") return true
elseif not tonumber(t[2]) or not tonumber(t[3]) or tonumber(t[3]) < 1 or tonumber(t[3]) > 999 or not isItemStackable(t[2]) and tonumber(t[3]) > 10 then doPlayerSendCancel(cid, "Please insert valid player name, itemid and amount(higher than 0,"..(not isItemStackable(t[2]) and " up to 10 if item doesn't stack." or " up to 1000, if item is stackable.")..").") return true
elseif not isItemMovable(t[2]) or not getItemNameById(tonumber(t[2])) then  doPlayerSendCancel(cid, "This item doesn't exist or couldn't be added.") return true
end
local player = getPlayerByNameWildcard(t[1])
if player then
local parcel = doCreateItemEx(ITEM_PARCEL)
if isItemStackable(t[2]) or tonumber(t[3]) == 1 then
doAddContainerItem(parcel, t[2], t[3])
else
for i = 1, t[3] do
doAddContainerItem(parcel, t[2], 1)
end
end
doPlayerSendMailByName(getPlayerNameByGUID(getPlayerGUIDByName(t[1])), parcel, 1)
else
local getPlayer = getPlayerGUIDByName(t[1])
if isItemStackable(t[2]) or tonumber(t[3]) == 1 then
doPlayerAddDepotItems(getPlayer, t[2], t[3])
else
for i = 1, t[3] do
doPlayerAddDepotItems(getPlayer, t[2], 1)
end
end
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"you added "..t[3].." "..getItemNameById(t[2]).." to "..t[1].."'s depot.")
return true
end

Did you get it work for TFS 1.0/1.1? @zbizu
 
Description: is a command to send items directly to the depot of the player, even though he is online or offline!

Tested: in Sqlite version, do not know if it supports version Mysql / Sql

additemdepot.lua
Lua:
function doPlayerAddDepotItems(pid, item, count) --By magus and edited by vodkart
    local item,count = {item},{(count or 1)}
    for k,v in ipairs(item) do
        local ls = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..pid.." ORDER BY `sid` DESC LIMIT 1")
        return db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ("..pid..", "..(ls:getDataInt("sid")+1)..", 101, "..v..", "..count[k]..", '')") or false
    end
end

function onSay(cid, words, param)
    local t = string.explode(param:lower(),",")
    if not t[1] then doPlayerSendCancel(cid, "digite Nome, Item ID, quantidade.")
        return true
    elseif not getPlayerByNameWildcard(t[1]) and not getPlayerGUIDByName(t[1]) then
        doPlayerSendCancel(cid, "Você deve digitar um Nome Válido.")
        return true
    elseif not tonumber(t[2]) or not tonumber(t[3]) or tonumber(t[3]) < 1 or tonumber(t[3]) > 999 or not isItemStackable(t[2]) and tonumber(t[3]) > 10 then
        doPlayerSendCancel(cid, "você deve digitar NOME,ID,QUANTIDADE(maior que 0"..(not isItemStackable(t[2]) and " até 10 se não for empilhavel." or " até 1000 se for empilhavel.")..").")
        return true
    elseif not isItemMovable(t[2]) or not getItemNameById(tonumber(t[2])) then
        doPlayerSendCancel(cid, "Este item não existe ou não pode ser adicionado ao jogador.")
        return true
    end
    local player = getPlayerByNameWildcard(t[1])
    if player then
        parcel = doCreateItemEx(ITEM_PARCEL)
        if isItemStackable(t[2]) or tonumber(t[3]) == 1 then
            doAddContainerItem(parcel, t[2], t[3])
        else
            for i = 1, t[3] do
                doAddContainerItem(parcel, t[2], 1)
            end
        end
        doPlayerSendMailByName(getPlayerNameByGUID(getPlayerGUIDByName(t[1])), parcel, 1)
    else
        local getPlayer = getPlayerGUIDByName(t[1])
        if isItemStackable(t[2]) or tonumber(t[3]) == 1 then
            doPlayerAddDepotItems(getPlayer, t[2], t[3])
        else
            for i = 1, t[3] do
            doPlayerAddDepotItems(getPlayer, t[2], 1)
            end
        end
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"você adicionou "..t[3].." "..getItemNameById(t[2]).." ao depot do jogador "..t[1])
    return true
end

Tag
Code:
<talkaction log="yes" access="5" words="/adddepot" event="script" value="additemdepot.lua"/>


Exemple:

/adddepot vodkart,2160,500

or

/adddepot vodkart,2494,6
Can someone adjust this for send to all players? Without need to put a name, when i choose "/adddepot" send to all existing players.
 
Can someone adjust this for send to all players? Without need to put a name, when i choose "/adddepot" send to all existing players.

Try change this:

Lua:
 db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..pid.." ORDER BY `sid` DESC LIMIT 1")

To:

Lua:
 db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` > 0" ORDER BY `sid` DESC LIMIT 1")
 
Back
Top