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

Solved Skill Quest error with Knight

juansanchez

Intermediate OT User
Joined
Apr 2, 2015
Messages
217
Reaction score
129
Hey otland people, i need some assistance today with a script i have. I have this script for a quest, which gives the players skills, however i have a problem with Knight, since knights use either axe/sword/club i tried to make it so the quest would give the player the which ever skill is higher, if his club skill is higher than his sword one, he would get the club bonus, and so on... However it didn't work. And i also tried to make is the player would get bonus in all the skill, club/axe/sword. And it also didn't work. Everytime i tried to do something, the player would get only one skill, for example he would only get sword skill, or only axe, no matter what skill he was.

I was wondering if you guys could help me out, even it has to give all the skill, it's fine.

Here's the script:

function onUse(cid, item, frompos, item2, topos)
voc = getPlayerVocation(cid)
pos = getPlayerPosition(cid)
if voc == 5 or voc == 6 or voc == 12 then
stor = getPlayerStorageValue(cid,2357)
if stor == -1 then
setPlayerStorageValue(cid,2357,1)
doPlayerSetMagic(cid, getPlayerMagLevel(cid)+4)
doSendMagicEffect(frompos, 28)
doSendAnimatedText(pos, "Magic Up", TEXTCOLOR_BLUE)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
elseif voc == 7 then
stor = getPlayerStorageValue(cid,2357)
if stor == -1 then
setPlayerStorageValue(cid,2357,1)
doPlayerSetSkill(cid, SKILL_DISTANCE, getPlayerSkillLevel(cid, SKILL_DISTANCE)+12)
doSendMagicEffect(frompos, 28)
doSendAnimatedText(pos, "Distance Up", TEXTCOLOR_BLUE)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
elseif voc == 10 then
stor = getPlayerStorageValue(cid,2357)
if stor == -1 then
setPlayerStorageValue(cid,2357,1)
doPlayerSetSkill(cid, SKILL_CLUB, getPlayerSkillLevel(cid, SKILL_CLUB)+12)
doSendMagicEffect(frompos, 28)
doSendAnimatedText(pos, "Club Up", TEXTCOLOR_BLUE)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
elseif voc == 14 then
stor = getPlayerStorageValue(cid,2357)
if stor == -1 then
setPlayerStorageValue(cid,2357,1)
doPlayerSetSkill(cid, SKILL_FIST, getPlayerSkillLevel(cid, SKILL_FIST)+12)
doSendMagicEffect(frompos, 28)
doSendAnimatedText(pos, "Fist UP", TEXTCOLOR_BLUE)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
elseif voc == 8 then
stor = getPlayerStorageValue(cid,2357)
if stor == -1 then
setPlayerStorageValue(cid,2357,1)
doPlayerSetSkill(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD)+12)
doPlayerSetSkill(cid, SKILL_AXE, getPlayerSkillLevel(cid, SKILL_AXE)+12)
doSendMagicEffect(frompos, 28)
doSendAnimatedText(pos, "Axe e Sword Up", TEXTCOLOR_BLUE)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end

else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
return true
end

I'm using TFS 0.3.7
 
It kind of worked.... However the amount of skill it add it's wrong, for mages it added 9 Magic levels. Knights, added 42 skills '-'
And also, when i right click the chest, the server freezes (i belive is because the amount of skill it adds, if a lot of players click at once will it crash?)
Back to what's important, the only thing wrong is the amount of skills it gives
 
Yea I almost thought that, that is because your function already checks for players actual skill then adds the amount you specify
so right now it adds the players mlv +4 or the players skill +12

change to doPlayerAddSkill(cid, SKILLNAME, +12)
((removing getPlayerSkill(cid, skillname) line))

ps: can you tell me what distro you use and what tibia version you run? I'd just like to know
 
[19:46:27.592] > SAVE: Complete in 1.69 seconds using binary house storage.
[19:46:28.907] [Error - LuaInterface::loadFile] data/actions/scripts/arquivo.lua
:11: unexpected symbol near '+'
[19:46:28.908] [Error - Event::checkScript] Cannot load script (data/actions/scr
ipts/arquivo.lua)
[19:46:28.908] data/actions/scripts/arquivo.lua:11: unexpected symbol near '+'

TFS 0.3.6 Tibia 10.10
 
post the part of script that checks for mage voc and raises mlevel

if pV == 5 or pV == 6 or pV == 12 then
setPlayerStorageValue(cid, 2357, 1)
doPlayerAddMagLevel(cid, MAGIC_LEVEL, 6)
doSendMagicEffect(getPlayerPosition(cid), 28)
doSendAnimatedText(getPlayerPosition(cid), "Magic Up", TEXTCOLOR_BLUE)
 
Before you had:
doPlayerSetMagic(cid, getPlayerMagLevel(cid) + 4)

Now you have:
doPlayerAddMagLevel(cid, MAGIC_LEVEL, 6)

which of the functions exist?
Both maybe?
If yes, is there like a documentation coming with your server that is showing info to these functions?
 
Before you had:
doPlayerSetMagic(cid, getPlayerMagLevel(cid) + 4)

Now you have:
doPlayerAddMagLevel(cid, MAGIC_LEVEL, 6)

which of the functions exist?
Both maybe?
If yes, is there like a documentation coming with your server that is showing info to these functions?

function doPlayerAddMagLevel(cid, amount)

That's the function that exist.

Lib, 050-functions?
 
so right now your line doPlayerAddMagLevel(cid, MAGIC_LEVEL, 6)
it passes wrong parameters, right syntax is:
doPlayerAddMagLevel(cid, amount)
Because your line passes wrong parameters, it takes the default value, which is 1, then adds 1 to your character

change your line to doPlayerAddMagLevel(cid, 6)
that will raise it by 6
 
so right now your line doPlayerAddMagLevel(cid, MAGIC_LEVEL, 6)
it passes wrong parameters, right syntax is:
doPlayerAddMagLevel(cid, amount)
Because your line passes wrong parameters, it takes the default value, which is 1, then adds 1 to your character

change your line to doPlayerAddMagLevel(cid, 6)
that will raise it by 6

Amem! After so long, you did it! It's working Flawlessly.... Thank you soooooooooooooooooooooooooo much, and sorry for all the trouble..
 
Back
Top