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

Script help

Joined
Jun 19, 2009
Messages
1,852
Reaction score
5
Hello!

I tried to add this:

Code:
			[7720] = {SKILL__MAGLEVEL, 150}

in this script:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Skill scroll" enabled="yes">
	<action itemid="9004;5958;5956;7696" event="script"><![CDATA[
		local t = {
			[9004] = {SKILL_CLUB, 150},
			[5958] = {SKILL_SWORD, 150},
			[5956] = {SKILL_AXE, 150},
			[7696] = {SKILL_DISTANCE, 150}
		}
		function onUse(cid, item, fromPosition, itemEx, toPosition)
			local v = t[item.itemid]
			if getPlayerSkillLevel(cid, v[1]) < v[2] then
				doPlayerAddSkill(cid, v[1], 1, true)
				doRemoveItem(item.uid, 1)
			else
				doCreatureSay(cid, "You can only use this if your " .. SKILL_NAMES[v[1]] .. " skill is lower than " .. v[2], TALKTYPE_ORANGE_1, false, cid)
			end
			return true
		end
	]]></action>
</mod>

But it doesn't work. Could someone fix it for me? I want if you click on X item, you get +1 magic level, however, only druids or sorceres BELOW mag lvl 150 can use it.
 
try this;
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Skill scroll" enabled="yes">
	<action itemid="9004; 5958; 5956; 7696" event="buffer"><![CDATA[
		local t = {
			[9004] = {1, 150},
			[5958] = {2, 150},
			[5956] = {3, 150},
			[7696] = {4, 150}
		}
		local v = t[item.itemid]
		if getPlayerSkillLevel(cid, v[1]) < v[2] then
			doPlayerAddSkill(cid, 1)
			doRemoveItem(item.itemid, 1)
		else
			doCreatureSay(cid, "You can only use this if your " .. (v[1] == 1 and "club" or v[1] == 2 and "sword" or v[1] == 3 and "axe" or v[1] == 4 and "distance") .. " skill is lower than " .. v[2], TALKTYPE_ORANGE_1, false, cid)
		end
		return true
	]]></action>
</mod>
 
That's not what I meant...
Did you even read his request? He wants to add MAGIC LEVELS.

And it has to be
Code:
doPlayerAddSkill(cid, v[1], 1)

Or else, how would it know which one to add?
 
Code:
db.executeQuery("UPDATE `players` SET `maglevel` = `maglevel` + 2 WHERE `id` = " .. getPlayerGUID(cid) .. ";")
 
Last edited:
This should work...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Skill scroll" enabled="yes">
	<action itemid="9004;5958;5956;7696;7720" event="script"><![CDATA[
		local t = {
			[9004] = {SKILL_CLUB, 150},
			[5958] = {SKILL_SWORD, 150},
			[5956] = {SKILL_AXE, 150},
			[7696] = {SKILL_DISTANCE, 150},
			[7720] = {SKILL__MAGLEVEL, 150}
		}
		function onUse(cid, item, fromPosition, itemEx, toPosition)
			local v = t[item.itemid]
			return getPlayerSkillLevel(cid, v[1]) < v[2] and doPlayerAddSkill(cid, v[1], 1, true) and doRemoveItem(item.uid, 1) or getPlayerSkillLevel(cid, v[1]) >= v[2] and doCreatureSay(cid, "You can only use this if your " .. SKILL_NAMES[v[1]] .. " skill is lower than " .. v[2], TALKTYPE_ORANGE_1, false, cid)
		end
	]]></action>
</mod>

