• 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
130
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
 
Something like this should do the job..
Code:
    elseif voc == 8 then
    stor = getPlayerStorageValue(cid,2357)
        if stor == -1 then
            local highest = "SKILL_CLUB"
            if getPlayerSkillLevel(cid, SKILL_SWORD) > getPlayerSkillLevel(cid, highest) then highest = "SKILL_SWORD"
            if getPlayerSkillLevel(cid, SKILL_AXE) > getPlayerSkillLevel(cid, highest) then highest = "SKILL_AXE"
         
            setPlayerStorageValue(cid,2357,1)
            doPlayerSetSkill(cid, highest, getPlayerSkillLevel(cid, highest)+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
both have to be highest at the player set skill line

Forgot small explaination, well here it is:

the script says that club is the highest skill
checks if sword is higher, if yes it says sword is the highest,
checks if axe is highest, if so it says axe is highest

then adds skills to the one defined as highest

There's only one condition left: if the skills are equal:
if sword or axe or both are equal to club it will raise club
if sword is higher than club, and sword and axe are equal it will raise sword
 
Last edited by a moderator:
To fix the above issue, you could get 'skill tries' instead of 'skill level'. You'll still have the same issue.. but at that small of a scale where their skills tries are within 1 point of each other, I doubt they will care which skill get's buffed.
 
Code:
local vocationTable = {
    {voc = {5, 6, 12}, maglvl = 4, msg = "Magic Up" },
    {voc = {7}, skill = 12, skillId = SKILL_DISTANCE, msg = "Distance Up" },
    {voc = {10}, skill = 12, skillId = SKILL_CLUB, msg = "Club Up"},
    {voc = {14}, skill = 12, skillId = SKILL_FIST, msg = "Fist UP"},
    {voc = {8}, skill = {12, 12}, skillId = {SKILL_SWORD, SKILL_AXE}, msg = "Axe and Sword Up"},
}

function onUse(cid, item, frompos, item2, topos)
    local vocation = getPlayerVocation(cid)
    local position = getPlayerPosition(cid)
    local playerStorage = getPlayerStorageValue(cid, storage)
   
    if playerStorage ~= -1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(position, CONST_ME_POFF)
        return false
    end
   
    for i = 1, #vocationTable do
        if isInArray(vocationTable[i].voc, vocation) then
           
            setPlayerStorageValue(cid, storage, 1)
            if vocationTable[i].maglvl then
                doPlayerSetMagic(cid, getPlayerMagLevel(cid) + vocationTable[i].maglvl)
            end
           
            if skill then
                if type(skill) == 'table' then
                    for x = 1, #skill do
                        doPlayerSetSkill(cid, vocationTable[i].skillId[x], getPlayerSkillLevel(cid, vocationTable[i].skillId[x]) + vocationTable[i].skill[x])
                    end
                else
                    doPlayerSetSkill(cid, vocationTable[i].skillId, getPlayerSkillLevel(cid, vocationTable[i].skillId) + vocationTable[i].skill)
                end
            end
            doSendMagicEffect(frompos, 28)
            doSendAnimatedText(position, vocationTable[i].msg, TEXTCOLOR_BLUE)
            return true
        end
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return true
end
 
Something like this should do the job..
Code:
    elseif voc == 8 then
    stor = getPlayerStorageValue(cid,2357)
        if stor == -1 then
            local highest = "SKILL_CLUB"
            if getPlayerSkillLevel(cid, SKILL_SWORD) > getPlayerSkillLevel(cid, highest) then highest = "SKILL_SWORD"
            if getPlayerSkillLevel(cid, SKILL_AXE) > getPlayerSkillLevel(cid, highest) then highest = "SKILL_AXE"
        
            setPlayerStorageValue(cid,2357,1)
            doPlayerSetSkill(cid, highest, getPlayerSkillLevel(cid, highest)+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
both have to be highest at the player set skill line

This happens to yours:

18:34:43.293] [Error - LuaInterface::loadFile] data/actions/scripts/arquivo.lua
:68: 'end' expected (to close 'if' at line 4) near '<eof>'
[18:34:43.296] [Error - Event::checkScript] Cannot load script (data/actions/scr
ipts/arquivo.lua)
[18:34:43.298] data/actions/scripts/arquivo.lua:68: 'end' expected (to close 'if
' at line 4) near '<eof>'


Code:
local vocationTable = {
    {voc = {5, 6, 12}, maglvl = 4, msg = "Magic Up" },
    {voc = {7}, skill = 12, skillId = SKILL_DISTANCE, msg = "Distance Up" },
    {voc = {10}, skill = 12, skillId = SKILL_CLUB, msg = "Club Up"},
    {voc = {14}, skill = 12, skillId = SKILL_FIST, msg = "Fist UP"},
    {voc = {8}, skill = {12, 12}, skillId = {SKILL_SWORD, SKILL_AXE}, msg = "Axe and Sword Up"},
}

function onUse(cid, item, frompos, item2, topos)
    local vocation = getPlayerVocation(cid)
    local position = getPlayerPosition(cid)
    local playerStorage = getPlayerStorageValue(cid, storage)
  
    if playerStorage ~= -1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(position, CONST_ME_POFF)
        return false
    end
  
    for i = 1, #vocationTable do
        if isInArray(vocationTable[i].voc, vocation) then
          
            setPlayerStorageValue(cid, storage, 1)
            if vocationTable[i].maglvl then
                doPlayerSetMagic(cid, getPlayerMagLevel(cid) + vocationTable[i].maglvl)
            end
          
            if skill then
                if type(skill) == 'table' then
                    for x = 1, #skill do
                        doPlayerSetSkill(cid, vocationTable[i].skillId[x], getPlayerSkillLevel(cid, vocationTable[i].skillId[x]) + vocationTable[i].skill[x])
                    end
                else
                    doPlayerSetSkill(cid, vocationTable[i].skillId, getPlayerSkillLevel(cid, vocationTable[i].skillId) + vocationTable[i].skill)
                end
            end
            doSendMagicEffect(frompos, 28)
            doSendAnimatedText(position, vocationTable[i].msg, TEXTCOLOR_BLUE)
            return true
        end
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return true
end

And this happens to yours:

[12:29:32.790] [Error - LuaInterface::loadFile] data/actions/scripts/arquivo.lua
:32: 'end' expected (to close 'if' at line 29) near '<eof>'
[12:29:32.791] [Error - Event::checkScript] Cannot load script (data/actions/scr
ipts/arquivo.lua)
[12:29:32.792] data/actions/scripts/arquivo.lua:32: 'end' expected (to close 'if
' at line 29) near '<eof>'
 
This happens to yours:

18:34:43.293] [Error - LuaInterface::loadFile] data/actions/scripts/arquivo.lua
:68: 'end' expected (to close 'if' at line 4) near '<eof>'
[18:34:43.296] [Error - Event::checkScript] Cannot load script (data/actions/scr
ipts/arquivo.lua)
[18:34:43.298] data/actions/scripts/arquivo.lua:68: 'end' expected (to close 'if
' at line 4) near '<eof>'




And this happens to yours:

[12:29:32.790] [Error - LuaInterface::loadFile] data/actions/scripts/arquivo.lua
:32: 'end' expected (to close 'if' at line 29) near '<eof>'
[12:29:32.791] [Error - Event::checkScript] Cannot load script (data/actions/scr
ipts/arquivo.lua)
[12:29:32.792] data/actions/scripts/arquivo.lua:32: 'end' expected (to close 'if
' at line 29) near '<eof>'
You must of changed something because I don't see and <eof> error
 
Yup, i messed up, i didn't copy the whole script.

@Edit, i tested and nothing happend '-' i clicked the chest, the maigc effect came out, but nothing else happend..
I must have overlooked the storage value, shit happens.
Code:
local vocationTable = {
    {voc = {5, 6, 12}, maglvl = 4, msg = "Magic Up" },
    {voc = {7}, skill = 12, skillId = SKILL_DISTANCE, msg = "Distance Up" },
    {voc = {10}, skill = 12, skillId = SKILL_CLUB, msg = "Club Up"},
    {voc = {14}, skill = 12, skillId = SKILL_FIST, msg = "Fist UP"},
    {voc = {8}, skill = {12, 12}, skillId = {SKILL_SWORD, SKILL_AXE}, msg = "Axe and Sword Up"}
}

local storage = 2357

function onUse(cid, item, frompos, item2, topos)
    local vocation = getPlayerVocation(cid)
    local position = getPlayerPosition(cid)
    local playerStorage = getPlayerStorageValue(cid, storage)
 
    if playerStorage ~= -1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(position, CONST_ME_POFF)
        return false
    end
 
    for i = 1, #vocationTable do
        if isInArray(vocationTable[i].voc, vocation) then
         
            setPlayerStorageValue(cid, storage, 1)
            if vocationTable[i].maglvl then
                doPlayerSetMagic(cid, getPlayerMagLevel(cid) + vocationTable[i].maglvl)
            end
         
            if skill then
                if type(skill) == 'table' then
                    for x = 1, #skill do
                        doPlayerSetSkill(cid, vocationTable[i].skillId[x], getPlayerSkillLevel(cid, vocationTable[i].skillId[x]) + vocationTable[i].skill[x])
                    end
                else
                    doPlayerSetSkill(cid, vocationTable[i].skillId, getPlayerSkillLevel(cid, vocationTable[i].skillId) + vocationTable[i].skill)
                end
            end
            doSendMagicEffect(frompos, 28)
            doSendAnimatedText(position, vocationTable[i].msg, TEXTCOLOR_BLUE)
            return true
        end
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return true
end
 
I must have overlooked the storage value, shit happens.
Code:
local vocationTable = {
    {voc = {5, 6, 12}, maglvl = 4, msg = "Magic Up" },
    {voc = {7}, skill = 12, skillId = SKILL_DISTANCE, msg = "Distance Up" },
    {voc = {10}, skill = 12, skillId = SKILL_CLUB, msg = "Club Up"},
    {voc = {14}, skill = 12, skillId = SKILL_FIST, msg = "Fist UP"},
    {voc = {8}, skill = {12, 12}, skillId = {SKILL_SWORD, SKILL_AXE}, msg = "Axe and Sword Up"}
}

local storage = 2357

function onUse(cid, item, frompos, item2, topos)
    local vocation = getPlayerVocation(cid)
    local position = getPlayerPosition(cid)
    local playerStorage = getPlayerStorageValue(cid, storage)

    if playerStorage ~= -1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(position, CONST_ME_POFF)
        return false
    end

    for i = 1, #vocationTable do
        if isInArray(vocationTable[i].voc, vocation) then
        
            setPlayerStorageValue(cid, storage, 1)
            if vocationTable[i].maglvl then
                doPlayerSetMagic(cid, getPlayerMagLevel(cid) + vocationTable[i].maglvl)
            end
        
            if skill then
                if type(skill) == 'table' then
                    for x = 1, #skill do
                        doPlayerSetSkill(cid, vocationTable[i].skillId[x], getPlayerSkillLevel(cid, vocationTable[i].skillId[x]) + vocationTable[i].skill[x])
                    end
                else
                    doPlayerSetSkill(cid, vocationTable[i].skillId, getPlayerSkillLevel(cid, vocationTable[i].skillId) + vocationTable[i].skill)
                end
            end
            doSendMagicEffect(frompos, 28)
            doSendAnimatedText(position, vocationTable[i].msg, TEXTCOLOR_BLUE)
            return true
        end
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return true
end

Same thing :/
 
There you go, I kept it simple for easy edits
Code:
function raiseMagic(cid)
    doPlayerSetMagic(cid, getPlayerMagLevel(cid) + 4)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Magic Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseDist(cid)
    doPlayerSetSkill(cid, SKILL_DISTANCE, getPlayerSkillLevel(cid, SKILL_DISTANCE) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Distance Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseFist(cid)
    doPlayerSetSkill(cid, SKILL_FIST, getPlayerSkillLevel(cid, SKILL_FIST) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Fist Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseClub(cid)
    doPlayerSetSkill(cid, SKILL_CLUB, getPlayerSkillLevel(cid, SKILL_CLUB) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Club Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseSword(cid)
    doPlayerSetSkill(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Sword Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseAxe(cid)
    doPlayerSetSkill(cid, SKILL_AXE, getPlayerSkillLevel(cid, SKILL_AXE) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Axe Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function checkHighest(cid)
    local highest = "SKILL_CLUB"
    if getPlayerSkillLevel(cid, SKILL_SWORD) > getPlayerSkillLevel(cid, highest) then highest = "SKILL_SWORD"
    if getPlayerSkillLevel(cid, SKILL_AXE) > getPlayerSkillLevel(cid, highest) then highest = "SKILL_AXE"
  
    if highest == "SKILL_CLUB" then raiseClub(cid)
    elseif highest == "SKILL_SWORD" then raiseSword(cid)
    else raiseAxe(cid)  
end

function onUse(cid, item, frompos, item2, topos)
    local pS = getPlayerStorageValue(cid, 2357)
    local pV = getPlayerVocation(cid)

    if pS ~= -1 or pS ~= 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(position, CONST_ME_POFF)
        return false
    end

    if pV == 5 or pV == 6 or pV == 12 then
        raiseMagic(cid)
    elseif pV == 7 then
        raiseDist(cid)
    elseif pV == 10 then
        raiseClub(cid)
    elseif pV == 14 then
        raiseFist(cid)
    elseif pV == 8 then
        checkHighest(cid)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
   
    return true
end
 
Last edited:
There you go, I kept it simple for easy edits
Code:
function raiseMagic(cid)
    doPlayerSetMagic(cid, getPlayerMagLevel(cid) + 4)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Magic Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseDist(cid)
    doPlayerSetSkill(cid, SKILL_DISTANCE, getPlayerSkillLevel(cid, SKILL_DISTANCE) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Distance Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseFist(cid)
    doPlayerSetSkill(cid, SKILL_FIST, getPlayerSkillLevel(cid, SKILL_FIST) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Fist Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseClub(cid)
    doPlayerSetSkill(cid, SKILL_CLUB, getPlayerSkillLevel(cid, SKILL_CLUB) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Club Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseSword(cid)
    doPlayerSetSkill(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Sword Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseAxe(cid)
    doPlayerSetSkill(cid, SKILL_AXE, getPlayerSkillLevel(cid, SKILL_AXE) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Axe Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function checkHighest(cid)
    local highest = "SKILL_CLUB"
    if getPlayerSkillLevel(cid, SKILL_SWORD) > getPlayerSkillLevel(cid, highest) then highest = "SKILL_SWORD"
    if getPlayerSkillLevel(cid, SKILL_AXE) > getPlayerSkillLevel(cid, highest) then highest = "SKILL_AXE"
 
    if highest == "SKILL_CLUB" then raiseClub(cid)
    elseif highest == "SKILL_SWORD" then raiseSword(cid)
    else raiseAxe(cid) 
end

function onUse(cid, item, frompos, item2, topos)
    local pS = getPlayerStorageValue(cid, 2357)
    local pV = getPlayerVocation(cid)

    if pS ~= -1 or pS ~= 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(position, CONST_ME_POFF)
        return false
    end

    if pV == 5 or pV == 6 or pV == 12 then
        raiseMagic(cid)
    elseif pV == 7 then
        raiseDist(cid)
    elseif pV == 10 then
        raiseClub(cid)
    elseif pV == 14 then
        raiseFist(cid)
    elseif pV == 8 then
        checkHighest(cid)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
  
    return true
end

This happend:

[20:54:21.404] [Error - LuaInterface::loadFile] data/actions/scripts/arquivo.lua
:79: 'end' expected (to close 'if' at line 46) near '<eof>'
[20:54:21.405] [Error - Event::checkScript] Cannot load script (data/actions/scr
ipts/arquivo.lua)
[20:54:21.406] data/actions/scripts/arquivo.lua:79: 'end' expected (to close 'if
' at line 46) near '<eof>'
 
take this fix:
Code:
function raiseMagic(cid)
    doPlayerSetMagic(cid, getPlayerMagLevel(cid) + 4)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Magic Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseDist(cid)
    doPlayerSetSkill(cid, SKILL_DISTANCE, getPlayerSkillLevel(cid, SKILL_DISTANCE) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Distance Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseFist(cid)
    doPlayerSetSkill(cid, SKILL_FIST, getPlayerSkillLevel(cid, SKILL_FIST) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Fist Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseClub(cid)
    doPlayerSetSkill(cid, SKILL_CLUB, getPlayerSkillLevel(cid, SKILL_CLUB) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Club Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseSword(cid)
    doPlayerSetSkill(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Sword Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseAxe(cid)
    doPlayerSetSkill(cid, SKILL_AXE, getPlayerSkillLevel(cid, SKILL_AXE) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Axe Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function checkHighest(cid)
    local highest = "SKILL_CLUB"
    if getPlayerSkillLevel(cid, SKILL_SWORD) > getPlayerSkillLevel(cid, highest) then
        highest = "SKILL_SWORD"
    end
    if getPlayerSkillLevel(cid, SKILL_AXE) > getPlayerSkillLevel(cid, highest) then
        highest = "SKILL_AXE"
    end

    if highest == "SKILL_CLUB" then
        raiseClub(cid)
    elseif highest == "SKILL_SWORD" then
        raiseSword(cid)
    else
        raiseAxe(cid) 
    end
end

function onUse(cid, item, frompos, item2, topos)
    local pS = getPlayerStorageValue(cid, 2357)
    local pV = getPlayerVocation(cid)

    if pS ~= -1 or pS ~= 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(position, CONST_ME_POFF)
        return false
    end

    if pV == 5 or pV == 6 or pV == 12 then
        raiseMagic(cid)
    elseif pV == 7 then
        raiseDist(cid)
    elseif pV == 10 then
        raiseClub(cid)
    elseif pV == 14 then
        raiseFist(cid)
    elseif pV == 8 then
        checkHighest(cid)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
    return true
end
 
take this fix:
Code:
function raiseMagic(cid)
    doPlayerSetMagic(cid, getPlayerMagLevel(cid) + 4)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Magic Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseDist(cid)
    doPlayerSetSkill(cid, SKILL_DISTANCE, getPlayerSkillLevel(cid, SKILL_DISTANCE) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Distance Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseFist(cid)
    doPlayerSetSkill(cid, SKILL_FIST, getPlayerSkillLevel(cid, SKILL_FIST) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Fist Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseClub(cid)
    doPlayerSetSkill(cid, SKILL_CLUB, getPlayerSkillLevel(cid, SKILL_CLUB) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Club Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseSword(cid)
    doPlayerSetSkill(cid, SKILL_SWORD, getPlayerSkillLevel(cid, SKILL_SWORD) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Sword Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function raiseAxe(cid)
    doPlayerSetSkill(cid, SKILL_AXE, getPlayerSkillLevel(cid, SKILL_AXE) + 12)
    doSendMagicEffect(frompos, 28)
    doSendAnimatedText(position, "Axe Up", TEXTCOLOR_BLUE)
    setPlayerStorageValue(cid, 2357, 1)
end

function checkHighest(cid)
    local highest = "SKILL_CLUB"
    if getPlayerSkillLevel(cid, SKILL_SWORD) > getPlayerSkillLevel(cid, highest) then
        highest = "SKILL_SWORD"
    end
    if getPlayerSkillLevel(cid, SKILL_AXE) > getPlayerSkillLevel(cid, highest) then
        highest = "SKILL_AXE"
    end

    if highest == "SKILL_CLUB" then
        raiseClub(cid)
    elseif highest == "SKILL_SWORD" then
        raiseSword(cid)
    else
        raiseAxe(cid)
    end
end

function onUse(cid, item, frompos, item2, topos)
    local pS = getPlayerStorageValue(cid, 2357)
    local pV = getPlayerVocation(cid)

    if pS ~= -1 or pS ~= 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(position, CONST_ME_POFF)
        return false
    end

    if pV == 5 or pV == 6 or pV == 12 then
        raiseMagic(cid)
    elseif pV == 7 then
        raiseDist(cid)
    elseif pV == 10 then
        raiseClub(cid)
    elseif pV == 14 then
        raiseFist(cid)
    elseif pV == 8 then
        checkHighest(cid)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    end
    return true
end

Well, now whenever i try to use the chest it says that i already did the quest, i tried a different storage, another char, but same thing happen.
 
Just replace if pS ~= -1 or pS ~= 0 then
with if pS > 0 then
like Xikini said......

it checks if your player's storage is higher than 0 ...
if your storage is higher than 0 you did the quest...
 
replace that part of the code, and be amazed how it can help. :p
Just replace if pS ~= -1 or pS ~= 0 then
with if pS > 0 then
like Xikini said......

it checks if your player's storage is higher than 0 ...
if your storage is higher than 0 you did the quest...

The part where i gives the skill worked, whichever skill is higher is the one the player will get, but the player can do the quest as many times as he wishes, so he keeps on using the chest and getting skills
 
Back
Top