TFS 0.X Quest gives skills not working

juansanchez

Member
Joined
Apr 2, 2015
Messages
177
Reaction score
18
Hey guys, i have this quest on my server that is supossed to give skills to players.
Mages get Magic Level, Knights and Paladins Skills.
I have a working script but it is way too glitchy.. Whenever a player does the quest, it does not give the right amount of skills, if someone is using some kind of equipment that gives skills, the quest will add skill on top of that, and if for example, a knight uses "utito tempo" right before using the chest, they'll get the skill set to whatever skill they go to when they use utito tempo + the amount of skill that the quest should give. (Skill 100, utito tempo goes to 130, quest gives 12, they go to 142 [Example]).
Also, whenever a player clicks on the chest, the server lags.
Lua:
function onUse(cid, item, frompos, item2, topos)
    local pS = getPlayerStorageValue(cid, 2357)
    local pV = getPlayerVocation(cid)
    if pS > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    else
        if pV == 5 or pV == 6 or pV == 12 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddMagLevel(cid, 6)
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Magic Up", TEXTCOLOR_BLUE)
        elseif pV == 7 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_DISTANCE, doPlayerAddSkill(cid, SKILL_DISTANCE, 12))
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Distance Up", TEXTCOLOR_BLUE)
        elseif pV == 10 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_CLUB, doPlayerAddSkill(cid, SKILL_CLUB, 12))
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Club Up", TEXTCOLOR_BLUE)
        elseif pV == 14 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_FIST, doPlayerAddSkill(cid, SKILL_FIST, 12))
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Fist Up", TEXTCOLOR_BLUE)
        elseif pV == 8 then
            setPlayerStorageValue(cid, 2357, 1)
      
            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
                doPlayerAddSkill(cid, SKILL_CLUB, doPlayerAddSkill(cid, SKILL_CLUB, 12))
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Club Up", TEXTCOLOR_BLUE)
            elseif highest == "SKILL_SWORD" then
                doPlayerAddSkill(cid, SKILL_SWORD, doPlayerAddSkill(cid, SKILL_SWORD, 12))
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Sword Up", TEXTCOLOR_BLUE)
            else
                doPlayerAddSkill(cid, SKILL_AXE, doPlayerAddSkill(cid, SKILL_AXE, 12))
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Axe Up", TEXTCOLOR_BLUE)
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    end
    return true
end
That's the script. I did find another one, that seems to use database to add the skills, which i believe is better. However when i try to use it, it gives me this error:

[20:58:56.702] [Error - Test Interface]
[20:58:56.704] data/actions/scripts/lagartos.lua
[20:58:56.707] Description:
[20:58:56.708] (internalGetPlayerInfo) Player not found when requesting player info #18
[20:58:56.710] [Error - Test Interface]
[20:58:56.711] data/actions/scripts/lagartos.lua
[20:58:56.711] Description:
[20:58:56.715] (internalGetPlayerInfo) Player not found when requesting player info #6
[20:58:56.718] [Error - Test Interface]
[20:58:56.720] data/actions/scripts/lagartos.lua
[20:58:56.721] Description:
[20:58:56.721] (internalGetPlayerInfo) Player not found when requesting player info #6
[20:58:56.723] [Error - Test Interface]
[20:58:56.729] data/actions/scripts/lagartos.lua
[20:58:56.730] Description:
[20:58:56.731] (internalGetPlayerInfo) Player not found when requesting player info #6
[20:58:56.731] [Error - Event::checkScript] Event onUse not found (data/actions/scripts/lagartos.lua)

Here's the script:

