• 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!

[Question] Is it possible? It probably is, but I'm not a scripter

Peroxide

Gone since January 2018
Senator
Joined
Aug 22, 2008
Messages
10,477
Reaction score
2,421
Location
New Zealand
Is it possible to have a Loot message for PvP? It probably is, but I'm not a scripter
E.g

Loot of Cykotitan: 12 gold coins, meat, life ring.

It would also be shown to members in a Party Aswell?
I think It could be a good feature for pvp :p
 
Lua:
function getContentDescription(uid, comma)
	local ret, i, containers = '', 0, {}
	while i < getContainerSize(uid) do
		local v, s = getContainerItem(uid, i), ''
		local k = getItemInfo(v.itemid)
		if k.name ~= '' then
			if v.type > 1 and k.stackable and k.showCount then
				s = v.type .. ' ' .. getItemInfo(v.itemid).plural
			else
				local article = k.article
				s = (article == '' and '' or article .. ' ') .. k.name
			end
			ret = ret .. (i == 0 and not comma and '' or ', ') .. s
			if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
				table.insert(containers, v.uid)
			end
		else
			ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
		end
		i = i + 1
	end
	for i = 1, #containers do
		ret = ret .. getContentDescription(containers[i], true)
	end
	return ret
end

local function send(cid, pos, corpseid, name, party)
	local corpse = getTileItemById(pos, corpseid).uid
	local ret = isContainer(corpse) and getContentDescription(corpse)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. name .. ': ' .. (ret ~= '' and ret or 'nothing'))
	if party then
		for _, pid in ipairs(getPartyMembers(party)) do
			doPlayerSendChannelMessage(pid, '', 'Loot of ' .. name .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
		end
	end
end

function onKill(cid, target, lastHit)
	if isPlayer(target) then
		addEvent(send, 0, cid, getThingPos(target), getPlayerSex(target) == 0 and 6081 or 6080, getCreatureName(target), getPlayerParty(cid))
	end
	return true
end
 
Lua:
function getContentDescription(uid, comma)
	local ret, i, containers = '', 0, {}
	while i < getContainerSize(uid) do
		local v, s = getContainerItem(uid, i), ''
		local k = getItemInfo(v.itemid)
		if k.name ~= '' then
			if v.type > 1 and k.stackable and k.showCount then
				s = v.type .. ' ' .. getItemInfo(v.itemid).plural
			else
				local article = k.article
				s = (article == '' and '' or article .. ' ') .. k.name
			end
			ret = ret .. (i == 0 and not comma and '' or ', ') .. s
			if isContainer(v.uid) and getContainerSize(v.uid) > 0 then
				table.insert(containers, v.uid)
			end
		else
			ret = ret .. (i == 0 and not comma and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
		end
		i = i + 1
	end
	for i = 1, #containers do
		ret = ret .. getContentDescription(containers[i], true)
	end
	return ret
end

local function send(cid, pos, corpseid, name, party)
	local corpse = getTileItemById(pos, corpseid).uid
	local ret = isContainer(corpse) and getContentDescription(corpse)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. name .. ': ' .. (ret ~= '' and ret or 'nothing'))
	if party then
		for _, pid in ipairs(getPartyMembers(party)) do
			doPlayerSendChannelMessage(pid, '', 'Loot of ' .. name .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
		end
	end
end

function onKill(cid, target, lastHit)
	if isPlayer(target) then
		addEvent(send, 0, cid, getThingPos(target), getPlayerSex(target) == 0 and 6081 or 6080, getCreatureName(target), getPlayerParty(cid))
	end
	return true
end

Wow.. thats some code lol

awesome as always
 
creaturescript, mr peroxide
creaturescripts.xml
XML:
<event type="kill" name="scripty" event="script" value="scripty.lua"/>
login.lua
Lua:
registerCreatureEvent(cid, "scripty")
;x
 
Back
Top