• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Players with the promotion lose less experience after death and promotion item

Sorbal

Member
Joined
Jul 23, 2010
Messages
406
Reaction score
11
Location
Poland
Hello Otlanders. I have to You request, can someone write me a script so that players with the promotion will lose about 50% less experience after death (I don't wants to edit sources <_<). The second script is a request for item (id 6546). After clicking on the item with id 6546 player receives promotion. Naturally for help i'll Rep+ You.
 
Deathloss percent; Dont got enough time to do you the item sorry.

LUA:
function onLogin(cid)
local PromotionLossPercent = 5 -- Promotion deathloss percent.
local NonLossPercent = 10 -- No promotion death loss percent.

if getPlayerPromotionLevel(cid) == 1 then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * PromotionLossPercent)
	elseif getPlayerPromotionLevel(cid) ~= 0 then
			doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * NonLossPercent)
		end
		return true
		end
 
iten:
LUA:
local prv = getPromotedVocation(getPlayerVocation(cid))
function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid, 7813) ~= 1 then
          doPlayerSetVocation(cid, prv)
          setPlayerStorageValue(cid, 7813, 1)
            else
          doPlayerSendCancel(cid, "You are already promoted")
       end
return TRUE
end
 
Thanks for your help, but..
@Bogart
While i use promotion item i get this error in console:
[02/09/2011 13:55:03] [Warning - Vocations::getVocation] Vocation 4294967295 not found.
And if i look on myself in game i can see:
You see yourself. You are .
And if you can, please add doRemoveItem :). Thanks.

@Optus
I dunno what i need to write in creaturescripts.xml, i wrote this:
<event type="login" name="PromotionDead" event="script" value="promotiondead.lua"/>
and next time this:
<event type="death" name="PromotionDead" event="script" value="promotiondead.lua"/>
and its not working :( help please.
 
LUA:
	<event type="login" name="PromotionDead" event="script" value="promotiondead.lua"/>


in login.lua creaturescripts/scripts:
LUA:
	registerCreatureEvent(cid, "PromotionDead")

try this one:
LUA:
function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid, 7813) ~= 1 then
		doPlayerSetPromotionLevel(cid, 1)
          setPlayerStorageValue(cid, 7813, 1)
		  doRemoveItem(cid, uid)
            else
          doPlayerSendCancel(cid, "You are already promoted")
       end
return TRUE
end
 
Last edited:
Thanks for quick answer but when i use promotion item that gives me promotion but don't disapear. And after death i can't login on promoted character:
[02/09/2011 14:50:42] [Error - CreatureScript Interface]
[02/09/2011 14:50:42] data/creaturescripts/scripts/promotiondead.lua:onLogin
[02/09/2011 14:50:42] Description:
[02/09/2011 14:50:42] data/creaturescripts/scripts/promotiondead.lua:6: attempt to perform arithmetic on global 'loss' (a nil value)
[02/09/2011 14:50:42] stack traceback:
[02/09/2011 14:50:42] data/creaturescripts/scripts/promotiondead.lua:6: in function <data/creaturescripts/scripts/promotiondead.lua:1>
[02/09/2011 14:50:42] Promotion Test has logged out.

And on item use:
[02/09/2011 14:49:55] [Error - Action Interface]
[02/09/2011 14:49:55] data/actions/scripts/other/promotionitem.lua:onUse
[02/09/2011 14:49:55] Description:
[02/09/2011 14:49:55] (luaDoRemoveItem) Item not found
But i replaced it with doRemoveItem(item.uid, 1) and it works - item disapear and character get promoted.
 
Change it to this i had found an error, this should work.
LUA:
function onLogin(cid)
local PromotionLossPercent = 5 -- Promotion deathloss percent.
local NonLossPercent = 10 -- No promotion death loss percent.
 
if getPlayerPromotionLevel(cid) == 1 then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, PromotionLossPercent)
	elseif getPlayerPromotionLevel(cid) ~= 0 then
			doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, NonLossPercent)
		end
		return true
		end
 
Okey, i don't have errors in console :) but when promoted player die, he get downgraded to level 1. Can you fix it? I did not write about this before - Im using TFS 0.3.6.
 
LUA:
function onLogin(cid)
local PromotionLossPercent = 5 -- Promotion deathloss percent.
local NonLossPercent = 10 -- No promotion death loss percent.
local loss = getConfigValue('deathLostPercent')
 
if getPlayerPromotionLevel(cid) == 1 and (loss == nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, PromotionLossPercent)
	elseif getPlayerPromotionLevel(cid) == 0 and (loss == nil) then
			doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, NonLossPercent)
		end
		return true
		end

In config.lua Find DeathLostPercent = and make it 0
 
Now non promoted player doesn't loss experience after death and while promoted player were downgraded to level 1. I check something and i found this - when non promoted character buy promotion from King (Like real tibia) he can still use PromotionItem.
 
LUA:
function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid, 7813) ~= 1 then
		doPlayerSetPromotionLevel(cid, 1)
          setPlayerStorageValue(cid, 7813, 1)
		  doRemoveItem(cid, uid, 1)
            elseif getPlayerPromotionLevel(cid, 1) then
          doPlayerSendCancel(cid, "You are already promoted")
       end