Code:
local playerid = getPlayerGUID(cid)
local ml = 6
local skillnew = 12
if isInArray({5,6}, getPlayerVocation(cid)) then
db.executeQuery("UPDATE `players` SET `maglevel` = `maglevel` + ".. newml .." WHERE `players`.`id`= ".. playerid .."")
elseif isInArray({8}, getPlayerVocation(cid)) then
local club = getPlayerSkillLevel(cid, SKILL_CLUB)
local sword = getPlayerSkillLevel(cid, SKILL_SWORD)
local axe = getPlayerSkillLevel(cid, SKILL_AXE)
db.executeQuery("UPDATE `player_skills` SET `value` = " .. (axe + skillnew) .. ", `count` = 0 WHERE `skillid` = 3 and `player_id` = " .. playerid .. ";")
db.executeQuery("UPDATE `player_skills` SET `value` = " .. (sword + skillnew) .. ", `count` = 0 WHERE `skillid` = 2 and `player_id` = " .. playerid .. ";")
db.executeQuery("UPDATE `player_skills` SET `value` = " .. (club + skillnew) .. ", `count` = 0 WHERE `skillid` = 1 and `player_id` = " .. playerid .. ";")
elseif isInArray({7}, getPlayerVocation(cid)) then
local distance = getPlayerSkillLevel(cid, SKILL_DISTANCE)
db.executeQuery("UPDATE `player_skills` SET `value` = " .. (distance + skillnew) .. ", `count` = 0 WHERE `skillid` = 4 and `player_id` = " .. playerid .. ";")
end
Bottomline is, can anyone help me either fix the first one, or make the second one work?
Longstory short: Gives skill, can't use spells to boost skill nor itens. If the player could logout when the skill is added (i believe it's via the db this happens).

Tfs 0.3.6 10.10

Sorry for the long post.​
 
Last edited:

Ascuas Funkeln

Rakkedo Game
Joined
Apr 14, 2013
Messages
129
Reaction score
58
Location
Poland
Lua:
function onUse(cid, item, frompos, item2, topos)
    local pS = getPlayerStorageValue(cid, 2357)
    local pV = getPlayerVocation(cid)
    if pS > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    else
        if pV == 5 or 6 or 12 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddMagLevel(cid, 6)
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Magic Up", TEXTCOLOR_BLUE)
        elseif pV == 7 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_DISTANCE, 12)
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Distance Up", TEXTCOLOR_BLUE)
        elseif pV == 10 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_CLUB, 12)
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Club Up", TEXTCOLOR_BLUE)
        elseif pV == 14 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_FIST, 12)
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Fist Up", TEXTCOLOR_BLUE)
        elseif pV == 8 then
            setPlayerStorageValue(cid, 2357, 1)
        
            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
                doPlayerAddSkill(cid, SKILL_CLUB, 12)
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Club Up", TEXTCOLOR_BLUE)
            elseif highest == "SKILL_SWORD" then
                doPlayerAddSkill(cid, SKILL_SWORD, 12)
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Sword Up", TEXTCOLOR_BLUE)
            else
                doPlayerAddSkill(cid, SKILL_AXE, 12)
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Axe Up", TEXTCOLOR_BLUE)
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    end
    return true
end
 
OP
juansanchez

juansanchez

Member
Joined
Apr 2, 2015
Messages
177
Reaction score
18
Lua:
function onUse(cid, item, frompos, item2, topos)
    local pS = getPlayerStorageValue(cid, 2357)
    local pV = getPlayerVocation(cid)
    if pS > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    else
        if pV == 5 or 6 or 12 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddMagLevel(cid, 6)
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Magic Up", TEXTCOLOR_BLUE)
        elseif pV == 7 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_DISTANCE, 12)
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Distance Up", TEXTCOLOR_BLUE)
        elseif pV == 10 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_CLUB, 12)
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Club Up", TEXTCOLOR_BLUE)
        elseif pV == 14 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_FIST, 12)
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Fist Up", TEXTCOLOR_BLUE)
        elseif pV == 8 then
            setPlayerStorageValue(cid, 2357, 1)
       
            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
                doPlayerAddSkill(cid, SKILL_CLUB, 12)
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Club Up", TEXTCOLOR_BLUE)
            elseif highest == "SKILL_SWORD" then
                doPlayerAddSkill(cid, SKILL_SWORD, 12)
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Sword Up", TEXTCOLOR_BLUE)
            else
                doPlayerAddSkill(cid, SKILL_AXE, 12)
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Axe Up", TEXTCOLOR_BLUE)
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    end
    return true
