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

Lower deathloss for certain voc

You could probably do said thing with an onPrepareDeath creaturescript that before death sets different deathloss depending on what vocation you are and then lets you die.
 
HTML:
dofile("./config.lua")

function onDeath(cid, corpse, killer)
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
	if deathListEnabled == "yes" then
		if sqlType == "mysql" then
			env = assert(luasql.mysql())
			con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
		else -- sqlite
			env = assert(luasql.sqlite3())
			con = assert(env:connect(sqliteDatabase))
		end
		local byPlayer = FALSE
		if killer == FALSE then
			killerName = "field item"
		else
			if isPlayer(killer) == TRUE then
				byPlayer = TRUE
			end
			killerName = getCreatureName(killer)
		end
		assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. escapeString(killerName) .. "', " .. byPlayer .. ");"))
		local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";"))
		local deathRecords = numRows(cursor)
		if sqlType == "mysql" then
			while deathRecords > maxDeathRecords do
				delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1;"))
				deathRecords = deathRecords - 1
			end
		else
			while deathRecords > maxDeathRecords do
				delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);"))
				deathRecords = deathRecords - 1
			end
		end			
		con:close()
		env:close()
	end
end

Hmm. Anyideas where I can add the different xp?
 
And in my players table there's a key "loss_experience":
Code:
`loss_experience` int(11) NOT NULL default '10' COMMENT 'NOT IN USE BY THE SERVER',

Why it say not in use by the server?
 
Not onDeath, onPreparedeath...


EDIT:

Whipped up a lil thing for ya...

LUA:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
		
	local exploss = {
		[1] = 50,	-- Sorcerer
		[2] = 50,	-- Druid
		[3] = 50,	-- Paladin
		[4] = 50	-- Knight
	}
		
		
		local voc = getPlayerVocation(cid)
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, exploss.voc)
		return TRUE
end
 
Last edited:
Back
Top