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
i dont get any errors in the console when booting up, but when i use the command i get this:
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