Lopaskurwa
Active Member
- Joined
- Oct 6, 2017
- Messages
- 873
- Solutions
- 2
- Reaction score
- 49
Hello,
so i did my first working npc script which works just fine but there is one weird problem that i cant figure out how to fix it
Sorry if code structure is terrible since im newbie. So there problem is when i type "no" it sends "Oh, well then not!" but it doesnt cancel npc basically i can flood that "no" keyword and it will flood "Oh, well then not!" as well.
TFS 1.2
so i did my first working npc script which works just fine but there is one weird problem that i cant figure out how to fix it
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
local config = {
minLevel = 350,
pos = {x = 1007, y = 1160, z = 7},
}
function creatureSayCallback(cid, type, msg)
local player = Player(cid)
if(not npcHandler:isFocused(cid)) then
return false
end
if config.minLevel and config.minLevel > 0 and player:getLevel() < config.minLevel then
npcHandler:say(string.format("You don't have %s level.", config.minLevel), cid)
elseif(msgcontains(msg, 'yes')) then
npcHandler:say("Okay then!", cid)
doTeleportThing(cid, config.pos)
elseif(msgcontains(msg, 'no')) then
npcHandler:say("Oh, well then not!", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
TFS 1.2