• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[Help] Transform Corpse or Delete Corpse

Critico

Sexy
Joined
Mar 25, 2010
Messages
370
Reaction score
179
this not work:

Code:
function onDeath(cid, corpse, killer)
if corpse.uid > 0 then
doTransformItem(corpse.uid,2160,1)
end
return true
end

or

Code:
function onDeath(cid, corpse, killer)
if corpse.uid > 0 then
doRemoveItem(corpse.uid, 1)
end
return true
end

why?
 
or at items.xml you can add this
Code:
<attribute key="decayTo" value="0" /> <-- what it gone transform to (0 means nothing)
<attribute key="duration" value="55" /> <-- how many seconds!
 
UIDs are a very strange thing actually.
The UID (not the unique ID in the mapeditor or from an item) is a table and it consists of:
*Just an assumption, not proven!*
ItemID,Position,"Time Stamp" and maybe more infos like clientversion and so on.
It changes like every system second.
*JUST ASSUMING! NOT PROVEN!*

The only thing which will never change when a corpse is created is the position.
So try it like that:
LUA:
doTransformItem(getTileItemById(getThingPos(cid), CORPSE_ID), 2160)
If this doesn't work post your errors or some information on what went wrong.
 
LUA:
local item = xxxx -- replace xxxx with the itemid of the corpse itemid you wanna use
function onDeath(cid, corpse, killer)
if (isCorpse(item).uid) then
doTransformItem((item).uid, 2160, 1)
end
return true
end

try this one, ;)

¡Bless you and Cheers up!
(Y)(Y)

-Obsdark-
 
creaturescripts.xml:
XML:
	<event type="kill" name="KillReward" event="script" value="killReward.lua"/>

login.lua:
LUA:
	registerCreatureEvent(cid, "KillReward")

creaturescripts/scripts/killReward.lua:
LUA:
local config = {
	monsters = {"Rat", "Dragon"},
	reward = {
		["Rat"] = {2160, 5},
		["default"] = {2160, 1}
	}
}

local function transformCorpse(name, id, pos, toId, toCount)
	local corpse = getTileItemById(pos, id)
	if corpse.uid > 0 then
		local reward = config.reward[name] or config.reward["default"]
		doRemoveItem(corpse.uid)
		doCreateItem(reward[1], reward[2], pos)
	end
end

function onKill(cid, target, lastHit)
	local name = getCreatureName(target)
	if isInArray(config.monsters, name) then
		addEvent(transformCorpse, 1, name, getMonsterInfo(getCreatureName(target)).lookCorpse, getThingPos(target))
	end
	return true
end

CONFIG:
In "monsters" you declare the monsters which have an extra reward.
::>
{"Rat", "Dragon"}


In "reward" you can either declare a reward for every monster you set or if you dont set the reward the "default" reward will be given.
::>
["Rat"] = {2160, 5},
["default"] = {2160, 1}

The first is the itemid, the second number the count.

Rep+ if helped.
 
LUA:
local item = xxxx -- replace xxxx with the itemid of the corpse itemid you wanna use
function onDeath(cid, corpse, killer)
if (isCorpse(item).uid) then
doTransformItem((item).uid, 2160, 1)
end
return true
end

try this one, ;)

¡Bless you and Cheers up!
(Y)(Y)

-Obsdark-

this error:
Code:
[05/03/2012 13:03:08] [Error - CreatureScript Interface] 
[05/03/2012 13:03:08] data/creaturescripts/scripts/heartd.lua:onDeath
[05/03/2012 13:03:08] Description: 
[05/03/2012 13:03:08] (luaGetThing) Thing not found

[05/03/2012 13:03:08] [Error - CreatureScript Interface] 
[05/03/2012 13:03:08] data/creaturescripts/scripts/heartd.lua:onDeath
[05/03/2012 13:03:08] Description: 
[05/03/2012 13:03:08] data/creaturescripts/scripts/heartd.lua:3: attempt to index a boolean value
[05/03/2012 13:03:08] stack traceback:
[05/03/2012 13:03:08] 	data/creaturescripts/scripts/heartd.lua:3: in function <data/creaturescripts/scripts/heartd.lua:2>



creaturescripts.xml:
XML:
	<event type="kill" name="KillReward" event="script" value="killReward.lua"/>

login.lua:
LUA:
	registerCreatureEvent(cid, "KillReward")

creaturescripts/scripts/killReward.lua:
LUA:
local config = {
	monsters = {"Rat", "Dragon"},
	reward = {
		["Rat"] = {2160, 5},
		["default"] = {2160, 1}
	}
}