end
It gives Magic Level to all vocations.

I did manage to force the logout and addskill using:
Code:
doRemoveCreature(cid)
db.executeQuery("UPDATE `player_skills` SET `value` = " .. (sword + 12) .. ", `count` = 0 WHERE `skillid` = 2 and `player_id` = " .. pid .. ";")
However, if i use utito tempo, even though sword is the highest skill, it gives me axe skill and i get this error:

Code:
[18:25:54.993] [Error - Action Interface]
[18:25:54.995] data/actions/scripts/lagartos.lua:onUse
[18:25:54.998] Description:
[18:25:54.999] data/lib/050-function.lua:396: 'for' limit must be a number
[18:25:55.002] stack traceback:
[18:25:55.005]  data/lib/050-function.lua:396: in function 'doPlayerAddSkill'
[18:25:55.006]  data/actions/scripts/lagartos.lua:53: in function <data/actions/scripts/lagartos.lua:1>
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,509
Reaction score
2,060
Hey guys, i have this quest on my server that is supossed to give skills to players.
Mages get Magic Level, Knights and Paladins Skills.
I have a working script but it is way too glitchy.. Whenever a player does the quest, it does not give the right amount of skills, if someone is using some kind of equipment that gives skills, the quest will add skill on top of that, and if for example, a knight uses "utito tempo" right before using the chest, they'll get the skill set to whatever skill they go to when they use utito tempo + the amount of skill that the quest should give. (Skill 100, utito tempo goes to 130, quest gives 12, they go to 142 [Example]).
Also, whenever a player clicks on the chest, the server lags.
Code:
function onUse(cid, item, frompos, item2, topos)
    local pS = getPlayerStorageValue(cid, 2357)
    local pV = getPlayerVocation(cid)
    if pS > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    else
        if pV == 5 or pV == 6 or pV == 12 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddMagLevel(cid, 6)
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Magic Up", TEXTCOLOR_BLUE)
        elseif pV == 7 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_DISTANCE, doPlayerAddSkill(cid, SKILL_DISTANCE, 12))
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Distance Up", TEXTCOLOR_BLUE)
        elseif pV == 10 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_CLUB, doPlayerAddSkill(cid, SKILL_CLUB, 12))
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Club Up", TEXTCOLOR_BLUE)
        elseif pV == 14 then
            setPlayerStorageValue(cid, 2357, 1)
            doPlayerAddSkill(cid, SKILL_FIST, doPlayerAddSkill(cid, SKILL_FIST, 12))
            doSendMagicEffect(getPlayerPosition(cid), 28)
            doSendAnimatedText(getPlayerPosition(cid), "Fist Up", TEXTCOLOR_BLUE)
        elseif pV == 8 then
            setPlayerStorageValue(cid, 2357, 1)
        
            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
                doPlayerAddSkill(cid, SKILL_CLUB, doPlayerAddSkill(cid, SKILL_CLUB, 12))
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Club Up", TEXTCOLOR_BLUE)
            elseif highest == "SKILL_SWORD" then
                doPlayerAddSkill(cid, SKILL_SWORD, doPlayerAddSkill(cid, SKILL_SWORD, 12))
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Sword Up", TEXTCOLOR_BLUE)
            else
                doPlayerAddSkill(cid, SKILL_AXE, doPlayerAddSkill(cid, SKILL_AXE, 12))
                doSendMagicEffect(getPlayerPosition(cid), 28)
                doSendAnimatedText(getPlayerPosition(cid), "Axe Up", TEXTCOLOR_BLUE)
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    end
    return true
end
That's the script. I did find another one, that seems to use database to add the skills, which i believe is better. However when i try to use it, it gives me this error:

