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
Well you have "doPlayerSendMailByName".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.
doPlayerSendMailByName(name, item[, town[, actor]])
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.You could send them mail instead?
-- UntestedCode:doPlayerSendMailByName(name, item[, town[, actor]])
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)
if(item->getParent() != VirtualCylinder::virtualCylinder)
{
lua_pushboolean(L, false);
return 1;
}
local sellername = db.getResult("SELECT `player` FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. "")
doPlayerSendTextMessage(sellername, MESSAGE_INFO_DESCR, "You got ...")
doPlayerAddMoney(sellername, 35)
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.Thank you, didntk now about send mail function
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.
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
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.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...
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
Error: attempt to concatenace local (a table value)
How am I being rude?If you dont want to help, then go away.
go be rude elsewhere.