Galaxy
New Member
Hello,
I have a script that changes your vocation. Almost everything works perfectly but when I change from which ever vocation to which ever vocation, I get an error in my console that says:
Here is my script for vocation change:
And here is my part in 050-function that has something to do with the error. Line 378.
Problem is: it doesn't set my magic level to 5 as it should and also doesn't reset my skills to 10 as it should ;(
I need to solve this problem very fast. I already fixed one problem with this script because it didn't work properly. But I just can't fix this problem ;/ Im not that good at lua as I thought.
Thanks
HUGE EDIT OMG!!! I am so proud of myself... I solved 1 problem...
I changed this line in 050-functions
The blue part is what I added ;D
so I got rid of the error in console...
BUT, the magic level and skills still dont reset as they should. So when changing vocation i do not get 5 maglevel and 10 skills
I have a script that changes your vocation. Almost everything works perfectly but when I change from which ever vocation to which ever vocation, I get an error in my console that says:
Here is my script for vocation change:
Code:
-----------------------CONFIG---START-----------------------------------------
local config = {
removelevel = 1, -- Amount of level taken away.
itemid = 11207, -- Item ID.
efekt = 2, -- Effect shown.
skilafter = 10, -- What skill will the player have after change.
minlevel = 90, -- What will be min level required?
magafter = 5, -- What magic level will he recive after change?
}
-----------------------CONFIG---END-------------------------------------------
function onSay(cid, words, param)
local param, oldVoc = param:lower(), 0
local voc = {
['sorcerer'] = {hp = 5, mana = 30, cap = 10, voc = 1},
['druid'] = {hp = 5, mana = 30, cap = 10, voc = 2},
['paladin'] = {hp = 10, mana = 15, cap = 20, voc = 3},
['knight'] = {hp = 15, mana = 5, cap = 25, voc = 4},
}
if(getPlayerVocation(cid) > 4)then
oldVoc = getPlayerVocation(cid)-4
else
oldVoc = getPlayerVocation(cid)
end
if(voc[param])then
if getPlayerLevel(cid) >= config.minlevel then
if(getPlayerItemCount(cid, config.itemid) > 0)then
if(oldVoc ~= voc[param].voc)then
doPlayerAddLevel(cid, -(config.removelevel)) --Set new level
doPlayerSetVocation(cid, voc[param].voc) --Change vocation
setCreatureMaxHealth(cid, (185+((getPlayerLevel(cid)-8)*voc[param].hp))) --Set new hp
setCreatureMaxMana(cid, (35+((getPlayerLevel(cid)-8)*voc[param].mana))) --Set new mana
doPlayerSetMaxCapacity(cid, (470+((getPlayerLevel(cid)-8)*voc[param].cap))) --Set new cap
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your vocation has been changed to ".. param ..".")
doSendMagicEffect(getCreaturePosition(cid), 2)
doPlayerRemoveItem(cid, config.itemid, 1)
doPlayerAddMagLevel(cid, - ((getPlayerMagLevel(cid)) - config.magafter))
doSendMagicEffect(getCreaturePosition(cid), config.efekt)
doCreatureAddMana(cid, -((getCreatureMana(cid))-(getCreatureMaxMana(cid))))
doCreatureAddHealth(cid, -((getCreatureHealth(cid))-(getCreatureMaxHealth(cid))))
for a = 0,6 do
doPlayerAddSkill(cid, -(getPlayerSkillLevel(cid, a)-config.skilafter))
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You already are a ".. param ..".")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have a ".. getItemNameById(config.itemid) ..".")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to be at least level ".. config.minlevel .." to use this command.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must say what vocation you want to change into, ie !changevoc sorcerer.")
end
return true
end
And here is my part in 050-function that has something to do with the error. Line 378.
Code:
function doPlayerAddMagLevel(cid, amount)
for i = 1, amount do
doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)) / getConfigInfo('rateMagic'))
end
return true
end
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, (getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill)) / getConfigInfo('rateSkill'))
end
Problem is: it doesn't set my magic level to 5 as it should and also doesn't reset my skills to 10 as it should ;(
I need to solve this problem very fast. I already fixed one problem with this script because it didn't work properly. But I just can't fix this problem ;/ Im not that good at lua as I thought.
Thanks
HUGE EDIT OMG!!! I am so proud of myself... I solved 1 problem...
I changed this line in 050-functions
Code:
function doPlayerAddSkill(cid, [COLOR="#0000CD"]a,[/COLOR] skill, amount, round)
so I got rid of the error in console...
BUT, the magic level and skills still dont reset as they should. So when changing vocation i do not get 5 maglevel and 10 skills
Attachments
-
vocationscript.jpg65.1 KB · Views: 17 · VirusTotal
Last edited: