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

[LUA] How to stop death?

Dantarrix

Member
Joined
Aug 27, 2010
Messages
546
Reaction score
18
Location
Stgo, Chile
Well, i have a doubt....
I need a script, when the player dies, he recovers all health and doesnt die....

I know it sounds stupid, but i need only this parto to add it to another script i have... xD
 
If player has item on necklace...
So i think its a movement.... xDDD

@double up: yes, like "revive" but it's not revive, is when you run out with the health, you refill it and lose item on necklace xDDD

Think that shuld be onStatsChange, and not onEquip xDDDD
 
You are searching for a script that refills someones health upon death if they are wearing an amulet?

Lua:
local necklace = 12345
function onPrepareDeath(cid, deathList)
	if getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid == necklace then
		if doPlayerRemoveItem(cid, necklace, 1) then
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
		end
	end
	
	return false
end

J.Dre
 
Last edited:
ok i found this in a forum:

replace data/creaturescripts/playerDeath.lua for:

Code:
"SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";") 
            if(rows:getID() ~= -1) then 
                local amount = rows:getRows(true) - config.maxDeathRecords 
                if(amount > 0) then 
                    if(config.sqlType == DATABASE_ENGINE_SQLITE) then 
                        for i = 1, amount do 
                        db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);") 
                        end 
                    else 
                    db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";") 
                    end 
                end 
            end 
            return TRUE 
        end 
    end 
end

and replace in data/creaturescripts/creaturescripts.xml

Code:
<event type="death" name="PlayerDeath" event="script" value="playerdeath.lua"/>
for:
Code:
<event type="preparedeath" name="PlayerDeath" event="script" value="playerdeath.lua"/>

and in config.lua add:

Code:
deadProtection = 20 -- max lvl in protection


players of X lvl wont die they will get teleported :)
 
create preventdeath.lua
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	if type == 1 then
		if getCreatureHealth(cid) <= value then
			if isPlayer(cid) then
				doCreatureAddHealth(cid, getCreatureMaxHealth(cid), true)
			end
		end
	end
return true
end
and in login.lua add this
Lua:
registerCreatureEvent(cid, "preventdeath")
and in creaturescripts.xml add this
Code:
<event type="statschange" name="preventdeath" event="script" value="preventdeath.lua"/>
 
create preventdeath.lua
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	if type == 1 then
		if getCreatureHealth(cid) <= value then
			if isPlayer(cid) then
				doCreatureAddHealth(cid, getCreatureMaxHealth(cid), true)
			end
		end
	end
return true
end
and in login.lua add this
Lua:
registerCreatureEvent(cid, "preventdeath")
and in creaturescripts.xml add this
Code:
<event type="statschange" name="preventdeath" event="script" value="preventdeath.lua"/>

enjoy your cpu usage
onDeath is much better.
 
Back
Top