SK

Doplayeradddepotitems(Cid, Items, Town)

Por SkyDangerous, 09 de ago. de 2012 em Mods, funções e outros

skydangerous
6
2.7k
SkyDangerousS
09 de agosto de 2012 às 01:59

Envia o item diretamente no depot do jogador.

 

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

 

Como usar

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

 

Creditos:

sn4ake

Não testado

Editado Agosto 9 por SkyDangerous

OneshotO
09 de agosto de 2012 às 17:43

É uma função bem útil, mas acho que muitos encontraram problemas com a declaração da função doPlayerSendMailByName.

 

No mais, obrigado pela colaboração.

caoticC
09 de agosto de 2012 às 17:48

Realmente curti.

Alem de verificar se e um numero ou uma string.

 

Parabens

SkyDangerousS
09 de agosto de 2012 às 22:20

opa vlw.

estou estudando algumas funções pra tentar fazer algumas legais..

4 meses depois...
20cm2
07 de dezembro de 2012 às 09:56

Devia por pra selecionar o id do container, pq ele pode nao querer parcel

11 meses depois...
markindootM
06 de novembro de 2013 às 08:40

Revivendo

Tem como faser este script para quando o player morrer, os items droparem e os items shops irem para seu depot?

Ex: o player Jhonny morre com 1 wand shop e um set free, quando ela morre só o set free e a backpack que irão dropar e a wand shop vai diretamente para o DP, Não chegando a cair no chão e sim SUMINDO e Aparecendo no DEPOT do player que morreu.