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

No logout after death and teleport to temple instead (OTX 2)

jerynn

New Member
Joined
May 27, 2018
Messages
28
Reaction score
2
Hello guys, what source edit or lua script i can do to make player teleport to temple after death and not logout..it's for war server
 
it's for war server
It can be 100% Lua. Add onPrepareDeath event that return false and heal player. It should make him unkillable. Test it, if it works fine (player can still walk etc.), then add code that adds mana and teleports to temple and that's should be all.

There is one known problem with fire bombs. If you move player to temple after he throw some fire bomb, someone may walk into that bomb and player will get PZ lock in protection zone. Some player can be also already burning by fire bomb and get delayed damage, which will also PZ lock player in protection zone.
With each relog player gets new ID in C++, which makes fire bomb does not count as his.
To fix this issue on my war OTS, I've added addEvent that executed 60 times with 1 second interval and removed PZ lock from player, if he was still in protection zone.

With onPrepareDeath event that returns false, C++ 'onDeath' code won't execute. If your server bases on C++ code that gives exp for kills, you got to replicate that code in Lua, to give exp to player. Corpse won't drop, you will have to add it in Lua too.
 
Last edited:
Can you provide me with these scripts cause i'm not expert enough to create them on my own & thx in advance
 
Can you provide me with these scripts cause i'm not expert enough to create them on my own & thx in advance
In data/creaturescripts/creaturescripts.xml add:
XML:
<event type="login" name="NoDeathLogin" event="script" value="no_death.lua"/>
<event type="preparedeath" name="NoDeathPrepareDeath" event="script" value="no_death.lua"/>
Create file data/creaturescripts/scripts/no_death.lua and paste into it:
Lua:
local templePosition = {x = 1000, y = 1000, z = 7}

function onLogin(cid)
   registerCreatureEvent(cid, "NoDeathPrepareDeath")
   return true
end

local function removePzLock(cid, iterations)
   if isPlayer(cid) and getTileInfo(getThingPosition(cid)).protection then
      doPlayerSetPzLocked(cid, false)
      if iterations > 0 then
         addEvent(removePzLock, 1000, cid, iterations - 1)
      end
   end
end

function onPrepareDeath(cid, deathList)
   doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
   doCreatureAddMana(cid, getCreatureMaxMana(cid))
   doRemoveConditions(cid)
   doTeleportThing(cid, templePosition, true, true)
   removePzLock(cid, 60)

   return false
end
configure temple positions:
Lua:
local templePosition = {x = 1000, y = 1000, z = 7}

There is no code for corpse and exp for kills.
It's hard to balance exp for kills. If this code works and teleport players to temple, message me on Discord: Gesior.pl#3208 , we will work on some exp for kills formula [I will post it in this thread later].
 
It does teleport players to temple but with 0 hp and inability to move in any direction as the char frooze.
 
function onPrepareDeath(cid, deathList) in older versions never worked correctly.

In my experience, onPrepareDeath believes the character to already be dead.. and using return false, assuming it would 'save' the player, doesn't actually do anything.. other then glitch the character to stay online with 0 hp.

I would suggest moving it over to onStatsChange, then just check if the creature hp and the incoming damage are the same.
If they are, the character is about to die, and then you can use it the same as you intended to use onPrepareDeath
 
Back
Top