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

Ldrozd

Piszę skrypty w zeszycie.
Joined
Dec 13, 2008
Messages
430
Reaction score
2
Location
Guess where!
Hu guys!
I have problem with my NPC. I dont know what I am doing wrobg. Could help me with it. Tell me what is wrong. I count on you :D

/travel.lua
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local getPlayer = getThingFromPos(getPlayerPosition(cid))
	-- config --
	local position = {x=1122, y=867, z=7}
	local itemId = 5896
	local count = 1
	if(msgcontains(msg, 'orange island')) then
		npcHandler:say("You are fucking orange, so I will teleport you to orange island for 5 bear paws. Deal?", cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes')) then
		if(talkState[talkUser] == 1) then
			if(doPlayerRemoveItem(cid, itemId, count) == TRUE) then
				doTeleportThing(cid, position, 0)
				npcHandler:say("Good, let's go!", cid)
			else
				npcHandler:say("You don't have " .. count .. " " .. itemId .. "s you fucking orangesucker!", cid)
			end
		end
	end
	return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

/captain_hook.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Hook" script="travel.lua" walkinterval="2000" floorchange="0">  <~~ [b]its correct now, but still doesnt work[/b]
	<health now="100" max="100"/>
	<look type="128" head="17" body="54" legs="114" feet="0"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|."/>
	</parameters>
</npc>
 
Last edited:
If you are using script named "travel.lua" then why are you trying to load script "data/npc/scripts/data/npc/scripts/captain.lua"? Yeah, I wrote path LIKE THAT because you don't need to use "data/npc/scripts" anymore. Simply write
Code:
script="travel.lua"

PS. Posts: 1,337 :D
 
Back
Top