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

Addon NPC problem TFS 1.0 [Varkhal]

CesarZ

Well-Known Member
Joined
Sep 20, 2012
Messages
269
Solutions
4
Reaction score
63
When I try to buy addons from this men this come up.
Capture otland.PNG

This is the NPC addon Script
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)    npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                        npcHandler:onThink()                        end

function buyAddons(cid, message, keywords, parameters, node)
    --TODO: buyAddons function in modules.lua
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local addon = parameters.addon
    local cost = parameters.cost
    local premium = (parameters.premium ~= nil and parameters.premium)

    if isPlayerPremiumCallback == nil or (isPlayerPremiumCallback(cid) and premium) then
        if doPlayerRemoveMoney(cid, cost) == TRUE then
            doPlayerAddAddons(cid, addon)
            npcHandler:say('There, you are now able to use all addons!', cid)
        else
            npcHandler:say('Sorry, you do not have enough money.', cid)
        end
    else
        npcHandler:say('I only serve customers with premium accounts.', cid)
    end

    keywordHandler:moveUp(1)
    return true
end

local node1 = keywordHandler:addKeyword({'first addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first addons set for 5000 gold coins?'})
    node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = 5000, premium = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to buy the second addons set for 10000 gold coins?'})
    node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = 10000, premium = true})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell the first addons set for 5000 gold coins and the second addons set for 10000 gold coins.'})

npcHandler:addModule(FocusModule:new())


He talks and all, but once i say Yes to buy the Addon, i don,t get them and the server window bring up a error.
I'm running my server's database thru MYSQL, phpmyadmin ect.. The server client is 10.41
 
Solution
E
tfs 1.x doesn't have doPlayerAddAddons function that is why it gives that error

but you can see these two scripts for ideas:
tfs 1.x doesn't have doPlayerAddAddons function that is why it gives that error

but you can see these two scripts for ideas:
 
Solution
Solved with Addondoll Script. tested on a TFS 1.0 client 10.41 worked fine

Script should be added and registered in talkaction folder
Code:
local config = {
    ['citizen'] = { male = 128, female = 136 },
    ['hunter'] = { male = 129, female = 137 },
    ['mage'] = { male = 130, female = 141 },
    ['knight'] = { male = 131, female = 139 },
    ['summoner'] = { male = 133, female = 138 },
    ['warrior'] = { male = 134, female = 142 },
    ['barbarian'] = { male = 147, female = 143 },
    ['druid'] = { male = 148, female = 144 },
    ['wizard'] = { male = 149, female = 145 },
    ['oriental'] = { male = 150, female = 146 },
    ['pirate'] = { male = 151, female = 155 },
    ['assassin'] = { male = 152, female = 156 },
    ['beggar'] = { male = 153, female = 157 },
    ['shaman'] = { male = 154, female = 158 },
    ['norseman'] = { male = 251, female = 252 },
    ['nightmare'] = { male = 268, female = 269 },
    ['jester'] = { male = 273, female = 270 },
    ['brotherhood'] = { male = 278, female = 279 },
    ['demonhunter'] = { male = 289, female = 288 },
    ['yalaharian'] = { male = 325, female = 324 },
    ['warmaster'] = { male = 335, female = 336 },
    ['wayfarer'] = { male = 367, female = 366 },
    ['afflicted'] = { male = 430, female = 431 },
    ['elementalist'] = { male = 432, female = 433 },
    ['deepling'] = { male = 463, female = 464 },
    ['insectoid'] = { male = 465, female = 466 },
    ['crystal warlord'] = { male = 512, female = 513 },
    ['soil guardian'] = { male = 516, female = 514 },
    ['demon'] = { male = 541, female = 542 },
    ['cave explorer'] = { male = 574, female = 575 },
    ['dream warden'] = { male = 577, female = 578 }
}

function onSay(cid, words, param)
    local targetOutfit = config[param:lower()]
    if not targetOutfit then
        return false
    end

    local player = Player(cid)
    if player:getSex() == 0 then
        if param == 'mage' then
            targetOutfit.female, targetOutfit.male = 138, 133
        elseif param == 'summoner' then
            targetOutfit.female, targetOutfit.male = 141, 130
        end
    end

    if player:hasOutfit(player:getSex() == 0 and targetOutfit.female or targetOutfit.male, 3) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have already obtained the ' .. param .. ' addons.')
        return false
    end

    if not player:removeItem(8982, 1) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You need an addon doll.')
        return false
    end

    player:addOutfitAddon(targetOutfit.female, 3)
    player:addOutfitAddon(targetOutfit.male, 3)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have received the ' .. param .. ' addons!')
    player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
    return false
end
 
Back
Top