• 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

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Solutions
2
Reaction score
160
It's answer for: http://otland.net/f132/0-3-5pl1-request-51235/
Idea by Gesior.pl!
Tested on The Forgotten Server 0.3.5pl1


How it works?
It will create a parcel with items from table, then send this parcel to mailbox positions. (It'll be send to players depot by parcel system.)


The Function
mailBoxPos = some position of mail box on map.
Code:
function doPlayerAddDepotItems(cid, town, items, notify)
	local mailBoxPos = {x = 991, y = 1052, z = 7}

	local parcel = doCreateItemEx(2595)

	local label = doAddContainerItem(parcel, 2599)
	doSetItemText(label, getCreatureName(cid) .."\n".. town)

	for i = 1, #items do
		doAddContainerItem(parcel, items[i][1], items[i][2])
	end

	doTeleportThing(parcel, mailBoxPos)

	if (notify == TRUE) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "New mail arrived.")
	end
	return true
end


Example talkaction for test:
Code:
function onSay(cid, words, param, channel)
	local items = {
		{2160, 99},
		{2152, 59}
	}
	doPlayerAddDepotItems(cid, "Main City", items, TRUE) 
	return true
end


How to use?
doPlayerAddDepotItems(Player UID, Town Name, Items Table {Item ID, Count}, Notification TRUE/FALSE)

fff.PNG
 
Last edited:
on TFS 0.3.5 beta (and older version probably too) it doesnt work.
and when I fix it (replace doTeleport... with:)
doTileAddItemEx(mailBoxPos,parcel)
Crash server :> (server always crash when script try to teleport/put parcel on mailbox)
EDIT:
@down
yeye
Add in first post that it's ONLY for TFS 0.3.5pl1 and newer versions
 
I wrote Tested on The Forgotten Server 0.3.5pl1, and works perfect :p
 
It will work too (Parcel System :p)

From what I can see the script just teleports the created item to the position of the mailbox, doesn't that mean it will end up ontop of it and if there is trash on the mailbox the parcel will just end up over the trash? (like in "real tibia")
 
and besides you could put the mailbox where noone can go, like in the middle of nowhere.
 
LOLOLOLOLOLOLOL I just checked TFS 0.3.5pl1 source and found:
doPlayerSendMailByName(name, item[, town[, actor]])
So you can use:
doPlayerSendMailByName(toPlayerName, item, town_id)
or:
doPlayerSendMailByName(toPlayerName, item)
(no town id = send to 'player town')
item can be container with items
and playe should receive item into depot and it can be any item, not only parcel :)
EDIT:
Siedzimy i 30 min piszemy jak to zrobic. Zaczalem szukac w silniku gdzie jest to 'send mail' i dlaczego mi crashuje, a znalazlem, ze w LUA tez jest odpalane :)
 
Last edited:
@doPlayerSendMailByName(name, item, town_id): Lols
@Chojrak: haha xD, the script just tp the parcel on the deport right?
 
No, this script is creating parcel, putting label with player name/town name and items from table inside then teleporting parcel at mailbox position. Parcel will be send to player depot by Parcel System.
 
LOLOLOLOLOLOLOL I just checked TFS 0.3.5pl1 source and found:
doPlayerSendMailByName(name, item[, town[, actor]])
So you can use:
doPlayerSendMailByName(toPlayerName, item, town_id)
or:
doPlayerSendMailByName(toPlayerName, item)
(no town id = send to 'player town')
item can be container with items
and playe should receive item into depot and it can be any item, not only parcel :)
EDIT:
Siedzimy i 30 min piszemy jak to zrobic. Zaczalem szukac w silniku gdzie jest to 'send mail' i dlaczego mi crashuje, a znalazlem, ze w LUA tez jest odpalane :)

//no chłopaki, fail ^^
 
Fixed one problem: if on top mailbox are moveable item

Code:
function doPlayerAddDepotItems(cid, town, items, notify)
	local mailBoxPos = {x = 991, y = 1052, z = 7}

	local parcel = doCreateItemEx(2595)

	local label = doAddContainerItem(parcel, 2599)
	doSetItemText(label, getCreatureName(cid) .."\n".. town)

	for i = 1, #items do
		doAddContainerItem(parcel, items[i][1], items[i][2])
	end

	for i = 1, 255 do
		item_ = getThingFromPos({x = mailBoxPos.x, y = mailBoxPos.y, z = mailBoxPos.z, stackpos = 255})
		if item_.uid == 0 then
			break
		end
		doRemoveItem(item_.uid)
	end
	
	doTeleportThing(parcel, mailBoxPos)

	if (notify == TRUE) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "New mail arrived.")
	end
	return true
end

PS: Grat idea Chojrak :)
 
Back
Top