local function transformCorpse(name, id, pos, toId, toCount)
	local corpse = getTileItemById(pos, id)
	if corpse.uid > 0 then
		local reward = config.reward[name] or config.reward["default"]
		doRemoveItem(corpse.uid)
		doCreateItem(reward[1], reward[2], pos)
	end
end

function onKill(cid, target, lastHit)
	local name = getCreatureName(target)
	if isInArray(config.monsters, name) then
		addEvent(transformCorpse, 1, name, getMonsterInfo(getCreatureName(target)).lookCorpse, getThingPos(target))
	end
	return true
end

CONFIG:
In "monsters" you declare the monsters which have an extra reward.
::>
{"Rat", "Dragon"}


In "reward" you can either declare a reward for every monster you set or if you dont set the reward the "default" reward will be given.
::>
["Rat"] = {2160, 5},
["default"] = {2160, 1}

The first is the itemid, the second number the count.

Rep+ if helped.

Worked from monsters... i need work from players too

REP +
 
LUA:
local config = {
	monsters = {"Rat", "Dragon", "player"},
	reward = {
		["Rat"] = {2160, 5},
		["default"] = {2160, 1},
		["player"] = {2160, 10}
	}
}

local function transformCorpse(name, id, pos, toId, toCount)
	local corpse = getTileItemById(pos, id)
	if corpse.uid > 0 then
		local reward = config.reward[name] or config.reward["default"]
		doRemoveItem(corpse.uid)
		doCreateItem(reward[1], reward[2], pos)
	end
end

function onKill(cid, target, lastHit)
	local name = isPlayer(target) and "player" or getCreatureName(target)
	if isInArray(config.monsters, name) then
		addEvent(transformCorpse, 1, name, getMonsterInfo(getCreatureName(target)).lookCorpse, getThingPos(target))
	end
	return true
end

Try this for players.
 
LUA:
local reward, count = 2160, 1 --reward itemID and the count
local corpse = XXXX --put here the corpse ID of players (kill a player and look at him ingame to make sure you get the correct ID!
 
function onKill(cid, target, lastHit)
	if isPlayer(target) then
		doCleanTile(getThingPos(target))
		doCreateItem(reward, count, getThingPos(target))
	end	
	return true
end
Edited Summs script, this should do for players ONLY.
Credits to Summ ;)
 
Last edited:
this error now

@Summ

Code:
[05/03/2012 13:27:54] [Error - CreatureScript Interface] 
[05/03/2012 13:27:54] data/creaturescripts/scripts/killReward.lua:onKill
[05/03/2012 13:27:54] Description: 
[05/03/2012 13:27:54] data/creaturescripts/scripts/killReward.lua:22: attempt to index a boolean value
[05/03/2012 13:27:55] stack traceback:
[05/03/2012 13:27:55] 	data/creaturescripts/scripts/killReward.lua:22: in function <data/creaturescripts/scripts/killReward.lua:19>

[05/03/2012 13:27:55] [Error - CreatureScript Interface] 
[05/03/2012 13:27:55] data/creaturescripts/scripts/killReward.lua:onKill
[05/03/2012 13:27:55] Description: 
[05/03/2012 13:27:55] (luaGetMonsterInfo) Monster not found

--- EDITED

@Zyntax

the same error /\
=/
 
this script worked:

Code:
function onKill(cid, target, lastHit)
	if isPlayer(target) then
        addEvent(DeleteCorpse,200,getCreaturePosition(target))
	end	
	return true
end
function DeleteCorpse(pos)
    doCleanTile(pos)
    doCreateItem(2160, 1, pos)
return true
end

:D

thanks to all who helped
 
This should work now. I would use this as the whole tile wont be cleaned only the corpse will be removed.
LUA:
local config = {
	monsters = {"Rat", "Dragon", "player"},
	reward = {
		["Rat"] = {2160, 5},
		["default"] = {2160, 1},
		["player"] = {2160, 10}
	}
}
 
local function transformCorpse(name, id, pos, toId, toCount)
	local corpse = getTileItemById(pos, id)
	if corpse.uid > 0 then
		local reward = config.reward[name] or config.reward["default"]
		doRemoveItem(corpse.uid)
		doCreateItem(reward[1], reward[2], pos)
	end
end
 
function onKill(cid, target, lastHit)
	local name = isPlayer(target) and "player" or getCreatureName(target)
	local corpse = name == "player" and (getPlayerSex(cid) == 0 and 3065 or 3058) or getMonsterInfo(getCreatureName(target)).lookCorpse

	if isInArray(config.monsters, name) then
		addEvent(transformCorpse, 1, name, corpse, getThingPos(target))
	end
	return true
end
 
Back
Top