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

TFS 1.X+ NPC Mount & Addon.

Pedrook

Advanced OT User
Joined
May 24, 2009
Messages
442
Solutions
3
Reaction score
183
Location
Brazil
someone could help me, not to be able to sell "addon" also in npc, only to mount that was until now.

Code:
[Warning - NpcScript::NpcScript] Can not load script: Veradin.lua
data/npc/scripts/Veradin.lua:22: unexpected symbol near 'local'

Lua:
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 creatureSayCallback(cid, type, msg)
    local player = Player(cid)
    local mounts =
    {
        ["Azudocus"] = {tokens = 775, mountId = 44},
        ["Carpacosaurus"] = {tokens = 775, mountId = 45},
        ["Platesaurian"] = {tokens = 775, mountId = 37},
        ["Armoured War Horse"] = {tokens = 425, mountId = 23},
        ["Crimson Ray"] = {tokens = 525, mountId = 33},
        ["Steelbeak"] = {tokens = 525, mountId = 34},
    },

        local outfits =
    {
        ["Entrepreneur"] = {tokens = 775, mountId = 471},
        ["Recruiter"] = {tokens = 525, mountId = 745},
        ["Jersey"] = {tokens = 425, mountId = 619},
    }
   
    if(not npcHandler:isFocused(cid)) then
        return false
    end
   
    if msg == "mounts" then
        npcHandler:say("Mounts available at the moment {Azudocus}, {Carpacosaurus}, {Platesaurian}, {Armoured War House}, {Crimson Ray} and {Steelbeak}.", cid)
        elseif msg == "outfits" then
            npcHandler:say("Outfits available at the moment {Entrepreneur}, {Recruiter} and {Jersey}.", cid)
        end
        else
            npcHandler:say("Sorry, choose another option as a reward.", cid)
        end   
        return true
    end
   
if msgcontains(msg, 'balance') then
       npcHandler:say("You have {"..player:getTokens().."} Crown Tokens.", cid)
        return true
    end
   
    if mounts[msg] then
        if not player:hasMount(mounts[msg].mountId) then
            if player:getTokens() >= mounts[msg].tokens then
                npcHandler:say("You were rewarded with the mount {"..msg.."} for "..mounts[msg].tokens.." Crown Tokens", cid)
                player:removeTokens(mounts[msg].tokens)
                player:addMount(mounts[msg].mountId)
            else
                npcHandler:say("You need to {"..mounts[msg].tokens.." Crown Tokens} to receive this mount.", cid)
            end
        else
            npcHandler:say("You already own this mount.", cid)
        end
    else
        npcHandler:say("The mount {"..msg.."} does not exist.", cid)
    end
    return true
end

    if outfits[msg] then
        if not player:hasMount(outfits[msg].mountId) then
            if player:getTokens() >= outfits[msg].tokens then
                npcHandler:say("You were rewarded with the mount {"..msg.."} for "..outfits[msg].tokens.." Crown Tokens", cid)
                player:removeTokens(outfits[msg].tokens)
                player:addMount(outfits[msg].mountId)
            else
                npcHandler:say("You need to {"..outfits[msg].tokens.." Crown Tokens} to receive this outfit.", cid)
            end
        else
            npcHandler:say("You already own this outfit.", cid)
        end
    else
        npcHandler:say("The outfit {"..msg.."} does not exist.", cid)
    end
    return true
end

keywordHandler:addKeyword({'crown tokens'}, StdModule.say, {npcHandler = npcHandler, text = "Crown Tokens are a kind of tokens that you can exchange for rewards, with each level you pick up counting from the 20 you will automatically receive 5 Crown Tokens, to check how many you already have, say {balance} or {trade} to exchange for some reward."})
keywordHandler:addKeyword({'trade'}, StdModule.say, {npcHandler = npcHandler, text = "To exchange and receive your reward choose what you want: {outfits}, {mounts}."})

npcHandler:setMessage(MESSAGE_GREET, "Welcome |PLAYERNAME|. I can offer rewards in exchange for {Crown Tokens}.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye and enjoy your stay in Thoria, |PLAYERNAME|.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
local mounts =
    {
        ["Azudocus"] = {tokens = 775, mountId = 44},
        ["Carpacosaurus"] = {tokens = 775, mountId = 45},
        ["Platesaurian"] = {tokens = 775, mountId = 37},
        ["Armoured War Horse"] = {tokens = 425, mountId = 23},
        ["Crimson Ray"] = {tokens = 525, mountId = 33},
        ["Steelbeak"] = {tokens = 525, mountId = 34},
    }, <-- REMOVE THIS ","
 
Back
Top