Ir para conteúdo

Featured Replies

Postado

local function getPlayerTownByGUID(guid) -- by MaTTch
	local ret = 0
	if(not guid) then
		return ret
	end
	local result = db.getResult("SELECT `town_id` FROM `players` WHERE `id` = "..guid..";")
	if(result:getID() ~= -1) then
		ret = result:getDataInt("town_id")
		result:free()
	end
	return ret
end

local function doPlayerAddDepotItemByName(name, item, quant, town) -- by MaTTch
	quant, town = quant and quant or 1, town and town or getPlayerTownByGUID(getPlayerGUIDByName(name))
	local a = doCreateItemEx(item, quant)
	if(getPlayerGUIDByName(name)) then
		doPlayerSendMailByName(name, a, town)
		return true
	end
	return false
end

function onSay(cid, words, param)
	local t = string.explode(param, ",")
	if(param == "" or not t[1] or not t[2]) then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Need player, itemid, count and town params.")
	end
	
	local count = t[3] and tonumber(t[3]) or 100
	local town = t[4] and tonumber(t[4])
	if(doPlayerAddDepotItemByName(t[1], t[2], count, town)) then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sent successfully. [Player: \""..getPlayerNameByGUID(getPlayerGUIDByName(t[1])).."\" gained "..count.." "..getItemNameById(t[2])..""..(count > 1 and "s" or "").."].")
	else
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not exists.")
	end
	return true
end

 

Testado TFS 0.4

Editado por MaTTch (veja o histórico de edições)

Postado
function onSay(cid, words, param)
    local t = param:explode(",")
    local pid, itemid, count = getPlayerByName(t[1]), tonumber(t[2]), tonumber(t[3]) or 1
    if not isPlayer(pid) then
        return doPlayerSendCancel(cid, "This player doesn't exist or is offline.")
    elseif not itemid then
        return doPlayerSendCancel(cid, "Write a existent item.")
    end
    local item = doCreateItemEx(itemid, count)
    doPlayerSendTextMessage(cid, 27, "You sent "..count.."x "..getItemNameById(itemid).." to "..getCreatureName(pid)..".")
    doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_ORANGE, "You received "..count.."x "..getItemNameById(itemid)..".")
    doPlayerSendMailByName(getCreatureName(pid), item)
    return true
end

ops, mandaram outra versão acima mais completa. w/e, se não funcionar, taí.

Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo