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

(Talkaction) skill command error nil value

Firulis

New Member
Joined
Jan 3, 2017
Messages
34
Solutions
2
Reaction score
1
I've been working on a command that will increase the skill of a player by a determined amount, and this is what i've come up with so far
Code:
function onSay(cid, words)
    local config = {
        item = 10140, -- Item required for command
        skills = 200, -- Half skill for Sword, Axe, Club, Distance, & Shield
        incrementSkills = 50, -- By how much does the skill increases everytime the command is used
        action = TRUE -- Do not change
    }
   
    skillID = -1
       
    if words == "!halfclub" then
        if getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
            skillID = 1
        else
            doPlayerSendCancel(cid, 'voce precisa ser knight para usar o comando.')
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    elseif words == "!halfsword" then
        if getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
            skillID = 2
        else
            doPlayerSendCancel(cid, 'voce precisa ser knight para usar o comando.')
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    elseif words == "!halfaxe" then
        if getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
            skillID = 3
        else
            doPlayerSendCancel(cid, 'voce precisa ser knight para usar o comando.')
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    elseif words == "!halfdistance" then
        if getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 then
            skillID = 4
        else
            doPlayerSendCancel(cid, 'voce precisa ser paladin para usar o comando.')
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        end
    elseif words == "!halfshield" then
        skillID = 5
    else
        diag = 'Skill Commands:\n\n!halfmagic\n!halfsword\n!halfaxe\n!halfclub\n!halfdistance\n!halfshield'
        doShowTextDialog(cid, 5958, diag)
        config.action = FALSE
    end
   
    if config.action == TRUE then
        if (getTilePzInfo(getCreaturePosition(cid)) == TRUE) then
            if skillID ~= -1  then
                local skills = db.getResult("SELECT `player_id`, `value`, `skillid` FROM `player_skills` WHERE `skillid` = "..skillID.." ORDER BY `value` DESC;")
                local currentSkill = skills:getDataInt("value")
                if currentSkill < config.skills - config.incrementSkills then
                    doPlayerSetSkill(cid, skillID, currentSkill + config.incrementSkills )
                elseif ( currentSkill > config.skills - config.incrementSkills ) and ( currentSkill < config.skills ) then
                    doPlayerSetSkill(cid, skillID, config.skills )
                else
                    doPlayerSendCancel(cid, 'Congratulations, you have 200 skill.')
                end
            end
        else
            doPlayerSendCancel(cid,"You need to be in a protection zone to use this command.")
        end
    end
end
i dont get any errors in the console when booting up, but when i use the command i get this:
C9766yv.png
 
Rules for the Support board

doPlayerSetSkill does not exist on your server, what version are you using?
It doest exist, im using tfs 0.4 but the problem is that there's a syntax error when i request the database information and that's why i get the nil value error, im trying to extract the skill level directly from the dabatase and this is what im using right now to do that:
Code:
                local skills = db.getResult('SELECT `value`, FROM `player_skills` WHERE `skillid` = "..skillID.."')
                local currentSkill = skills:getDataInt('value')
and this is the error im getting
Code:
[11:35:26.521] mysql_real_query(): SELECT `value`, FROM `player_skills` WHERE `skillid` = "..skillID.." - MYSQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `player_skills` WHERE `skillid` = "..skillID.."' at line 1 (1064)
 
It doest exist, im using tfs 0.4 but the problem is that there's a syntax error when i request the database information and that's why i get the nil value error, im trying to extract the skill level directly from the dabatase and this is what im using right now to do that:
Code:
                local skills = db.getResult('SELECT `value`, FROM `player_skills` WHERE `skillid` = "..skillID.."')
                local currentSkill = skills:getDataInt('value')
and this is the error im getting
Code:
[11:35:26.521] mysql_real_query(): SELECT `value`, FROM `player_skills` WHERE `skillid` = "..skillID.." - MYSQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `player_skills` WHERE `skillid` = "..skillID.."' at line 1 (1064)

Do you have a table called; player_skills
Does it have a column named; skillid
Remember to check if the player id aswell.

Also if you are using Linux make sure it's skillId insted of skillid etc
 
local skills = db.getResult('SELECT `value`, FROM `player_skills` WHERE `skillid` = "..skillID.."')
 

Similar threads

Replies
8
Views
1K
Evil Puncker
E
Back
Top