Hello there! I just got back to Tibia to start scripting for a friend again but when I sat down to script I realized I had almost forgot everything about it....
So after I've read through a ton of scripts I tried to do an own one which is a npc who is supposed to teleport you to a location if you got the correct lvl when you talk to him.
Well my question is if someone could take a look at it real quick and see if it's correct atm or if there is anything that needs to get changed.
All comments are welcome!
This is for 8.54 core btw.
So after I've read through a ton of scripts I tried to do an own one which is a npc who is supposed to teleport you to a location if you got the correct lvl when you talk to him.
Well my question is if someone could take a look at it real quick and see if it's correct atm or if there is anything that needs to get changed.
All comments are welcome!
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 telepos = {x = xxx, y = xxx, z = xx}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'fight') then
selfSay('Okey young one, you are here to fight demonic creatures? Am I right?', cid) then
if msgcontains(msg, 'yes') then
selfSay('Then what would you like to face? {lightweight} creatures, {normal} creatures, {stronger} creatures or {DAFUQ} WHAT AM I FIGHITING?', cid)
end
end
if msgcontains(msg, 'lightweight') then
selfSay('Are you sure that you want to fight the lightweight creatures?', cid) then
if msgcontains(msg, 'yes') then
if(getPlayerLevel(cid) > x) then
doTeleportPlayer(cid, telepos)
else
selfSay('Come back when you have grown up kiddo!', cid)
talk_state = 0
end
end
elseif msgcontains(msg, 'normal') then
selfSay('Are you sure that you want to fight the normal creatures?', cid) then
if msgcontains(msg, 'yes') then
if(getPlayerLevel(cid) > x) then
doTeleportPlayer(cid, telepos)
else
selfSay('Come back when you have grown up kiddo!', cid)
talk_state = 0
end
elseif msgcontains(msg, 'stronger') then
selfSay('Are you sure that you want to fight the stronger creatures?', cid) then
if msgcontains(msg, 'yes') then
if(getPlayerLevel(cid) > x) then
doTeleportPlayer(cid, telepos)
else
selfSay('Come back when you have grown up kiddo!', cid)
talk_state = 0
end
elseif msgcontains(msg, 'dafuq') then
selfSay('Have you really thought about this? There is no way back from this insane creatures!', cid) then
if msgcontains(msg, 'yes') then
if(getPlayerLevel(cid) > x) then
doTeleportPlayer(cid, telepos)
else
selfSay('Come back when you have grown up kiddo!', cid)
talk_state = 0
end
This is for 8.54 core btw.
Last edited by a moderator: