I always wanted a function like doPlayerAddDepotItems, so this is the nearest thing I could make.
First of all, Kinight gave me the idea, and I made all the scripting.
Add this to global.lua or functions.lua or whatever you use :
So, here's how it works:
First of all, you need to edit two variables:
MAILBOX_POS = This is the position of any mailbox in the map, it doesn't matter where it is, but using an unreachable mailbox is adviced, so if you use a wrong town name or something like that, nobody can take the parcel/letter.
TOWN_NAMES = This array must have all the names of the towns of your map, in the same order they were added, so they match with the town id.
Now, the functions:
-doPlayerReceiveLetter(name,town,text)
name = Name of the player who is going to recieve the letter.
town = Name of the town or Id of the town
text = The text that will be written in the letter(the Adress is already added)
--Examples:
---doPlayerReceiveLetter("God Lord","Selentia","Hello")
---doPlayerReceiveLetter("Kinight",3,"Bye")
-doPlayerReceiveParcel(name,town,items)
name = Name of the player who is going to recieve the parcel
town = Name of the town or Id of the town
items = This may be a little complicated, there are two ways to add the items, in a simple array like {4364,2148,2472}, that will add one of each of the items in the array; You can also use arrays inside the array, like this: {4364,{id = 2148, count = 100},2495}.
You can also add descriptions(desc), text(text) or action Ids(aid).
The label is already added
-Examples
--doPlayerReceiveParcel("God Lord","Selentia",{{id = 2090, aid = 4532, desc = "This key opens the secret chamber"}, {id = 2160, count = 15}, 2472}) -- That will add a crystal key with an action id and a description, 15 crystal coins and 1 magic plate armor.
And that's it, please tell me if you find any bug.
Hope you like it.
First of all, Kinight gave me the idea, and I made all the scripting.
Add this to global.lua or functions.lua or whatever you use :
PHP:
TOWN_NAMES = {"Rookgaard", "Selentia", "Keltenia"}
MAILBOX_POS = {x=1187, y=1240, z=7}
function doPlayerReceiveLetter(name, town, text)
if getPlayerGUIDByName(name) ~= 0 then
if type(town) == 'number' then
town = TOWN_NAMES[town]
end
local letter = doCreateItemEx(2597)
doSetItemText(letter,name.."\n"..town.."\n\n"..text)
doTileAddItemEx(MAILBOX_POS,letter)
else
debugPrint("doPlayerSendLetter: Player not found")
end
end
function doPlayerReceiveParcel(name, town, items)
if getPlayerGUIDByName(name) ~= 0 then
if type(town) == 'number' then
town = TOWN_NAMES[town]
end
local parcel = doCreateItemEx(2595)
local label = doAddContainerItem(parcel, 2599)
doSetItemText(label,name.."\n"..town)
for i = 1, #items do
if type(items[i]) == 'table' then
local tempitem = doAddContainerItem(parcel,items[i].id,items[i].count or 1)
doSetItemText(tempitem,items[i].text or "")
doSetItemSpecialDescription(tempitem,items[i].desc or "")
if items[i].aid ~= nil then
doSetItemActionId(tempitem,items[i].aid)
end
else
doAddContainerItem(parcel, items[i], 1)
end
end
doTileAddItemEx(MAILBOX_POS,parcel)
else
debugPrint("doPlayerSendParcel: Player not found")
end
end
So, here's how it works:
First of all, you need to edit two variables:
MAILBOX_POS = This is the position of any mailbox in the map, it doesn't matter where it is, but using an unreachable mailbox is adviced, so if you use a wrong town name or something like that, nobody can take the parcel/letter.
TOWN_NAMES = This array must have all the names of the towns of your map, in the same order they were added, so they match with the town id.
Now, the functions:
-doPlayerReceiveLetter(name,town,text)
name = Name of the player who is going to recieve the letter.
town = Name of the town or Id of the town
text = The text that will be written in the letter(the Adress is already added)
--Examples:
---doPlayerReceiveLetter("God Lord","Selentia","Hello")
---doPlayerReceiveLetter("Kinight",3,"Bye")
-doPlayerReceiveParcel(name,town,items)
name = Name of the player who is going to recieve the parcel
town = Name of the town or Id of the town
items = This may be a little complicated, there are two ways to add the items, in a simple array like {4364,2148,2472}, that will add one of each of the items in the array; You can also use arrays inside the array, like this: {4364,{id = 2148, count = 100},2495}.
You can also add descriptions(desc), text(text) or action Ids(aid).
The label is already added
-Examples
--doPlayerReceiveParcel("God Lord","Selentia",{{id = 2090, aid = 4532, desc = "This key opens the secret chamber"}, {id = 2160, count = 15}, 2472}) -- That will add a crystal key with an action id and a description, 15 crystal coins and 1 magic plate armor.
And that's it, please tell me if you find any bug.
Hope you like it.
Last edited: