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

Solved Players not losing equip on death TFS 1.0

arthuraio

Member
Joined
Apr 9, 2015
Messages
123
Reaction score
13
Hello people, I used to be a pro at making OTs in the 7.8 ages... But now I return more noob than ever and I need help, please.

On my OT 10.76 TFS 1.0, players over lvl 8 not "no vocation" are only losing their container upon death... I want then having a 25% chance to drop each one of their equip (helmet 25%, boots 25%, armor 25% etc...) but looks like TFS 1.0 doesn't have the dosetplayerlosspercent blablabla PLAYERLOSS_ITEM function. I am looking into this for like 4 days now to no avail....

Some people says that I have to change it on players.ccp, but where? Other people says to set the function on "login.lua". Other(2) people says to add the funcion on "playerdeath.lua". Anyway, since OTLand is full of master experts, I'd like to ask politely for some assistence into this matter, how can I make player drop equip on death??

function onLogin(cid)
local player = Player(cid)

local loginStr = configManager.getString(configKeys.LOGIN_MSG)
if player:getLastLoginSaved() <= 0 then
loginStr = loginStr .. " Please choose your outfit."
player:sendOutfitWindow()
else
if loginStr ~= "" then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
end

loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
end
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

registerCreatureEvent(cid, "PlayerDeath")
return true
end

local deathListEnabled = true
local maxDeathRecords = 5

function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
local player = Player(cid)

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are dead.")
if player:getStorageValue(cid, 1101) > 0 then
player:setStorageValue(1101, 0)
end

if not deathListEnabled then
return
end

local byPlayer = 0
local killerCreature = Creature(killer)
if killerCreature == nil then
killerName = "field item"
else
if killerCreature:isPlayer() then
byPlayer = 1
else
local master = killerCreature:getMaster()
if master and master ~= killerCreature and master:isPlayer() then
killerCreature = master
byPlayer = 1
end
end
killerName = killerCreature:getName()
end

local byPlayerMostDamage = 0
if mostDamage == 0 then
mostDamageName = "field item"
else
local mostDamageKiller = Creature(mostDamage)
if mostDamageKiller:isPlayer() then
byPlayerMostDamage = 1
else
local master = mostDamageKiller:getMaster()
if master and master ~= mostDamageKiller and master:isPlayer() then
mostDamageKiller = master
byPlayerMostDamage = 1
end
end
mostDamageName = mostDamageKiller:getName()
end

local playerGuid = player:getGuid()
db.query("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) VALUES (" .. playerGuid .. ", " .. os.time() .. ", " .. player:getLevel() .. ", " .. db.escapeString(killerName) .. ", " .. byPlayer .. ", " .. db.escapeString(mostDamageName) .. ", " .. byPlayerMostDamage .. ", " .. unjustified .. ", " .. mostDamage_unjustified .. ")")
local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. playerGuid)

local deathRecords = 0
local tmpResultId = resultId
while tmpResultId ~= false do
tmpResultId = result.next(resultId)
deathRecords = deathRecords + 1
end

if resultId ~= false then
result.free(resultId)
end

while deathRecords > maxDeathRecords do
db.query("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT 1")
deathRecords = deathRecords - 1
end

if byPlayer == 1 then
local playerGuild = player:getGuild()
if playerGuild then
local killerGuild = killerCreature:getGuild()
if playerGuild ~= killerGuild and isInWar(cid, killerCreature) then
local warId = false
resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = " .. killerGuild:getId() .. " AND `guild2` = " .. playerGuild:getId() .. ") OR (`guild1` = " .. playerGuild:getId() .. " AND `guild2` = " .. killerGuild:getId() .. "))")
if resultId ~= false then
warId = result.getDataInt(resultId, "id")
result.free(resultId)
end

if warId ~= false then
db.query("INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (" .. db.escapeString(killerName) .. ", " .. db.escapeString(player:getName()) .. ", " .. killerGuild:getId() .. ", " .. playerGuild:getId() .. ", " .. os.time() .. ", " .. warId .. ")")
end
end
end
end
end

Config.lua just have the percent of exp lost on death, no problem at that. But I want the percent to lose equips.
 
The reason why you don't lose any equipment upon death is because someone altered the uniform_random value in player.cpp. See: https://otland.net/threads/players-dont-loss-eq-when-die.230615/#post-2223824

Tip: Move Player::dropLoot to Lua, and add your own conditions for dropping equipment (Using TFS 1.1 would make this simpler for you, since all you would have to do is modify droploot.lua).
 
Thanks for your reply! I knew that coming here would bring some light.

But about the tip you gave... Changing to TFS1.1 will not crash everything? TFS 1.0 barely have support and alot of tools doesn't work with TFS 1.x, I made so far till now, scripting and map editing... I dont want to start from scratch again...

About move player::dropLoot to lua?? How can I do that? As I said, I am more noob than ever. Sorry for being ignorant.
 
TFS 1.0 barely have support and alot of tools doesn't work with TFS 1.x,
What? TFS has even more tools than in TFS 1.0

Changing to TFS1.1 will not crash everything?
No, if you don't have TOO many scripts then i suggest you to move on to TFS 1.1

Download latest Distro and Data folder.
Then move all your old scripts to new Data folder and register again.
(don't replace entire files, only the scripts and register lines, else you gona have a nice error fest troughout the game, what are easy to fix, but annoyance none the less)

About move player::dropLoot to lua?? How can I do that? As I said, I am more noob than ever. Sorry for being ignorant.
Just going to link you this for now and see how you respond.

https://otland.net/threads/how-to-drop-remove-specific-item-on-player-death.229318/#post-2213649
 
No, if you don't have TOO many scripts then i suggest you to move on to TFS 1.1

I'm not using the TFS itself, my sever is only based on it (to compile), I'm using GLOBAL FULL 10.76 TFS 1.0 [Full Oramond - Cast System] update V10

Do you know about a Global FULL 10.76 tfs 1.1? Nevermind, I tested some important tools for me and the amazing Spell creator spells crashes servers based on 1.1

Just going to link you this for now and see how you respond.

Thanks, I will test it

Edit: doesn't work, it give an error on distro after dying.
 
Last edited:
Back
Top