NPC [TFS 1.3] TestServer Assistant

Evil Puncker

I'd rather kiss a rattlesnake
Joined
May 30, 2009
Messages
5,925
Best answers
33
Reaction score
1,874
Location
160,54,7
Hello everyone, just a small and simple NPC based on the idea from this thread, CIPSoft, and trying to help this thread.

Enjoy it while it breaks apart 😁 (yeah the blessing part was removed since the check was never working and I don't know why)




What the NPC does:
  • Give 10 crystal coins to player (unlimited)
  • Give 50.000.000 experience to player (until lvl 350 only)


Install:
/*/data/npc create
Testserver Assistant.xml and add:​
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Testserver Assistant" script="Testserver Assistant.lua" walkinterval="0" floorchange="0" speechbubble="2">
    <health now="100" max="100" />
    <look type="134" head="127" body="103" legs="41" feet="89" addons="1" mount="0" />
</npc>
/*/data/npc/scripts create Testserver Assistant.lua and add:​
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)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

    if msgcontains(msg, "money") or msgcontains(msg, "gold") then
        selfSay("Enjoy your money.", cid)
        player:addItem(2160, 10)
        return
    end

    if msgcontains(msg, "exp") then
        if player:getLevel() >= 350 then
            selfSay("You can not take it anymore.", cid)
        else
            selfSay("Here you are.", cid)
            player:addExperience(50000000)
        end
        return
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_GREET, "Hey |PLAYERNAME|. I'm Testserver Assistant and I can give {money} and {experience} which will be useful for testing on " .. configManager.getString(configKeys.SERVER_NAME) .. " server.")

npcHandler:addModule(FocusModule:new())
If you have any issue or suggestion, feel free to say so!
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,340
Best answers
528
Reaction score
3,068
It's better practice to return true if what you're doing is successful, that way the NPC updates idle status.
 
Top