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

Amulet Of Loss

Ratser

Retired // Making time for yoloswagmod
Joined
Feb 11, 2009
Messages
482
Reaction score
36
I have a problem with the Amulet Of Loss, it disappears when dying but doesn't protect the player from losing items. I am using TFS 0.3.4 (Crying Damson). Here are the files playerdeath.lua and items.xml

data\creaturescripts\scripts\playerdeath.lua:
PHP:
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

data\items\items.xml:
PHP:
	<item id="2173" article="an" name="amulet of loss">
		<attribute key="weight" value="420"/>
		<attribute key="slotType" value="necklace"/>
		<attribute key="preventDrop" value="1"/>
	</item>
 
Last edited:
Replace this here in items.xml:
Code:
<attribute key="preventDrop" value="1"/>

with this:
Code:
<attribute key="preventLoss" value="1"/>

:D hope that works for ya
 
in tfs 0.3.4 the aol dont work use the blessing system when player buy blessing they wont lose exp and items like rl tibia.
 
Ok I think I somehow fixed it because everybody in my OT says it works now. So anyways thank you for taking the time to help me.
 
For tfs 0.3.4:

Code:
	<item id="2173" article="an" name="amulet of loss">
		<attribute key="weight" value="420"/>
		<attribute key="slotType" value="necklace"/>
		<attribute key="charges" value="1"/>
		<attribute key="preventDrop" value="1"/>
	</item>

Rep++ if i helped =D.
 
Well, better late than never.

For TFS 0.3.5+

On playerdeath.lua:
Code:
if getPlayerSlotItem(cid, 2).itemid == 2173 then
doPlayerRemoveItem(cid, 2173, 1)
end
just before
Code:
if(config.deathListEnabled ~= TRUE) then
		return
	end

On items.xml:
Code:
	<item id="2173" article="an" name="amulet of loss">
		<attribute key="weight" value="420" />
		<attribute key="slotType" value="necklace" />
		<attribute key="charges" value="1" />
		<attribute key="preventDrop" value="1"/>
	</item>

And there it is...SOLVED.
 
Last edited:
Back
Top