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

Unexplainable script/function results.

Michael Orsino

Premium User
Premium User
Support Team
Joined
Nov 15, 2007
Messages
854
Solutions
10
Reaction score
389
Location
Santiago, Chile (Australian)
I have this script that myself and another wrote, as far as I can see it should work 100%, but it does not. In fact, it has given different results depending on the COMPUTER it was used on. I don't get it. Maybe you guys will.
I will post all the information I can gather.

Okay here we go.
Read this script, looks fine to me, should work.
Code:
function onLogin(cid)
local playerVoc = getPlayerVocation(cid)
local reqTries = getPlayerRequiredSkillTries
local skillStor = 56364
local gotSkills = getPlayerStorageValue(cid, 56364)

if playerVoc == 5 and gotSkills == -1 then
doPlayerAddMagLevel(cid, 60)
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 6 and gotSkills == -1 then
doPlayerAddMagLevel(cid, 60)
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 7 and gotSkills == -1 then
doPlayerAddSkillTry(cid, SKILL_DISTANCE, reqTries(cid, SKILL_DISTANCE, 80))
doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 80))
doPlayerAddMagLevel(cid, 15)
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 8 and gotSkills == -1 then
doPlayerAddSkillTry(cid, SKILL_AXE, reqTries(cid, SKILL_AXE, 80))
doPlayerAddSkillTry(cid, SKILL_SWORD, reqTries(cid, SKILL_SWORD, 80))
doPlayerAddSkillTry(cid, SKILL_CLUB, reqTries(cid, SKILL_CLUB, 80))
doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 80))
doPlayerAddMagLevel(cid, 8)
setPlayerStorageValue(cid, skillStor, 1)

end
return TRUE
end
So, after reading that, what conclusions can we draw?
Sorcerer's and Druid's are given magic level 60.
Paladins are given magic level 15 and 80/80 (Or just over, taking into account the 10 skill you start with)
Knights are given magic level 8, and 80 in all combat and shielding.

Funny thing is, the script gives different results on each computer I run it on. Ive had vocations getting an extra 2 magic levels, one less skill, one extra skill. Not to mention magic level for the mages just doesn't work at all almost, giving results like 5 or 6.

This lead me to write another script, this one works. Works differently for every computer, but whatever, it works.

Code:
function onLogin(cid)
local playerVoc = getPlayerVocation(cid)
local reqTries = getPlayerRequiredSkillTries
local skillStor = 56364
local gotSkills = getPlayerStorageValue(cid, 56364)


if playerVoc == 5 and gotSkills == -1 then
doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,60)))
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 6 and gotSkills == -1 then
doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,60)))
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 7 and gotSkills == -1 then
doPlayerAddSkillTry(cid, SKILL_DISTANCE, reqTries(cid, SKILL_DISTANCE, 80))
doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 80))
doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,13)))
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 8 and gotSkills == -1 then
doPlayerAddSkillTry(cid, SKILL_AXE, reqTries(cid, SKILL_AXE, 80))
doPlayerAddSkillTry(cid, SKILL_SWORD, reqTries(cid, SKILL_SWORD, 80))
doPlayerAddSkillTry(cid, SKILL_CLUB, reqTries(cid, SKILL_CLUB, 80))
doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 80))
doPlayerAddMagLevel(cid, 8)
setPlayerStorageValue(cid, skillStor, 1)

end
return TRUE
end
With this script
Mages get magic level 60, but only once they are wearing all the equipment they start with. (say it starts with focus cape, spellbook and hat of the mad, once they are all equiped the mage will have the set magic level.)
Paladins get magic level 15, which is odd considering they are set to get magic level 13. I have had varied results with the skills on a paladin, never 80/80 though. 79/79 usually.
Knights are given magic level 8 as they should be, for knights doPlayerAddMagLevel works fine. All skills are -1 of what is set, though.

Strange thing is though, the results are different on each computer I run it on.
I have no explanation for it.
It seems I cannot write a clean script for this purpose, instead I am stuck using lines like doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,13))) when the function doPlayerAddMagLevel should just work!

So yeah, done writing now.
Doubt anyone can really explain it..
Doubt anyone bothered reading all this. Eh, was good to set it all out even just so I could reflect on the results.

Try the script on your computer, i'd love to see how it reacts.
 
Back
Top