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

Lua Npc Script

hasbro

Member
Joined
Feb 15, 2009
Messages
287
Reaction score
6
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local Topic = {}
local storage = 100168
 
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 greetCallback(cid)
	Topic[cid] = 0
	return true
end

local cormaya_cost = 160

function creatureSayCallback(cid, type, msg)
        if (not npcHandler:isFocused(cid)) then return false end
	if (msgcontains(msg, 'no') and Topic[cid] >= 1) then
		npcHandler:say("You shouldn\'t miss the experience.",cid)
		Topic[cid] = 0
	end 						
if msgcontains(msg,"farmine") then
	if getPlayerStorageValue(cid,57787) == -1 then
	  npcHandler:say("Well, you might be just the hero they need there. To tell you the truth, some our most reliable ore mines have started to run low. ...",cid)
		npcHandler:say("This is why we developed new steamship technologies to be able to further explore and cartograph the great subterraneous rivers. Our brothers have established a base on a continent far, far away. ...",cid,3000)
			npcHandler:say("We call that the far, far away base. But since it will hopefully become a flourishing mine one day, most of us started to call it Farmine. The dwarfs there could really use some help right now. ...",cid,3000)
		npcHandler:say("Would you like to go to Farmine for 200 gold?",cid,3000)	
    Topic[cid] = 3
	setPlayerStorageValue(cid,57787,1)
	else
		 npcHandler:say("Would you like to go to Farmine for 200 gold?",cid)	
		 setPlayerStorageValue(cid,57787,1)
	end
 elseif getPlayerStorageValue(cid,57787) == 1 then
 if  msgcontains(msg,'yes') then
		 if doPlayerRemoveMoney(cid,110) then
		 if getPlayerStorageValue(cid,1015) < 10 then
		 doTeleportThing(uid,newposold)
		 local newposold = {x=33025, y=31553, z=14} 
		 end
		 else
		 npcHandler:say("Then not.",cid)
		end
	end
 end
	if (msgcontains(msg, "cormaya") and getPlayerStorageValue(cid,storage) == 3) then
   		npcHandler:say("Do you seek a ride to Cormaya for "..cormaya_cost.." gold coins?",cid)
		Topic[cid] = 1
	elseif (Topic[cid] == 1) then
	if (msgcontains(msg, 'yes') and doPlayerRemoveMoney(cid,cormaya_cost)) then
		doTeleportThing(cid,{x=33311, y=31989, z=15})
		doSendMagicEffect({x=33311, y=31989, z=15},CONST_ME_TELEPORT)
		setPlayerStorageValue(cid,storage, 4)
		setPlayerStorageValue(cid,100171,6)
	else
		npcHandler:say("You dont have enough of gold.",cid)
		end
	end
	if (msgcontains(msg, "cormaya")) and (getPlayerStorageValue(cid,storage) == -1 or getPlayerStorageValue(cid,storage) >= 4) then
   		npcHandler:say("Do you seek a ride to Cormaya for "..cormaya_cost.." gold coins?",cid)
		Topic[cid] = 2
  	elseif (Topic[cid] == 2) then
	if (msgcontains(msg, 'yes') and doPlayerRemoveMoney(cid,cormaya_cost)) then
		doTeleportThing(cid,{x=33311, y=31989, z=15})
		doSendMagicEffect({x=33311, y=31989, z=15},CONST_ME_TELEPORT)
	else
		npcHandler:say("You dont have enough of gold.",cid)
		end
	end	
	return true	
end

       

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

This doesn't work..
Lua:
if msgcontains(msg,"farmine") then
	if getPlayerStorageValue(cid,57787) == -1 then
	  npcHandler:say("Well, you might be just the hero they need there. To tell you the truth, some our most reliable ore mines have started to run low. ...",cid)
		npcHandler:say("This is why we developed new steamship technologies to be able to further explore and cartograph the great subterraneous rivers. Our brothers have established a base on a continent far, far away. ...",cid,3000)
			npcHandler:say("We call that the far, far away base. But since it will hopefully become a flourishing mine one day, most of us started to call it Farmine. The dwarfs there could really use some help right now. ...",cid,3000)
		npcHandler:say("Would you like to go to Farmine for 200 gold?",cid,3000)	
    Topic[cid] = 3
	setPlayerStorageValue(cid,57787,1)
	else
		 npcHandler:say("Would you like to go to Farmine for 200 gold?",cid)	
		 setPlayerStorageValue(cid,57787,1)
	end
 elseif getPlayerStorageValue(cid,57787) == 1 then
 if  msgcontains(msg,'yes') then
		 if doPlayerRemoveMoney(cid,110) then
		 if getPlayerStorageValue(cid,1015) < 10 then
		 doTeleportThing(uid,newposold)
		 local newposold = {x=33025, y=31553, z=14} 
		 end
		 else
		 npcHandler:say("Then not.",cid)
		end
	end
 end
 
Back
Top