[20:58:56.702] [Error - Test Interface]
[20:58:56.704] data/actions/scripts/lagartos.lua
[20:58:56.707] Description:
[20:58:56.708] (internalGetPlayerInfo) Player not found when requesting player info #18
[20:58:56.710] [Error - Test Interface]
[20:58:56.711] data/actions/scripts/lagartos.lua
[20:58:56.711] Description:
[20:58:56.715] (internalGetPlayerInfo) Player not found when requesting player info #6
[20:58:56.718] [Error - Test Interface]
[20:58:56.720] data/actions/scripts/lagartos.lua
[20:58:56.721] Description:
[20:58:56.721] (internalGetPlayerInfo) Player not found when requesting player info #6
[20:58:56.723] [Error - Test Interface]
[20:58:56.729] data/actions/scripts/lagartos.lua
[20:58:56.730] Description:
[20:58:56.731] (internalGetPlayerInfo) Player not found when requesting player info #6
[20:58:56.731] [Error - Event::checkScript] Event onUse not found (data/actions/scripts/lagartos.lua)

Here's the script:

Code:
local playerid = getPlayerGUID(cid)
local ml = 6
local skillnew = 12
if isInArray({5,6}, getPlayerVocation(cid)) then
db.executeQuery("UPDATE `players` SET `maglevel` = `maglevel` + ".. newml .." WHERE `players`.`id`= ".. playerid .."")
elseif isInArray({8}, getPlayerVocation(cid)) then
local club = getPlayerSkillLevel(cid, SKILL_CLUB)
local sword = getPlayerSkillLevel(cid, SKILL_SWORD)
local axe = getPlayerSkillLevel(cid, SKILL_AXE)
db.executeQuery("UPDATE `player_skills` SET `value` = " .. (axe + skillnew) .. ", `count` = 0 WHERE `skillid` = 3 and `player_id` = " .. playerid .. ";")
db.executeQuery("UPDATE `player_skills` SET `value` = " .. (sword + skillnew) .. ", `count` = 0 WHERE `skillid` = 2 and `player_id` = " .. playerid .. ";")
db.executeQuery("UPDATE `player_skills` SET `value` = " .. (club + skillnew) .. ", `count` = 0 WHERE `skillid` = 1 and `player_id` = " .. playerid .. ";")
elseif isInArray({7}, getPlayerVocation(cid)) then
local distance = getPlayerSkillLevel(cid, SKILL_DISTANCE)
db.executeQuery("UPDATE `player_skills` SET `value` = " .. (distance + skillnew) .. ", `count` = 0 WHERE `skillid` = 4 and `player_id` = " .. playerid .. ";")
end
Bottomline is, can anyone help me either fix the first one, or make the second one work?
Longstory short: Gives skill, can't use spells to boost skill nor itens. If the player could logout when the skill is added (i believe it's via the db this happens).

Tfs 0.3.6 10.10

Sorry for the long post.​
How to display CODE properly in your post
please don't format your code with centered text, it's impossible to read
 
OP
juansanchez

juansanchez

Member
Joined
Apr 2, 2015
Messages
177
Reaction score
18
How to display CODE properly in your post
please don't format your code with centered text, it's impossible to read
Sorry, i didn't think of that. I fixed it now.

@Update

I fixed parts of it. Now the player logs out and gets the right amount of skills.
However, it still glitches when they use any spells that buffs skills or itens.

And now knights don't recieve any skills.

