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

doPlayerAddDepotItems(cid, items, town)

sn3ejk

This account is inactive.
Joined
Nov 16, 2011
Messages
2,121
Solutions
1
Reaction score
145
function
doPlayerAddDepotItems(cid, items, town)

____________________________________​


  • Lua:
    function doPlayerAddDepotItems(cid, items, town)
    	if (not isPlayer(cid)) then
    		error("Player not found")
    	end
    	local town = town or getPlayerTown(cid)
    	
    	local parcel = doCreateItemEx(ITEM_PARCEL)
    	for item, count in pairs(items) do
    		if (type(item) == "number") then
    			doAddContainerItem(parcel, item, count)
    		elseif (type(item) == "string") then
    			doAddContainerItem(parcel, getItemIdByName(item), count)
    		else
    			error("Undefinied type of item name")
    		end
    	end
    	
    	return doPlayerSendMailByName(getCreatureName(cid), parcel, town) 
    end

  • Lua:
    -- example usage
    doPlayerAddDepotItems(cid, {[2160] = 60, ["backpack"] = 1})
    doPlayerAddDepotItems(cid, {["gold coin"] = 100, ["crystal coin"] = 16})
 
Talkaction?

wait-what-meme-rage-face.jpg


@thread
great job!
 
Example talkactions (not tested, but should work)
Lua:
function doPlayerAddDepotItems(cid, items, town)
	if (not isPlayer(cid)) then
		error("Player not found")
	end
	local town = town or getPlayerTown(cid)
 
	local parcel = doCreateItemEx(ITEM_PARCEL)
	for item, count in pairs(items) do
		if (type(item) == "number") then
			doAddContainerItem(parcel, item, count)
		elseif (type(item) == "string") then
			doAddContainerItem(parcel, getItemIdByName(item), count)
		else
			error("Undefinied type of item name")
		end
	end
 
	return doPlayerSendMailByName(getCreatureName(cid), parcel, town) 
end

function onSay(cid, words, param, channel)
	if (param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
	else
		local params = string.explode(param, ",")
		if (not params[2]) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
		elseif (not getPlayerByNameWildcard(params[1])) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " not found.")
		else
			local items, item_params = {}, {}
			for i = 2, #params do
				item_params = string.explode(params[i], "x")
				if (#item_params ~= 2 or tonumber(item_params[1]) <= 0 or tonumber(item_params[2]) <= 0) then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
				else
					items[tonumber(item_params[2])] = tonumber(item_params[1])
					print(items[tonumber(item_params[2])])
				end
			end
			if (#item_params > 0) then
				doPlayerAddDepotItems(getPlayerByNameWildcard(params[1]), items)
			end
		end
	end

	return true
end

Usage ingame:
/yourcommand Ralcoral, 100x2160, 1x2161
 
useless function. already exist an function to add an UID in a depot (in tfs 0.3.6 or higger)
 
Will it work?
Lua:
doPlayerAddDepotItems(cid, {["gold coin"] = 100, ["crystal coin"] = 16}, ["carlin"])
 
How can I set attribute aid/description
Lua:
		doPlayerAddDepotItems(cid, {[glacierkiltid]=1})
 
Last edited:
Lua:
local a = doPlayerAddDepotItems(cid, items, town)
	doItemSetAttribute(a.uid, 'aid', actionid)
I really don't know if you could set two attributes through this though.
 
Last edited:
Console error?
Description:
(luaDoItemSetAttribute) Item not found


Lua:
		local itemattrs = doPlayerAddDepotItems(cid, {[scalerobeid]=1})
		doItemSetAttribute(itemattrs, 'description', "Who Cares")
 
Console error using Description
Description:
(luaDoItemSetAttribute) Item not found


Lua:
local itemattrs = doPlayerAddDepotItems(cid, {[scalerobeid]=1})
doItemSetAttribute(itemattrs, 'description', "Who Cares")
 
-_- you didnt edit the script, lol.
change doItemSetAttribute(itemattrs, bla bla) to doItemSetAttribute(itemattrs.uid, bla bla)
 
Tested, lot of buggs in console

Sem título.jpg


Lua:
local itemattrs = doPlayerAddDepotItems(cid, {[scalerobeid]=1})
doItemSetAttribute(itemattrs.uid, 'description', "Who Cares")
 
Will it work?
Lua:
doPlayerAddDepotItems(cid, {["gold coin"] = 100, ["crystal coin"] = 16}, ["carlin"])
Nope.


Console error using Description
Description:
(luaDoItemSetAttribute) Item not found


Lua:
local itemattrs = doPlayerAddDepotItems(cid, {[scalerobeid]=1})
doItemSetAttribute(itemattrs, 'description', "Who Cares")
This function doesn't return a UID.
 
Back
Top