local DefaultTownId = 1 -- town id that sends the parcel
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
return true
end
local t = string.explode(param, ",")
if(not t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough params.")
return true
end
local pid = getPlayerByNameWildcard(t[1]) -- check player name
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
return true
end
local id = tonumber(t[2]) -- check item id or name
if(not id) then
errors(false)
id = getItemIdByName(t[2])
errors(true)
if(not id) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item with such name does not exists.")
return true
end
end
local amount = tonumber(t[3]) -- check if has amount or not
if(not amount or amount == 0) then
amount = 1
end
local parcel = doCreateItemEx(2595) -- make a parcel
local letter = doAddContainerItem(received, 2598, 1) -- make a letter inside parcel
doSetItemText(letter, "TEXT OF LETTER HERE", "NAME", os.time()) -- DISPLAY TEXT, NAME WHO SEND OR ANOTHER NAME AND HOUR SEND
doAddContainerItem(parcel, id, amount)
doPlayerSendMailByName(getPlayerNameByGUID(pid), parcel, DefaultTownId)
return true
end