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

[SOLVED] [1.0] If Player Dies, Corpse become Creature!

Eldin

Eldin Projects
Premium User
Joined
Jun 12, 2008
Messages
1,334
Reaction score
613
Location
Sweden
Greets!

A script that will be of huge importance at my upcoming server will be something different that I have in mind.

If a player dies, the corpse delays 30 seconds (if possible) then turns (and remove body) into a Skeleton.(Monster)
This happens from lvl 1 to lvl 10, from lvl 10, the players body becomes a Demon Skeleton.

If its not possible to make the corpse lootable/delay, its not an issue but would ofcourse be a plus.
Im using TFS 1.0, thanks in advance

Kind Regards,
Eldin.
 
Code:
function onDeath(cid, corpse, deathList)
if getPlayerLevel(cid) ~= 10 then
doSummonCreature(cid, "Name", getPlayerPosition(cid))
end
else
if getPlayerLevel(cid) ~= 20 then
doSummonCreature(cid, "Name", getPlayerPosition(cid))
end
return true
end
Idk if this will work but i just wrote it out of wild imagination.
 
Thank You for the first try!

I tested it and got some "end" errors so I changed it abit:

creaturescripts.xml
Code:
<event type="death" name="Corpse" script="Corpse.lua"/>

Corpse.lua
Code:
function onDeath(cid, corpse, deathList)
    if getPlayerLevel(cid) ~= 10 then
        doSummonCreature(cid, "Skeleton", getPlayerPosition(cid))

    elseif getPlayerLevel(cid) ~= 20 then
        doSummonCreature(cid, "Demon Skeleton", getPlayerPosition(cid))
    end
  return true
end

Nothing happens with the body and I get no errors in the logg,
should I add the interval at creaturescripts.xml?

Kind Regards,
Eldin.
 
I am not sure on the position of the corpse, but maybe this will help you.
Code:
function onPrepareDeath(cid, lasthit)
    local pPos = getPlayerPosition(cid)
    if getPlayerLevel(cid) < 10 then
        addEvent(function ()
                    doRemoveItem(getTileItemById(pPos, CORPSEID).uid)
                    doCreateItem(NEWCORPSEID, pPos)
                end, 30000)
    elseif getPlayerLevel(cid) >= 10 then
        addEvent(function ()
                    doRemoveItem(getTileItemById(pPos, CORPSEID).uid)
                    doCreateItem(NEWCORPSEID, pPos)
                end, 30000)
    end
    return true
end
 
Code:
function onDeath(cid, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    if Player(cid):getLevel() <= 10 then
        addEvent(function(corpse) local item = Item(corpse) if not item then return true end Game.createMonster("Skeleton", item:getPosition()) item:remove() end, 30000, corpse)
    else
        addEvent(function(corpse) local item = Item(corpse) if not item then return true end Game.createMonster("Demon Skeleton", item:getPosition()) item:remove() end, 30000, corpse)
    end
end
 
Last edited:
Tryed Ninjas, also tryed to add "doSummonCreature" instead as Game.createMonster might not work yet on my TFS 1.0 version.
Nothing happens and I get no errors in the log, time to eat, will try Cadyan and other possible ones after I got some food. ^^

Kind Regards,
Eldin
.
 
Tryed Ninjas, also tryed to add "doSummonCreature" instead as Game.createMonster might not work yet on my TFS 1.0 version.
Nothing happens and I get no errors in the log, time to eat, will try Cadyan and other possible ones after I got some food. ^^

Kind Regards,
Eldin
.
Have you registered the event in login.lua?
 
Code:
function onDeath(cid, corpse, deathList)
if getPlayerLevel(cid) ~= 10 then
doSummonCreature(cid, "Name", getPlayerPosition(cid))
end
else
if getPlayerLevel(cid) ~= 20 then
doSummonCreature(cid, "Name", getPlayerPosition(cid))
end
return true
end
Idk if this will work but i just wrote it out of wild imagination.

Is it just me or do you never tab your scripts? :eek:

also, you closed the if, and then tried to use else?

Code:
function onDeath(cid, corpse, deathList)
    if getPlayerLevel(cid) ~= 10 then
        doSummonCreature(cid, "Name", getPlayerPosition(cid))
    elseif getPlayerLevel(cid) ~= 20 then
        doSummonCreature(cid, "Name", getPlayerPosition(cid))
    end
return true
end

Would be the correct way.

Edit: diden't notice eldin haden't already corrected you.
 
Forgot to add it at login, Always forgets that >.<
I'll be Writing as soon as I tested it! :D

Kind Regards,
Eldin.
 
The new one you made works Ninja! :D
This will be freakin awesome, thanks everyone who tryed to help, appriciate it ALOT.

Kind Regards,
Edin.
 
Code:
function onDeath(cid, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    local player = Player(cid)
    local item = Item(corpse)
    if player:getLevel() <= 10 then
        addEvent(function () doSummonCreature("Skeleton", item:getPosition()) item:remove() end, 30000)
    else
        addEvent(function () doSummonCreature("Demon Skeleton", item:getPosition()) item:remove() end, 30000)
    end
    return true
end
move "local item = Item(corpse)" in to addEvent function" to avoid errors or crashes
 
@Ninja
Can you write me a version of this for 0.3.7?
Got a cool idea for this on a side project :p sweet idea eldin
Edit: maybe you can help me understand 1.0 better by this
 
Last edited:
Back
Top