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

Lua Skill scroll

Relic

Mapper and Scripter
Joined
Feb 26, 2010
Messages
28
Reaction score
1
Location
United States
Hi there. I'm looking for a script for skill scroll that would increase player's skill level by 1.

I've been using this one for a while but the scroll only increases player's skill level by a certain number of tries, which is annoying:

HTML:
local config =  {maxlvl = 80, trys =  1000, skilltype = 2}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerSkill(cid,2) <= config.maxlvl then
        doPlayerAddSkillTry(cid, config.skilltype, config.trys)
        doRemoveItem(item.uid, 1)
        doPlayerSendTextMessage(cid,TALKTYPE_BROADCAST, "CONGRATULATIONS! You've gained ".. config.trys .." skill tries from the skill up scroll!")
    else
        doPlayerSendCancel(cid, "Your skill level is too high.")
    end
  return TRUE
end

Thank you!
 
Code:
local config =  {maxlvl = 80, trys =  1000, skilltype = 2}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerSkill(cid,2) <= config.maxlvl then
        doPlayerAddSkill(cid, config.skilltype, 1)
        doRemoveItem(item.uid, 1)
        doPlayerSendTextMessage(cid,TALKTYPE_BROADCAST, "CONGRATULATIONS! You've gained 1 skill from the skill up scroll!")
    else
        doPlayerSendCancel(cid, "Your skill level is too high.")
    end
  return TRUE
end
 
Tested it and it doesn't work. The skill level increases a little bit but the player doesn't advance (once it gets to 95%, it doesn't increase anymore).

No errors in the console. I'm using TFS 0.3.6.pl1 btw.
 
Okay, I ran some testing and came to this conclusion:

  • It works fine as long as rateSkill is 1(.0)
  • At higher rates the skill tries and rateSkill division results in a decimal number which should be rounded up, but it isn't.

This patch solves the issue: (data/lib/050-function.lua)
Code:
function doPlayerAddSkill(cid, skill, amount, round)
	if(skill == SKILL__LEVEL) then
		return doPlayerAddLevel(cid, amount, round)
	elseif(skill == SKILL__MAGLEVEL) then
		return doPlayerAddMagLevel(cid, amount)
	end

	return doPlayerAddSkillTry(cid, skill, [B][COLOR="Red"]math.ceil([/COLOR][/B](getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill)) / getConfigInfo('rateSkill')[B][COLOR="Red"])[/COLOR][/B])
end

Edit: Now for some reason it doesn't work when calling function doPlayerAddSkill, but works when calling this directly:
Code:
doPlayerAddSkillTry(cid, skill, math.ceil((getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill)) / getConfigInfo('rateSkill')))
 
Last edited:
Code:
local config =  {maxlvl = 80, trys =  1000, skilltype = 2}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerSkillLevel(cid, config.skilltype) <= config.maxlvl then
        doPlayerAddSkillTry(cid, config.skilltype, config.trys)
        doRemoveItem(item.uid, 1)
        doPlayerSendTextMessage(cid,TALKTYPE_BROADCAST, "CONGRATULATIONS! You've gained ".. config.trys .." skill tries from the skill up scroll!")
    else
        doPlayerSendCancel(cid, "Your skill level is too high.")
    end
  return TRUE
end
 
Code:
local config =  {maxlvl = 80, trys =  1000, skilltype = 2}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerSkillLevel(cid, config.skilltype) <= config.maxlvl then
        doPlayerAddSkillTry(cid, config.skilltype, config.trys)
        doRemoveItem(item.uid, 1)
        doPlayerSendTextMessage(cid,TALKTYPE_BROADCAST, "CONGRATULATIONS! You've gained ".. config.trys .." skill tries from the skill up scroll!")
    else
        doPlayerSendCancel(cid, "Your skill level is too high.")
    end
  return TRUE
end
what do you think you're doing?
 
Works better than before but for some reason the skill level gets stuck at 37. My skill rate is 7.

HTML:
local config =  {maxlvl = 80, trys =  1000, skilltype = 3}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerSkill(cid,3) <= config.maxlvl then
        doPlayerAddSkillTry(cid, 3, math.ceil((getPlayerRequiredSkillTries(cid, 3, getPlayerSkillLevel(cid, 3) + 1) - getPlayerSkillTries(cid, 3)) / getConfigInfo('rateSkill')))
        doRemoveItem(item.uid, 1)
        doPlayerSendTextMessage(cid,TALKTYPE_BROADCAST, "CONGRATULATIONS! You've gained 1 axe fighting skill from the skill up badge!")
    else
        doPlayerSendCancel(cid, "Your skill level is too high.")
    end
  return TRUE
end
 
can some one help me and make this add sword,axe,club ??

and make it can only by used 10 times max by knights

local config = {maxlvl = 80, trys = 1000, skilltype = 3}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerSkill(cid,3) <= config.maxlvl then
doPlayerAddSkillTry(cid, 3, math.ceil((getPlayerRequiredSkillTries(cid, 3, getPlayerSkillLevel(cid, 3) + 1) - getPlayerSkillTries(cid, 3)) / getConfigInfo('rateSkill')))
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid,TALKTYPE_BROADCAST, "CONGRATULATIONS! You've gained 1 axe fighting skill from the skill up badge!")
else
doPlayerSendCancel(cid, "Your skill level is too high.")
end
return TRUE
end
 
Back
Top