• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua How to send a parcel to a player?

  • Thread starter Thread starter Xikini
  • Start date Start date
X

Xikini

Guest
Short and simple. TFS 0.3.7.

How do you send a parcel to a player from the system?

Easy example,
Use an object and get sent a parcel containing a backpack.
Inside the backpack is..
a demon shield, 53 gold coins and 4 amethysts.


Code:
<action actionid="45001" event="script" value="send_parcel_test.lua"/>
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   -- parcel unsent id = 2595
   -- label id = 2599
   -- parcel sent id = 2596
   local backpack = doPlayerAddItem(cid,1988,1)
   doAddContainerItem(backpack,2520,1)
   doAddContainerItem(backpack,2148,53)
   doAddContainerItem(backpack,2150,4)
   
   return true
end
Thanks for checking into this for me.

Xikini
 
Not terribly familiar with 0.3.7 but is there a doCreateItem() function? if so, you should be able to do like
Code:
local parcel = doCreateItem(2596)
local backpack = doAddContainerItem(parcel, 1988, 1)
doAddContainerItem(backpack,2520,1)
doAddContainerItem(backpack,2148,53)
doAddContainerItem(backpack,2150,4)
local label = doAddContainerItem(parcel, 2599, 1)
--function to set text on label, I'm not sure what that is in 0.3.7
--move item to a mailbox in the middle of no where and send normally, or otherwise just get the player's depot and just add it in there?
 
Not terribly familiar with 0.3.7 but is there a doCreateItem() function? if so, you should be able to do like
Code:
local parcel = doCreateItem(2596)
local backpack = doAddContainerItem(parcel, 1988, 1)
doAddContainerItem(backpack,2520,1)
doAddContainerItem(backpack,2148,53)
doAddContainerItem(backpack,2150,4)
local label = doAddContainerItem(parcel, 2599, 1)
--function to set text on label, I'm not sure what that is in 0.3.7
--move item to a mailbox in the middle of no where and send normally, or otherwise just get the player's depot and just add it in there?
haha this is what I was going to do if no solution was found. :p
I'll mark it as solved tomorrow morning if theres no other solution. ;p
 
Okay :p
As far as I know, mail is handled entirely by the source, so to create a function for mail sending, you'd have to find the mail functions in the source, port the necessary one(s) to lua and then recompile, but I imagine that isn't ideal
 
Code:
function doPlayerAddDepotItems(cid, pos, town, items, notify) -- Credits to Chojy for idea.
  local parcel = doCreateItemEx(2595)
  local label = doAddContainerItem(parcel, 2599)
   
  doSetItemText(label, getCreatureName(cid) .."\n".. town)
  doAddContainerItemEx(parcel, items)
  doTeleportThing(parcel, pos)
  if notify then
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your backpack has been sent to your local town depot.")
  end
return true
end
 
Back
Top