Lua:
function onUse(cid, item, frompos, item2, topos)
    local pS = getPlayerStorageValue(cid, 2400)
    local pV = getPlayerVocation(cid)
    if pS > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja fez a quest.")
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    else
        if pV == 5 or pV == 6 or pV == 12 then
            setPlayerStorageValue(cid, 2400, 1)
            local pid = getPlayerGUID(cid)
            doRemoveCreature(cid)
            db.executeQuery("UPDATE `players` SET `maglevel` = `maglevel` + 6 WHERE `id` = "..pid..";")
        elseif pV == 7 then
            setPlayerStorageValue(cid, 2400, 1)
            local pid = getPlayerGUID(cid)
            local distance = getPlayerSkillLevel(cid, SKILL_DISTANCE)
            doRemoveCreature(cid)
            db.executeQuery("UPDATE `player_skills` SET `value` = " .. (distance + 12) .. ", `count` = 0 WHERE `skillid` = 4 and `player_id` = " .. pid .. ";")
        elseif pV == 10 then
            setPlayerStorageValue(cid, 2400, 1)
            local pid = getPlayerGUID(cid)
            local club = getPlayerSkillLevel(cid, SKILL_CLUB)
            doRemoveCreature(cid)
            db.executeQuery("UPDATE `player_skills` SET `value` = " .. (club + 12) .. ", `count` = 0 WHERE `skillid` = 1 and `player_id` = " .. pid .. ";")
        elseif pV == 14 then
            setPlayerStorageValue(cid, 2400, 1)
            local pid = getPlayerGUID(cid)
            local fist = getPlayerSkillLevel(cid, SKILL_FIST)
            doRemoveCreature(cid)
            db.executeQuery("UPDATE `player_skills` SET `value` = " .. (fist + 12) .. ", `count` = 0 WHERE `skillid` = 0 and `player_id` = " .. pid .. ";")
        elseif pV == 8 or pV == 18 then
            setPlayerStorageValue(cid, 2400, 1)
        
            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
                local pid = getPlayerGUID(cid)
                local club = getPlayerSkillLevel(cid, SKILL_CLUB)
                doRemoveCreature(cid)
                db.executeQuery("UPDATE `player_skills` SET `value` = " .. (club + 12) .. ", `count` = 0 WHERE `skillid` = 1 and `player_id` = " .. pid .. ";")
            elseif highest == "SKILL_SWORD" then
                if getCreatureCondition (cid, CONDITION_ATTRIBUTES) == FALSE then
                local pid = getPlayerGUID(cid)
                local sword = getPlayerSkillLevel(cid, SKILL_SWORD)
                doRemoveCreature(cid)
                db.executeQuery("UPDATE `player_skills` SET `value` = " .. (sword + 12) .. ", `count` = 0 WHERE `skillid` = 2 and `player_id` = " .. pid .. ";")
            else
                local pid = getPlayerGUID(cid)
                local xe = getPlayerSkillLevel(cid, SKILL_CLUB)
                doRemoveCreature(cid)
                db.executeQuery("UPDATE `player_skills` SET `value` = " .. (axe + 12) .. ", `count` = 0 WHERE `skillid` = 3 and `player_id` = " .. pid .. ";")
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce nao tem a vocacao necessaria.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    end
    return true
end
end
 

Ramirow

Advanced OT User
Joined
Aug 22, 2009
Messages
453
Reaction score
167
Location
Argentina
The only way to do it is by using querys? I don't have such an old server to try, but I think this function existed on it:
Code:
getPlayerRequiredSkillTries(cid, skillId, skillLevel)
I suppose that would give you the required tries for X level, so you could try something like this for example:
Code:
if highest == "SKILL_CLUB" then
    local pid = getPlayerGUID(cid)
    local club = getPlayerSkillLevel(cid, SKILL_CLUB)
    local clubTries = getPlayerRequiredSkillTries(cid, SKILL_CLUB, club + 12)
   
    doPlayerAddSkillTry(cid, SKILL_CLUB, clubTries)
 
OP
juansanchez

juansanchez

Member
Joined
Apr 2, 2015
Messages
177
Reaction score
18
The only way to do it is by using querys? I don't have such an old server to try, but I think this function existed on it:
Code:
getPlayerRequiredSkillTries(cid, skillId, skillLevel)
I suppose that would give you the required tries for X level, so you could try something like this for example:
Code:
if highest == "SKILL_CLUB" then
    local pid = getPlayerGUID(cid)
    local club = getPlayerSkillLevel(cid, SKILL_CLUB)
    local clubTries = getPlayerRequiredSkillTries(cid, SKILL_CLUB, club + 12)
  
    doPlayerAddSkillTry(cid, SKILL_CLUB, clubTries)
Query is better, because if i add that many skills to a player, the server freezes while adding the skills. Tried your way, knights still don't recieve any skill.
 

Tadelho

