SixNine
Active Member
- Joined
- Dec 12, 2018
- Messages
- 452
- Reaction score
- 41
Hi
so im working on this code and im confused why it doesnt send my custom text from config when it should work like a charm i think Ignore the part that my code looks like it was made by 9 year old and its not clean
So when i type 'hi' he doesnt send any message just an empty text when it should send that text from config because of npcHandler:say(currentSaga.text, cid)
so im working on this code and im confused why it doesnt send my custom text from config when it should work like a charm i think Ignore the part that my code looks like it was made by 9 year old and its not clean
So when i type 'hi' he doesnt send any message just an empty text when it should send that text from config because of npcHandler:say(currentSaga.text, cid)
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 = {
teleport = {{x = 81, y = 607, z = 6}, "Beetle Juice Castle"},
}
local currentSaga = {
[75] = {text = "Hello, i need your help can you help me defeat beetlejuice hes on crack?", setSagaValue = 76, needLevel = 300, needPremium = true},
[76] = {text = "Are you ready to go back?.", setSagaValue = 76, needLevel = 300, needPremium = true},
[77] = {text = "Are you ready to go back?.", setSagaValue = 77, needLevel = 300, needPremium = true},
[78] = {text = "Are you ready to go back?.", setSagaValue = 78, needLevel = 300, needPremium = true},
[79] = {text = "Are you ready to go back?.", setSagaValue = 79, needLevel = 300, needPremium = true},
[80] = {text = "Are you ready to go back?.", setSagaValue = 80, needLevel = 300, needPremium = true}
}
function creatureSayCallback(cid, type, msg)
local player = Player(cid)
if not npcHandler:isFocused(cid) then
if msg == "hi" or msg == "hello" then
npcHandler:addFocus(cid)
npcHandler:say(currentSaga.text, cid)
npcHandler.topic[cid] = 1
else
return false
end
elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 1 then
local sagaValue = player:getStorageValue(Storage.Saga)
local currentSaga = currentSaga[sagaValue]
if not currentSaga then
npcHandler:say("Sorry, You cant do this saga.", cid)
return true
end
if currentSaga.needPremium and not player:isPremium() then
npcHandler:say("You don't have premium.", cid)
return true
end
if currentSaga.needLevel and player:getLevel() < currentSaga.needLevel then
npcHandler:say(string.format("You have to be stronger[%d level%s].", currentSaga.needLevel, currentSaga.needLevel > 1 and "s" or ""), cid)
return currentSaga
end
player:setStorageValue(Storage.Saga, currentSaga.setSagaValue)
npcHandler:say("Go now!", cid)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("You have been teleported to %s.", config.teleport[2]))
player:teleportTo(config.teleport[1])
npcHandler.topic[cid] = 0
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, "bye") then
npcHandler:say("Bye.", cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)