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

items gives skill (or magic lvl) forever

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
hii, well like i said on the title, i'm looking for an action that makes a item give skill or magic lvl, for example, i have item id XXXX that when u use it it give you 5 sword skill points forever (or 5 magic levels)
plz guys help me with this :S i serch for it and i didn't found any
 
Enjoy!

XML:
<action itemid="ItemID" event="script" value="skill_scroll.lua"/>

Lua:
local add_skill,amount = SKILL_SWORD,1 --Edit skill name Ex: SKILL_CLUB,1 = that means amount so, it add now 1 sword fighting.
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	doPlayerAddSkill(cid, add_skill, amount)
	doSendMagicEffect(getThingPos(cid),math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
	doCreatureSay(cid, "SKILL UP!", TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
end
 
damn i gave you rep with the problem before :S
You must spread some Reputation around before giving it to Printer again.
 
Try this:
Lua:
doPlayerAddSkillTry(cid,skillid,amount)

I think on amount you need add 100 which equal 1 skill level.
 
I answered Trolle question, since the script i gave you dont work with 0.2, im pretty sure you use 0.3?
 
yes i do

- - - Updated - - -

so what do i have to do now? D: if there are any changes to do to that script, could you edit the script for me plz?? :/ i don't wanna mess it up
 
It doesn't matter if you mess it up, you will only learn from it. It's always good to try it yourself first and if you are unable to get it right, you can show what you tried and people can explain or show what you did wrong.
 
Ok thanks for the advice limos, i edit it and this is what i got, but is not working, it give 4 (not 3) first skills (not sword)
Lua:
local add_skill,amount = SKILL_SWORD,3 --Edit skill name Ex: SKILL_CLUB,1 = that means amount so, it add now 1 sword fighting.
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	doPlayerAddSkillTry(cid,skillid,amount)
	doSendMagicEffect(getThingPos(cid),math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
	doCreatureSay(cid, "SKILL UP!", TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
end
:(
 
You can use doPlayerAddSkill(cid, add_skill, amount) like Printer posted.
Btw, also add return true above the end, so you won't get the "You cannot use this object" message.
 
now it says skill up but no skill grew :/

Lua:
local add_skill,amount = SKILL_SWORD,3 --Edit skill name Ex: SKILL_CLUB,1 = that means amount so, it add now 1 sword fighting.
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	doPlayerAddSkill(cid,skillid,amount)
	doSendMagicEffect(getThingPos(cid),math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
	doCreatureSay(cid, "SKILL UP!", TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
return true
end
 
Last edited:
I'm droping my try with the 0.2.~ distro. It works for lower number skills, like 10-50~. After the 50~ skill the number of tries you need to advance to the next level become so big that it's converted to a 5e+49 number format.
If anyone could come up with a smart solution for this I would appreciate it. :)

Code:
dofile("./config.lua")

local function addSkill(cid, vocationFactor, skillid, skillAmount)
	for i = 1, skillAmount do
		[COLOR="#B22222"]local triesToNextAdvance = (50*math.pow(vocationFactor, (getPlayerSkill(cid, skillid)-10))) / rateSkill[/COLOR]
		doPlayerAddSkillTry(cid, skillid, triesToNextAdvance)
	end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have gained " .. skillAmount .. " fist fighting skills!")
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local voc = getPlayerVocation(cid)
	
	if voc == 1 or voc == 5 or voc == 0 then -- sorc or rookgaardians
		addSkill(cid, 1.5, SKILL_FIST, 1)
	elseif voc == 2 or voc == 6 then -- druid
		addSkill(cid, 1.5, SKILL_FIST, 1)
	elseif voc == 3 or voc == 7 then -- paladin
		addSkill(cid, 1.2, SKILL_FIST, 1)
	elseif voc == 4 or voc == 8 then -- knight
		addSkill(cid, 1.1, SKILL_FIST, 1)
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you are not ready to use this item yet.")
	end
	return TRUE
end
 
You can also do it like this.
Lua:
local skill, amount = SKILL_SWORD, 3 --Edit skill name Ex: SKILL_CLUB,1 = that means amount so, it add now 1 sword fighting.
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	for i = 1, amount do
		doPlayerAddSkillTry(cid, skill, (getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill)), false)
	end
	doSendMagicEffect(getThingPos(cid),math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
	doCreatureSay(cid, "SKILL UP!", TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
	return true
end
 
well now a new problem showed up :/ when i axe the SWORD for AXE doesn't work, it keeps giving sword skill, i haven't tried with MAGIC or DEFENSE or others, but i guess they don't work too, here is the AXE i edited:

Lua:
local skill, amount = SKILL_AXE, 3 --Edit skill name Ex: SKILL_CLUB,1 = that means amount so, it add now 1 axe fighting.
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	for i = 1, amount do
		doPlayerAddSkillTry(cid, skill, (getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill)), false)
	end
	doSendMagicEffect(getThingPos(cid),math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
	doCreatureSay(cid, "SKILL UP!", TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
	return true
end
 
Did you reload actions after you changed to AXE? :p

-45qhI.png
 
:p of course

- - - Updated - - -

so works fine for you? :/

- - - Updated - - -

ooooh i found the error, it was on actions.xml, thanks man :p

- - - Updated - - -

Hey and what should i put if i want this with magic? i tried MAGIC, LEVELMAGIC and MAGICLEVEL, i'm running out of ideas haha D:
 
Back
Top