Excellent OT User
Joined
Aug 12, 2007
Messages
38
Reaction score
2
@juansanchez In TFS 0.4~ there is a function called 'getPlayerSkillLevel' wich should receives 3 parameters: cid (the creatureid that should be checked), skill (the skill to be checked), and a parameter to ignore or consider modifiers (from itens/spells) in this skills. You can ignore modifiers setting this last parameter as "true" or consider it setting as "false". In case of magic level, it's 'getPlayerMagLevel' with only 2 parameters: cid, true/false.

So, you can make a simple script to check the skill of the player and then add more skills upon it.
For example:

Lua:
getPlayerSkillLevel(cid, SKILL_SWORD, true)
Here you're checking the "natural" sword skill of a player, you can start from here. But, of course, in your case the code must be a lot bigger with a lot of other verifications...

But, hey, another possible temporary solution is simply checking if the player has any buff/debuff in his skills and disable the quest to buffed players. Something like:

Lua:
if getPlayerSkillLevel(cid, Skill, true) == getPlayerSkillLevel(cid, Skill, false) and getPlayerMagLevel(cid, true) == getPlayerMagLevel(cid, false) then
(insert the bonus code here)
else
doSendPlayerCancel(cid,'You can not receive a bonus awhile your skills or magic level are modified.')
end
 
Last edited:

mdwilliams

(Michael)
Premium User
Joined
Nov 15, 2007
Messages
614
Reaction score
118
Location
Western Australia
I used these functions for my simple war ot release back in the day, but it did cause lag and I do recall the results not being as expected - it wasn't because of equipment or spells (I was applying these on first login only). I can't remember what the problem ended up being, but it was in the coding of these functions.

Lua:
doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,x))) // doPlayerAddMagLevel(cid, x)
doPlayerAddSkillTry(cid, SKILL_DISTANCE, getPlayerRequiredSkillTries(cid, SKILL_DISTANCE, x))
doPlayerAddSkillTry(cid, SKILL_SHIELD, getPlayerRequiredSkillTries(cid, SKILL_SHIELD, x))
doPlayerAddSkillTry(cid, SKILL_AXE, getPlayerRequiredSkillTries(cid, SKILL_AXE, x))
doPlayerAddSkillTry(cid, SKILL_SWORD, getPlayerRequiredSkillTries(cid, SKILL_SWORD, x))
doPlayerAddSkillTry(cid, SKILL_CLUB, getPlayerRequiredSkillTries(cid, SKILL_CLUB, x))
Oh I forgot about this, I helped some guy fix it back in 2012 - maybe this will help you:
Solved - doPlayerAddMagLevel(cid, getPlayerMagLevel(cid) * (-1) + 70) is not working...
 
Last edited:
OP
juansanchez

juansanchez

Member
Joined
Apr 2, 2015
Messages
177
Reaction score
18
@juansanchez In TFS 0.4~ there is a function called 'getPlayerSkillLevel' wich should receives 3 parameters: cid (the creatureid that should be checked), skill (the skill to be checked), and a parameter to ignore or consider modifiers (from itens/spells) in this skills. You can ignore modifiers setting this last parameter as "true" or consider it setting as "false". In case of magic level, it's 'getPlayerMagLevel' with only 2 parameters: cid, true/false.

So, you can make a simple script to check the skill of the player and then add more skills upon it.
For example:

Lua:
getPlayerSkillValue(cid, SKILL_SWORD, true)
Here you're checking the "natural" sword skill of a player, you can start from here. But, of course, in your case the code must be a lot bigger with a lot of other verifications...

But, hey, another possible temporary solution is simply checking if the player has any buff/debuff in his skills and disable the quest to buffed players. Something like:

Lua:
if getPlayerSkillValue(cid, Skill, true) == getPlayerSkillValue(cid, Skill, false) and getPlayerMagLevel(cid, true) == getPlayerMagLevel(cid, false) then
(insert the bonus code here)
else
doSendPlayerCancel(cid,'You can not receive a bonus awhile your skills or magic level are modified.')
end
This function doesn't exist: "attempt to call global 'getPlayerSkillValue' (a nil value)" At least not on my 0.3.6.
 
Top