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

Three npc scripts

gr33nd3v1l

You see a Green Devil.
Joined
Feb 12, 2008
Messages
140
Reaction score
0
Location
Croatia
My idea was to make a quest of this sort:

You need to talk to the old pirate, ask him about pirates and he tells you to go find a drunk pirate somewhere on the island. When you find him, he is scared of you and yells "Ghost!", at that moment a storage value is added on the player. When you come back to the old pirate he gives you a hat and tells you to find Jack, the captain. When you find jack you complete the quest and receive a pirate shirt, boots, hook, peg leg, eye patch and those blue pirate briefs.

This is what i managed to compile on my own, i am using Jiddo's npc system i think.

This is the drunk pirate, he isn't supposed to talk to you, only add a storagevalue and yell help every time you say hi.
Code:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Hicks!')
          focus = 0
          talk_start = 0
  	end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
  	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
  	msg = string.lower(msg)
  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
 		selfSay('You\'s aa.. Pirate? No\'s you.. You\'s a ghost! Help! HEELP!')
focus == cid
setPlayerStorageValue(cid, 7667)
focus == 0
  	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Hicks!')
		elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
			selfSay('Hicks!')
			focus = 0
			talk_start = 0
		end
	end



function onCreatureChangeOutfit(creature)

end


function onThink()
	if focus > 0 then 
		x, y, z = creatureGetPosition(focus)
		myx, myy, myz = selfGetPosition()
		
		if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then
			selfTurn(1)
		end 
		if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
			selfTurn(3)
		end
		if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
			selfTurn(2)
		end
		if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
			selfTurn(0)
		end
		if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
			selfTurn(2)
		end
		if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
			selfTurn(0)
		end
		if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
			selfTurn(3)
		end
		if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
			selfTurn(1)
		end
		if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
			selfTurn(2)
		end
		if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
			selfTurn(0)
		end
		if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
			selfTurn(3)
		end
		if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
			selfTurn(1)
		end
		if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
			selfTurn(2)
		end
		if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
			selfTurn(0)
		end
		if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
			selfTurn(3)
		end
		if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
			selfTurn(1)
		end
	end

end

This is the old pirate.
Code:
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


npcHandler:addModule(FocusModule:new())
function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return false
	end
		if msgcontains(msg, 'pirate') then
		if getPlayerStorageValue(cid, 7667) == -1 then
  		selfSay('Well now, ' .. getCreatureName(cid) .. '! You do look like a pirate, maybe if you do something like a pirate you can be one! Pirates must be explorers, see if you can find a Drunk Pirate around here.')
			else
			if getPlayerStorageValue(cid, 7668) == -1 then
			selfSay('Good, very good. Find Jack somewhere here and talk to him. Tell him i sent you, and take this with you.')
			setPlayerStorageValue(cid, 7668)
			doPlayerAddItem(cid, 6096, 1)
				else
				selfSay('Go find Jack!')
				end

			end
		end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

And sice these 2 didn't work together, i havent even started on Jack ;)

Oh and i only compiled this using common sense, logic thinking, and other npc scripts. I am no scripter so be gentle with the flaming please =\
 
Last edited:
First of all we will never start flamming for searching for help, And specially when u have tryt to script!

I'm worryd about the first script since it's builded in the old npc system try to rescript it in the new npc system like script 2 =).

Here are some tips:
Make an storage check in script 1 so it will only set an storage value when u have spoken with the quest started or else it will be useless.

if u have some bugs dont mind to pm me i'm here to help people who put effort in there scripts!
 
Ok im gonna try and find which part of the new npc script goes HI so i can delete it xD

ED:

I can't figure out how to remove the greetings part without the script not working so im gonna change the whole script =\
He won't be drunk, he'll just be Hidden Pirate, and he will act paranoic and stuff ;)
 
Last edited:
First of all we will never start flamming for searching for help, And specially when u have tryt to script!

I'm worryd about the first script since it's builded in the old npc system try to rescript it in the new npc system like script 2 =).

Here are some tips:
Make an storage check in script 1 so it will only set an storage value when u have spoken with the quest started or else it will be useless.

if u have some bugs dont mind to pm me i'm here to help people who put effort in there scripts!

Old NPCs works with Jiddos system, how he said himself.
 
Back
Top