• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction !buy skill/magic level

Fire Element

Member
Joined
Sep 10, 2010
Messages
193
Reaction score
22
Location
Brazil
  • Name: Buy skill/magic level
  • Test version: TFS 0.4_SVN
  • Credits: fireelement and apocarai
  • Example:
    1. !buy skillclub
    2. !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
 
That's a really nice idea. Thanks for the code, it will be put to good use in my server. :D
 
Back
Top