• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Magic level scroll

ghettobird

LUA newbie
Joined
Aug 17, 2013
Messages
679
Reaction score
132
Location
OTland
Hey otlanders, i'm sorry if i'm making too much threads but i'm just excited that i understand how scripting is now, at first i looked at this and said "oh crap that's one language i'll never understand" :p anyways i hope you will like it :)

Lua:
local add_skill,amount = SKILL_MAGIC,1 
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
        doPlayerAddSkill(cid, add_magicl, 1)
	doCreatureSay(cid, "MAGIC LEVEL UP", TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
end

PS: i'm not sure if it will work i didn't have any time to test it cus i can't download any more files (i'm on my old laptop so not much space) so i can't download uniserv to test it :( sorry

post bugs here! :peace:
 
Last edited:
That will just send a message and remove the item. ^_^
 
You removed the part of adding skill:
Lua:
doPlayerAddSkill(cid, add_skill, amount)
 
Lua:
doPlayerAddSkill(cid, skill[, amount = 1[, round = false]])
doPlayerAddMagLevel(cid[, amount = 1])
 
i need one like that but i need it add the magic level for some time and the magic level is back to normal after that time

i need it to add like 10 ml
thx
 
i need one like that but i need it add the magic level for some time and the magic level is back to normal after that time

i need it to add like 10 ml
thx

Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SUBID, 3)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	doAddCondition(cid, condition)
	doRemoveItem(item.uid)
	return true
end
 
Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SUBID, 3)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	doAddCondition(cid, condition)
	doRemoveItem(item.uid)
	return true
end

I need his script work only in sorcerers, druids and paladin. Not Knight.
 
Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SUBID, 3)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)

if playerVoc == 1 or 2 then
function onUse(cid, item, fromPosition, itemEx, toPosition)
	doAddCondition(cid, condition)
	doRemoveItem(item.uid)
		end
	return true
end

ps: not sure if it will work
 
Doesn't non-promoted & promoted vocations have different IDs? Just use

Lua:
if (not isKnight(cid)) then
--proceed
end
 
in lua functions :-
Lua:
if playerVoc == 1 then --If Vocation is Sorcerer or Master Sorcerer
 
in lua functions :-
Lua:
if playerVoc == 1 then --If Vocation is Sorcerer or Master Sorcerer


XML:
	<vocation id="1" clientId="3" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="3" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>

	<vocation id="5" clientId="3" name="Master Sorcerer" description="a master sorcerer" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="2" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>


and playerVoc isn't declared anywhere in your code.
 
if playerVoc == 1 or 2 then

Lua:
local playerVoc = getPlayerVocation(cid)
if (playerVoc == 1) or (playerVoc == 2) then

playerVoc is nil
it checks if 2 is true, which it is, so it'll proceed either way.
 
Last edited:
Lua:
local add_skill,amount = SKILL_MAGIC,1 
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
        doPlayerAddSkill(cid, add_magicl, 1)
	doCreatureSay(cid, "MAGIC LEVEL UP", TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
end
you have a problem with this.

read the word u declared you said

Lua:
local add_skill,amount = SKILL_MAGIC,1
this means: When I say add_skill you should write SKILL_MAGIC and when I say amount you should write 1

in the script u wrote

Lua:
doPlayerAddSkill(cid, add_magicl, 1)
you never said when I write add_magicl write ~~~ you wrote add_skill in the local so it should be

Lua:
doPlayerAddSkill(cid, add_skill, 1)
and why u wrote doPlayerAddSkill(cid, add_magicl, [1]) when u already said when I say amount write 1 you should use amount here and if u will not use it then why u wrote local amount = 1? It should be written there to help people change it easily I know but if it will never be used in the script it will not change anything :)

Use:

Lua:
doPlayerAddSkill(cid, add_skill, amount)
full script

Lua:
local add_skill,amount = SKILL_MAGIC,1 
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
        doPlayerAddSkill(cid, add_skill, amount)
	doCreatureSay(cid, "MAGIC LEVEL UP", TALKTYPE_ORANGE_1)
	doRemoveItem(item.uid, 1)
end

If u understood this then you should understand that playerVoc will never work if you didn't tell LUA to write getPlayerVocation(cid) when u say playerVoc when coded it will be

Lua:
local playerVoc = getPlayerVocation(cid)

Hint: Btw, for me I would better use this script to add magic lvl

Lua:
local amount = 1 
function onUse(cid, item, fromPosition, itemEx, toPosition)
        doPlayerAddMagLevel(cid, amount)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "MAGIC LEVEL UP")
	doRemoveItem(item.uid, 1)
end
 
Last edited:
Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SUBID, 3)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)

if playerVoc == 1 or 2 then
function onUse(cid, item, fromPosition, itemEx, toPosition)
	doAddCondition(cid, condition)
	doRemoveItem(item.uid)
		end
	return true
end

ps: not sure if it will work

playerVoc is nil, 2 is true, if statement is outside the function while end is inside.

Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SUBID, 3)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(isKnight(cid)) then
		doAddCondition(cid, condition)
		doRemoveItem(item.uid)
	end
	return true
end

Btw. download a Notepad++ v6.4.5 - Current Version. It will surely help you.
 
playerVoc is nil, 2 is true, if statement is outside the function while end is inside.

Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SUBID, 3)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(isKnight(cid)) then
		doAddCondition(cid, condition)
		doRemoveItem(item.uid)
	end
	return true
end

Btw. download a Notepad++ v6.4.5 - Current Version. It will surely help you.

I've already pointed that out and he wanted it to work for all vocs but knights :p
 
Back
Top