return TRUE
end


With the Deathloss percent ill have to investigate sorry i dont know the problem :(
 
LUA:
function onLogin(cid)
local PromotionLossPercent = 5 -- Promotion deathloss percent.
local NonLossPercent = 10 -- No promotion death loss percent.
local loss = getConfigValue('deathLostPercent')
 
if getPlayerPromotionLevel(cid) == 1 and (loss == nil) then
for i = 0, 4 do		
doPlayerSetLossPercent(cid, i, PromotionLossPercent)
	elseif getPlayerPromotionLevel(cid) == 0 and (loss == nil) then
for i = 0, 4 do
		doPlayerSetLossPercent(cid, i, NonLossPercent)
		end
		return true
		end

Try this one

edit: sorry accidentally double posted.
 
Last edited:
LUA:
function onUse(cid, item, frompos, item2, topos)
    if (getPlayerPromotionLevel(cid) == 0) then
        doPlayerSetPromotionLevel(cid, 1)
		doRemoveItem(item.uid, 1)
    else
		doPlayerSendCancel(cid, "You are already promoted")
    end
	return true
end
That's Bogart's script, hopefully it'll work fine now.
 
No problem, i can delete the king :). Error in console while turning on the server. Non promoted character doesn't loss experience after death and promoted were downgraded to 1 lvl :/. :
[02/09/2011 15:42:59] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/promotiondead.lua:9: 'end' expected (to close 'for' at line 7) near 'elseif'
[02/09/2011 15:42:59] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/promotiondead.lua)
[02/09/2011 15:42:59] data/creaturescripts/scripts/promotiondead.lua:9: 'end' expected (to close 'for' at line 7) near 'elseif'
I see that You really are trying to help me and i respect Your work, for which I thank you very much, but this promotion may be impossible without editing the source?
 
No problem, i can delete the king :). Error in console while turning on the server. Non promoted character doesn't loss experience after death and promoted were downgraded to 1 lvl :/. :

I see that You really are trying to help me and i respect Your work, for which I thank you very much, but this promotion may be impossible without editing the source?

LUA:
local PromotionLossPercent = 5 -- Promotion deathloss percent.
local NonLossPercent = 10 -- No promotion death loss percent.
local loss = getConfigValue('deathLostPercent')
 
function onLogin(cid)
	if getPlayerPromotionLevel(cid) == 1 and (loss == 0) then
		for i = 0, 4 do		
			doPlayerSetLossPercent(cid, i, PromotionLossPercent)
		end
	elseif getPlayerPromotionLevel(cid) == 0 and (loss == 0) then
		for i = 0, 4 do
			doPlayerSetLossPercent(cid, i, NonLossPercent)
		end
	end
	return true
end
Note to Optus: "for" statements also need an "end" ;).
 
Okey, so item problem is solved. Thanks all for help :). Now time to deathloss, when i use this script:
local PromotionLossPercent = 5 -- Promotion deathloss percent.
local NonLossPercent = 10 -- No promotion death loss percent.
local loss = getConfigValue('deathLostPercent')

function onLogin(cid)
if getPlayerPromotionLevel(cid) == 1 and (loss == 0) then
for i = 0, 4 do
doPlayerSetLossPercent(cid, i, PromotionLossPercent)
end
elseif getPlayerPromotionLevel(cid) == 0 and (loss == 0) then
for i = 0, 4 do
doPlayerSetLossPercent(cid, i, NonLossPercent)
end
end
return true
end
Non promoted losses 5% of his experience -- as the scrips says, they need to lose 10% :/
Promoted players were downgraded to level 1. They need to lose 5% and Here is no errors in console.
 
Last edited:
Ok try this, remove the script for the promotion loss experience, and config set the DeathLostPercent to DeathLostPercent = 10
Then remove, registerCreatureEvent for the script.

The go to xml/vocations.xml and for non promoted vocations (eg. druid)

remove the line

LUA:
lessloss="">

and for promoted vocations (eg. elder druid) put
LUA:
lessloss="50">


This should hopefully work.
 
open login.lua
search for this line
Code:
local loss = getConfigValue('deathLostPercent')
change this
Code:
function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
	end
to this
Code:
local edit = 5 -- lose precent
function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil and not getPlayerPromotionLevel(cid) ~= 1) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
	else
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * edit)
	end

here you are promotion script
Code:
function onUse(cid, item, frompos, item2, topos)
local k = getPlayerPromotionLevel(cid)
	if k ~= 1 then
		doPlayerSetPromotionLevel(cid, 1)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "you have been promoted")
	else
		doPlayerSendCancel(cid,"you already promoted")
		end
	return true
end
 
Thank you Optus for your time to help me, now I can not give You a reputation - "You must spread some Reputation around before giving it to Optus again." But I do not forget about it, and I'll give it to You as soon as I can. Editing vocations.xml works perfectly :)! Greetings.
 
Thank you Optus for your time to help me, now I can not give You a reputation - "You must spread some Reputation around before giving it to Optus again." But I do not forget about it, and I'll give it to You as soon as I can. Editing vocations.xml works perfectly :)! Greetings.

No problem, I try my best to help everybody im glad it worked for you :)
 
Back
Top