• 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 0.4. doPlayerSendItemToDepot?

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,759
Solutions
127
Reaction score
2,279
How do I add item to player depot?

I'm using tfs 0.4. I searched for functions and found only one
getPlayerDepotItems(cid, depotid)
but its kinda useless here.
 
Solution
Code:
local sellername = db.getResult("SELECT `player` FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. "")
-- ^ assuming its his player_id
local sellercid = getPlayerByGUID(sellername)
if sellercid then
-- he is online do stuff with sellercid
else
-- he is offline do stuff with queries
end
You could send them mail instead?
Code:
doPlayerSendMailByName(name, item[, town[, actor]])
-- Untested
Code:
local name = getCreatureName(cid)
local item = 1987 -- No way to alter amount of items? (1987 I think is a bag?) didn't check :P
local town = getPlayerTown(cid)

local bag = doPlayerSendMailByName(name, item, town)
doAddContainerItem(bag, 2148, 69) -- this is mostly a test.. I'm just assuming you can do it
doAddContainerItem(bag, 2148, 13)
 
You could send them mail instead?
Code:
doPlayerSendMailByName(name, item[, town[, actor]])
-- Untested
Code:
local name = getCreatureName(cid)
local item = 1987 -- No way to alter amount of items? (1987 I think is a bag?) didn't check :P
local town = getPlayerTown(cid)

local bag = doPlayerSendMailByName(name, item, town)
doAddContainerItem(bag, 2148, 69) -- this is mostly a test.. I'm just assuming you can do it
doAddContainerItem(bag, 2148, 13)
You cant use it like this the returned value is a boolean, but the function is "item" not "itemid" so it takes an uid and you could just create an container with doCreateItemEx, add a bunch of stuff inside and send it.

Actually you can only send virtual items so yea you would need to use doCreateItemEx anyway.

Code:
    if(item->getParent() != VirtualCylinder::virtualCylinder)
    {
        lua_pushboolean(L, false);
        return 1;
    }
 
Thank you, didntk now about send mail function :D

One more question. What is cid?
in function: doPlayerAddMoney(cid, 99)

Cause im trying to give money to other player than cid I mean

Code:
local sellername = db.getResult("SELECT `player` FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. "")

doPlayerSendTextMessage(sellername, MESSAGE_INFO_DESCR, "You got ...")
doPlayerAddMoney(sellername, 35)

And selected "player" is player_id
 
Thank you, didntk now about send mail function :D

One more question. What is cid?
in function: doPlayerAddMoney(cid, 99)

Cause im trying to give money to other player than cid I mean

Code:
local sellername = db.getResult("SELECT `player` FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. "")

doPlayerSendTextMessage(sellername, MESSAGE_INFO_DESCR, "You got ...")
doPlayerAddMoney(sellername, 35)

And selected "player" is player_id
You have to check if the player is online, if its online you get its cid with getPlayerByGUID and use doPlayerAddMoney, if he is offline you have to use another query to increment the balance of that player's id.
 
You have to check if the player is online, if its online you get its cid with getPlayerByGUID and use doPlayerAddMoney, if he is offline you have to use another query to increment the balance of that player's id.

Can you please show me ?

if he is offline I understand. How to check if its online? and how to get his cid?
 
Code:
local sellername = db.getResult("SELECT `player` FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. "")
-- ^ assuming its his player_id
local sellercid = getPlayerByGUID(sellername)
if sellercid then
-- he is online do stuff with sellercid
else
-- he is offline do stuff with queries
end
 
Solution
Now all is working great! Thank you!

Last question, its any method to make message appear when player login?
Its related to when its offline.

Something like: Welcome, during your absence you sold...
 
Now all is working great! Thank you!

Last question, its any method to make message appear when player login?
Its related to when its offline.

Something like: Welcome, during your absence you sold...
Well you would need to keep track of the transactions so you would need another table in your database to store the information like who bought when etc and obviously the playerid that sold the item, then you would check on every onLogin if in that table if you can find any transaction log with that playerid and if there is you can either remove it if you don't wanna keep it stored or you can have a field like boolean "seen" set it to false as default and when the player logins set it to true to not send it again.
 
Its too much work I guess. I will stay with how it is now.

Thank you for help :)
 
I have one more question. Im creating item list:
But when I have more than 1 item in database it shows only 1. How to show all of them?

Error: attempt to concatenate local (a table value)
Code:
if(t[1] == "list") then
local itemlist = db.getResult("SELECT * FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
if itemlist > 0 then --< also I dont know how to check if > 0 then do
doPlayerPopupFYI(cid, 'Your active offers:\n ID: NAME:\n '.. itemlist:getDataInt("id") ..' '.. itemlist:getDataString("item_name") ..'\n')
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not selling anything.")
end
end
 
Last edited:
Error: attempt to concatenace local (a table value)
wRxhLfm.png
 
Back
Top