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!
 

Grehy

Killroy
Joined
Nov 21, 2008
Messages
2,627
Reaction score
29
Location
United States
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
 
OP
R

Relic

Mapper and Scripter
Joined
Feb 26, 2010
Messages
28
Reaction score
1
Location
United States
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.
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,897
Reaction score
805
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:

Fallen

Freelancer
Joined
Aug 21, 2009
Messages
3,714
Reaction score
245
Location
Egypt
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
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,897
Reaction score
805
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?
 
OP
R

Relic

Mapper and Scripter
Joined
Feb 26, 2010
Messages
28
Reaction score
1
Location
United States
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
 

Wartio

Any game ideas?
Joined
Apr 2, 2010
Messages
459
Reaction score
13
Location
Sweden
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
 
Top