• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Prevent loss in a crash

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
This script is too useful!
if you server crash and your players are insed of POI or anihhilator all them will die and lost exp and loot. BUT... NOT now!
wink.gif


Add this tag on creaturescripts.xml

Code:
<event type="preparedeath" name="crash" event="script" value="crash.lua"/>

And on crash.lua:
Lua:
local nonDieDelay = 60*3 --- 3 minuts
function onPrepareDeath(cid,aa) -- Script by mock the bear
	if getWorldUpTime() <= nonDieDelay then
		doCreatureAddHealth(cid,getCreatureMaxHealth(cid))
		doCreatureAddMana(cid,getCreatureMaxMana(cid))
		doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))
		doRemoveCreature(cid)
		return false
	end
        return true
end

And enjoy :thumbup:
if you open your server and die in less of 3 mins you dont loose nothing! not loot and exp
 
You and your crazy amazing usefull ideas. So simple but so usefull haha
 
Code:
[1:51:08.489] [Error - CreatureScript Interface]
[1:51:08.490] data/creaturescripts/scripts/idle.lua:onThink
[1:51:08.490] Description:
[1:51:08.490] (luaGetThingPosition) Thing not found

[1:51:08.490] [Error - CreatureScript Interface]
[1:51:08.490] data/creaturescripts/scripts/idle.lua:onThink
[1:51:08.490] Description:
[1:51:08.490] (luaGetTileInfo) Tile not found

[1:51:08.490] [Error - CreatureScript Interface]
[1:51:08.490] data/creaturescripts/scripts/idle.lua:onThink
[1:51:08.490] Description:
[1:51:08.490] data/creaturescripts/scripts/idle.lua:7: attempt to index a boolean value
[1:51:08.490] stack traceback:
[1:51:08.490]   data/creaturescripts/scripts/idle.lua:7: in function <data/creaturescripts/scripts/idle.lua:6>

Lua:
local config = {
	idleWarning = getConfigValue('idleWarningTime'),
	idleKick = getConfigValue('idleKickTime')
}

function onThink(cid, interval)
	if(getTileInfo(getCreaturePosition(cid)).nologout or getCreatureNoMove(cid) or
		getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_ALLOWIDLE)) then
		return true
	end

	local idleTime = getPlayerIdleTime(cid) + interval
	doPlayerSetIdleTime(cid, idleTime)
	if(config.idleKick > 0 and idleTime > config.idleKick) then
		doRemoveCreature(cid)
	elseif(config.idleWarning > 0 and idleTime == config.idleWarning) then
		local message = "You have been idle for " .. math.ceil(config.idleWarning / 60000) .. " minutes"
		if(config.idleKick > 0) then
			message = message .. ", you will be disconnected in "
			local diff = math.ceil((config.idleWarning - config.idleKick) / 60000)
			if(diff > 1) then
				message = message .. diff .. " minutes"
			else
				message = message .. "one minute"
			end

			message = message .. " if you are still idle"
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, message .. ".")
	end

	return true
end

It gives an error on this script :S
 
@up that has nothing to do with Mock's script
 
Trust me, I changed what HeberPCL said (function onPrepareDeath(cid, deathList)) and then reloaded and said those errors...
 
hehe :p ye ure right
here's the fix: @ idle.lua
add after function onThink(cid, interval)
this
Lua:
if not isPlayer(cid) then
    return true
end
 
Back
Top