vitorelias1
New Member
- Joined
- Sep 27, 2022
- Messages
- 27
- Reaction score
- 2
Hi Guys!
The Demon Helmet Server - Version: (TFS 1.4)
Compiled with: Microsoft Visual C++ version 14.2
x64
I have this script but it is not working it is a command to buy skill it gives an error in the console
observations: it removes the item but does not add the skills and gives the error in the console.
needed a strength in this script. thank you!
The Demon Helmet Server - Version: (TFS 1.4)
Compiled with: Microsoft Visual C++ version 14.2
x64
I have this script but it is not working it is a command to buy skill it gives an error in the console
observations: it removes the item but does not add the skills and gives the error in the console.
needed a strength in this script. thank you!
Lua:
SKILL_CLUB = "skill_club"
SKILL_DISTANCE = "skill_dist"
SKILL_SHIELD = "skill_shielding"
SKILL_MAGLEVEL = "maglevel"
SKILL_SWORD = "skill_sword"
SKILL_AXE = "skill_axe"
local buyComprar = TalkAction("!buy")
local storage = 45611
local coinID = 9971 -- currency to buy skills
local skills = {
["magiclevel"] = {vocations = {1, 5, 2, 6, 11, 12}, voc_msg= "Only Sorcerers, Druids and Infernalists can buy magic level.", lim = 200, lim_msg = "You cannot have magic level above 200.", price= 3, incre = 1, skill = 7},
}
function buyComprar.onSay(player, words, param)
local player = Player(player)
local pid = player:getGuid()
local tile = player:getTile()
local param = param:lower()
if not tile:hasFlag(TILESTATE_PROTECTIONZONE) then
player:sendCancelMessage("You need to be in protected area to use this command.")
return true
end
if player:getStorageValue(storage) >= os.time() then
player:sendCancelMessage("For security reasons you can only use this command in " .. player:getStorageValue(storage)-os.time() .. " seconds.")
return true
end
if skills[param] then
local v = skills[param]
if param == "magiclevel" and player:getBaseMagicLevel() >= v.lim or (player:getBaseMagicLevel() + v.incre ) >= v.lim then
player:sendCancelMessage(v.lim_msg) return true
elseif player:getSkillLevel(v.skill) + v.incre >= v.lim then
print("oooooookay") -- here you have to stop the code
player:sendCancelMessage(v.lim_msg) return true
end
if not isInArray(v.vocations, player:getVocation():getId()) then
player:sendCancelMessage(v.voc_msg)
return true
end
if player:getItemCount(coinID) >= v.price then
player:removeItem(coinID, v.price)
player:setStorageValue(storage, os.time()+1)
player:remove()
db.query("UPDATE players SET ".. v.skill .. " = " .. v.skill .. " + " .. v.incre .. " WHERE id = ".. pid)
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You do not have the necessary amount to buy.")
end
return true
end
return true
end
buyComprar:separator(" ")
buyComprar:register()