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

player death casuses level reset

tiddpd

PHP Scripter
Joined
Apr 16, 2008
Messages
331
Reaction score
0
Im pretty sure that this doesnt happen every time, but a lot of the times when a player dies on my server, their level is reset to level 1, and then they die as soon as they login there after.

here is the playerdeath.lua if it helps

Code:
local config = {
	deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
	sqlType = getConfigInfo('sqlType'),
	maxDeathRecords = getConfigInfo('maxDeathRecords')
}

config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL

function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
	if(config.deathListEnabled ~= TRUE) then
		return
	end

	local hitKillerName = "field item"
	local damageKillerName = ""
	if(lastHitKiller ~= FALSE) then
		if(isPlayer(lastHitKiller) == TRUE) then
			hitKillerName = getPlayerGUID(lastHitKiller)
		else
			hitKillerName = getCreatureName(lastHitKiller)
		end

		if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
			if(isPlayer(mostDamageKiller) == TRUE) then
				damageKillerName = getPlayerGUID(mostDamageKiller)
			else
				damageKillerName = getCreatureName(mostDamageKiller)
			end
		end
	end

	db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
	local rows = db.getResult("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
end
 
its when they die, and after that death when they tried to log in their already dead. I checked database and their health gets set to 0 somehow
 
Well, the script you posted only serves as to update the "latest deaths" table.

Are you sure deathloosepercent and whatnot ain't set to some craaaaaazy high value?
Because that 0HP sounds to me like they loose all of their EXP and thus gets deleveled to lvl 1, and due to the way tibia HP gain is set up, at least knights and paladins would have 0HP at level 1 if deleveled.
 
my config.lua deathlosspercent is only at 7

could it have something to do with my login.lua? theres some loss percent stuff in that also, that i modified.

Code:
function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 7)
	end

	if(getPlayerStorageValue(cid, 34) < 24000) then
		setPlayerStorageValue(cid, 34, 24000)
		doPlayerPopupFYI(cid, "In game commands for Super Server: \n \n /buyrune -- use to buy a small selection of runes anywhere in the world \n /buyaol -- use to buy aol anywhere in the world \n /buyammo -- use to buy ammo anywhere in the world \n \n /commands to see this again")
	end

	registerCreatureEvent(cid, "Mail")
	registerCreatureEvent(cid, "GuildMotd")
	registerCreatureEvent(cid, "PlayerDeath")
	return TRUE
end

and at one point in time the loss was set to * 1
 
Have a look in your database, namely the players table. Look for the "loss_experience" column, and check its value.

EDIT:

What the... oO;

LUA:
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 7)
	end

From what i can see, that sets player EXP loss on death to seven times the value of the deathloss you set in config.lua.
This means that player loss is 7 * 7 or 49... aka. 49% of their EXP is lost upon death.
 
Have a look in your database, namely the players table. Look for the "loss_experience" column, and check its value.

EDIT:

What the... oO;

LUA:
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 7)
	end

From what i can see, that sets player EXP loss on death to seven times the value of the deathloss you set in config.lua.
This means that player loss is 7 * 7 or 49... aka. 49% of their EXP is lost upon death.

Yes well, its set to 10 by default on TFS.
 
Back
Top