Fire Element
Member
- Name: Buy skill/magic level
- Test version: TFS 0.4_SVN
- Credits: fireelement and apocarai
- Example:
- !buy skillclub
- !buy magiclevel
Between in data/talkactions/talkactions.xml and add this tag:
Code:
<talkaction words="!buy;/buy" event="script" value="buyskill.lua"/>
Between in data/talkactions/talkactions.xml and add this script:
Lua:
function onSay(cid, words, param, channel)
local x = {
item = 9971,
amount = 10,
amountskill = 10,
limitskill = 340
}
local xml = {
item = 9971,
amount = 15,
amountml = 5,
limitml = 195
}
local pid = getPlayerGUID(cid)
local id = {
["skillclub"] = 1,
["skillsword"]= 2,
["skillaxe"] = 3,
["skilldistance"] = 4,
["skillshielding"] = 5
}
local voc = {
["skillclub"] = {4, 8},
["skillsword"] = {4, 8},
["skillaxe"] = {4, 8},
["skilldistance"] = {3, 7},
["skillshielding"] = {4, 8}
}
local vocml = {1, 2, 5, 6}
local pz = "yes"
if(pz == "yes") and (getTilePzInfo(getCreaturePosition(cid)) == false) then
doPlayerSendCancel(cid, "You need be in protect zone to buy.")
return true
end
if (param == '') then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Example: !buy skillshielding.")
return true
end
if (param == 'magiclevel') then
if getPlayerMagLevel(cid) <= xml.limitml then
if isInArray(vocml, getPlayerVocation(cid)) == true then
if doPlayerRemoveItem(cid, xml.item, xml.amount) then
doRemoveCreature(cid, true)
db.executeQuery("UPDATE `players` SET `maglevel` = `maglevel` + ".. xml.amountml .." WHERE `id` = ".. pid .. "")
else
doPlayerSendCancel(cid, "You don't have required item.")
end
else
doPlayerSendCancel(cid, "You can't buy magic level.")
end
else
doPlayerSendCancel(cid, "You've reached the limit of magic level.")
end
return true
end
if(id[param:lower()]) then
if(getPlayerSkill(cid, id[param:lower()]) <= x.limitskill) then
if isInArray(voc[param:lower()], getPlayerVocation(cid)) == true then
if doPlayerRemoveItem(cid, x.item, x.amount) then
doRemoveCreature(cid, true)
db.executeQuery("UPDATE `player_skills` SET `value` = `value` + ".. x.amountskill .." WHERE `player_id` = ".. pid .. " and `skillid` = ".. id[param:lower()] ..";")
else
doPlayerSendCancel(cid, "You don't have required item.")
end
else
doPlayerSendCancel(cid, "You can't buy this skill.")
end
else
doPlayerSendCancel(cid, "You've reached the limit of this skill.")
end
else
doPlayerSendCancel(cid, "Unknown skill.")
end
return true
end