Another way...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Skill scroll" enabled="yes">
	<action itemid="9004;5958;5956;7696;7720" event="script"><![CDATA[
		local t = {
			[9004] = {SKILL_CLUB, 1, 150},
			[5958] = {SKILL_SWORD, 1, 150},
			[5956] = {SKILL_AXE, 1, 150},
			[7696] = {SKILL_DISTANCE, 1, 150},
			[7720] = {SKILL__MAGLEVEL, 1, 150}
		}
		function onUse(cid, item, fromPosition, itemEx, toPosition)
			local v = t[item.itemid]
			return getPlayerSkillLevel(cid, v[1]) < v[3] and doPlayerAddSkill(cid, v[1], v[2], true) and doRemoveItem(item.uid, 1) or getPlayerSkillLevel(cid, v[1]) >= v[3] and doCreatureSay(cid, "You can only use this if your " .. SKILL_NAMES[v[1]] .. " skill is lower than " .. v[3], TALKTYPE_ORANGE_1, false, cid)
		end
	]]></action>
</mod>
 
Last edited:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Skill scroll" enabled="yes">
	<action itemid="9004;5958;5956;7696" event="script"><![CDATA[
		local t = {
			[9004] = {SKILL_CLUB, 150},
			[5958] = {SKILL_SWORD, 150},
			[5956] = {SKILL_AXE, 150},
			[7696] = {SKILL_DISTANCE, 150},
			[7720] = {SKILL__MAGLEVEL, 150},
		}
		function onUse(cid, item, fromPosition, itemEx, toPosition)
			local v = t[item.itemid]
			if (v[1] == SKILL__MAGLEVEL and getPlayerMagLevel(cid, true) < v[2]) or getPlayerSkillLevel(cid, v[1]) < v[2] then
				doPlayerAddSkill(cid, v[1], 1, true)
				doRemoveItem(item.uid, 1)
			else
				doCreatureSay(cid, 'You can only use this if your ' .. SKILL_NAMES[v[1]] .. (v[1] == SKILL__MAGLEVEL and '' or ' skill') .. ' is lower than ' .. v[2], TALKTYPE_ORANGE_1, false, cid)
			end
			return true
		end
	]]></action>
</mod>
 
Hmm, it works~ but you don't get 1 magic level.

Example:

Right now, I have 0 in magic level. When using the scroll, I still have 0 mag lvl BUT with 99% left to 1.

Oh, and you can't use it more than once, if you do it, you won't even get 1%.
 
Edit this function in 050-function.lua:
Code:
function doPlayerAddMagLevel(cid, amount)
	for i = 1, amount do
		doPlayerAddSpentMana(cid, math.ceil((getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)) / getConfigInfo('rateMagic')))
	end
	return true
end
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Skill scroll" enabled="yes">
	<action itemid="9004;5958;5956;7696" event="script"><![CDATA[
		local t = {
			[9004] = {SKILL_CLUB, 150},
			[5958] = {SKILL_SWORD, 150},
			[5956] = {SKILL_AXE, 150},
			[7696] = {SKILL_DISTANCE, 150},
			[7720] = {SKILL__MAGLEVEL, 150, [B][COLOR="Red"]{1, 2, 5, 6, 9, 10}[/COLOR][/B]},
		}
		function onUse(cid, item, fromPosition, itemEx, toPosition)
			local v = t[item.itemid]
			if not v[3] or isInArray(v[3], getPlayerVocation(cid)) then
				if (v[1] == SKILL__MAGLEVEL and getPlayerMagLevel(cid, true) < v[2]) or getPlayerSkillLevel(cid, v[1]) < v[2] then
					doPlayerAddSkill(cid, v[1], 1, true)
					doRemoveItem(item.uid, 1)
				else
					doCreatureSay(cid, 'You can only use this if your ' .. SKILL_NAMES[v[1]] .. (v[1] == SKILL__MAGLEVEL and '' or ' skill') .. ' is lower than ' .. v[2], TALKTYPE_ORANGE_1, false, cid)
				end
			else
				doCreatureSay(cid, 'You don\'t have the required vocation', TALKTYPE_ORANGE_1, false, cid)
			end
			return true
		end
	]]></action>
</mod>
 
Back
Top