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

The Orc King

Godely

Member
Joined
Aug 19, 2007
Messages
233
Reaction score
19
Well, I tried it all the day and couldn't make it. In the older versions of NPCs, where you used to configure the "hi" on the .lua file, I could do it. But now, as almost everything is on the xml file, I can't. I tried to use those interactions things but couldn't do.

The Orc King is a NPC that you say "hi" and he summons 2 orc warlods, 2 orc leaders and 4 slimes around you. He also add a StorageValue, so if you greet he again, he won't summon anymore.

If anyone can do it, I will be greatful.

Thanks.
 
In fact, it's like that:
k8qd8vgpgreendjinnquestscreen5.png


I know how to make it, just hang on...
 
Shouldn't this do the job:

Lua Code (orcking.lua)
PHP:
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


function greetCallback(cid)
    if getPlayerStorageValue(cid,17050) == -1 then
	

        npcHandler:say('Arrrrgh! A dirty paleskin! To me my children! Kill them my guards!')
	pos = getCreaturePosition(getNpcCid())

	local northEast = {x=pos.x+1,y=pos.y-1,z=pos.z}
	local northWest = {x=pos.x-1,y=pos.y-1,z=pos.z}
	local southEast = {x=pos.x+1,y=pos.y+1,z=pos.z}
	local southWest = {x=pos.x-1,y=pos.y+1,z=pos.z}
	local East = {x=pos.x+1,y=pos.y,z=pos.z}
	local West = {x=pos.x-1,y=pos.y,z=pos.z}
	local South = {x=pos.x,y=pos.y+1,z=pos.z}
	local North = {x=pos.x,y=pos.y+1,z=pos.z}

		doSummonCreature('Orc Warlord', northWest)
		doSummonCreature('Orc Warlord', West)
		doSummonCreature('Orc Leader', southWest)
		doSummonCreature('Orc Leader', South)
		doSummonCreature('Orc Leader', southEast)
		doSummonCreature('Slime', East)
		doSummonCreature('Slime', northEast)
		doSummonCreature('Slime', North)

	SetPlayerStorageValue(cid,17050,1)
        return false
    else
        return true
    end
end
 
-- Set the greeting callback function
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
 
npcHandler:setMessage(MESSAGE_GREET, 'Harrrrk! You think you are strong now? You shall never escape my wrath! I am immortal!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'We will meet again.')


npcHandler:addModule(FocusModule:new())

XML File (The Orc King.xml)
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="The Orc King" script="data/npc/scripts/orcking.lua" walkinterval="2000">
	<health now="1000" max="1000"/>
	<look type="238" head="10" body="20" legs="30" feet="40" addons="0"/>
</npc>

I haven't tested it yet...
 
Last edited:
Code:
[21/01/2009 13:49:29] Lua Script Error: [Npc interface] 
[21/01/2009 13:49:29] data/npc/scripts/random places/the orc king.lua:onCreatureSay

[21/01/2009 13:49:29] data/npc/lib/npcsystem/npchandler.lua:576: table index is nil
[21/01/2009 13:49:29] stack traceback:
[21/01/2009 13:49:29] 	data/npc/lib/npcsystem/npchandler.lua:576: in function 'say'
[21/01/2009 13:49:29] 	data/npc/scripts/random places/the orc king.lua:15: in function 'callback'
[21/01/2009 13:49:30] 	data/npc/lib/npcsystem/npchandler.lua:322: in function 'greet'
[21/01/2009 13:49:30] 	data/npc/lib/npcsystem/npchandler.lua:490: in function 'onGreet'
[21/01/2009 13:49:30] 	data/npc/lib/npcsystem/modules.lua:217: in function 'callback'
[21/01/2009 13:49:30] 	data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
[21/01/2009 13:49:30] 	data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
[21/01/2009 13:49:30] 	data/npc/lib/npcsystem/keywordhandler.lua:128: in function 'processMessage'
[21/01/2009 13:49:30] 	data/npc/lib/npcsystem/npchandler.lua:371: in function 'onCreatureSay'
[21/01/2009 13:49:30] 	data/npc/scripts/random places/the orc king.lua:7: in function <data/npc/scripts/random places/the orc king.lua:7>

:P
 
If not, change to this (two fixes, removed 'do' and change the dot into a comma sign):
setPlayerStorageValue(cid, 17050, 1)

EDIT: Just read your error messages and it seems that's not the reason why it's producing errors lmao. Rizz you fool! :<
 
If not, change to this (two fixes, removed 'do' and change the dot into a comma sign):
setPlayerStorageValue(cid, 17050, 1)

EDIT: Just read your error messages and it seems that's not the reason why it's producing errors lmao. Rizz you fool! :<

it was because I was already posting before he posted, check the timestamps.
 
Edit: Some changes... Here is the NPC, working perfectly now:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="The Orc King" script="data/npc/scripts/random places/the orc king.lua" walkinterval="2000">
    <health now="100" max="100"/>
    <look type="238"/>
    <parameters>
	  <parameter key="message_farewell" value="LEAVE!"/>
	  <parameter key="message_walkaway" value="YES, LEAVE!"/>
	  <parameter key="message_idletimeout" value="LEAVE!"/>

        <parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="job;name;orc fortress;fortress;orc;dark;cathedral;offer;human;mission;quest" />
        <parameter key="keyword_reply1" value="HOW DARE YOU TO ASK MY JOB? I AM THE ORC KING. THAT IS MY JOB, RRRUMAN!" />
        <parameter key="keyword_reply2" value="You dun need to know my name... I'm the orc king." />
        <parameter key="keyword_reply3" value="You are in our fortress. How dare you to kill my citizens?" />
        <parameter key="keyword_reply4" value="You are in our fortress. How dare you to kill my citizens?" />
        <parameter key="keyword_reply5" value="I am theirrr king!" />
        <parameter key="keyword_reply6" value="OFFER? ARE YOU ASKING FOR AN OFFER? LEAVE, NOW!" />
        <parameter key="keyword_reply7" value="HA HA HA! LEAVE, YOU ARE MAKING ME MAD!" />
        <parameter key="keyword_reply8" value="HUMAN... YOU, HUMANS, MAKE THE WORLD WORSE!" />
        <parameter key="keyword_reply9" value="Do you really want a mission? Ok, the mission is: Leave the orc fortress immediatly!" />
        <parameter key="keyword_reply10" value="Do you really want a mission? Ok, the mission is: Leave the orc fortress immediatly!" />
    </parameters>
</npc>

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


function greetCallback(cid)
	if getPlayerStorageValue(cid,3058) == -1 then
		selfSay('Arrrrgh! A dirty paleskin! Kill them my guards!', cid)
		pos = getCreaturePosition(getNpcCid())

		local northEast = {x=pos.x+1,y=pos.y-1,z=pos.z}
		local northWest = {x=pos.x-1,y=pos.y-1,z=pos.z}
		local southEast = {x=pos.x+1,y=pos.y+1,z=pos.z}
		local southWest = {x=pos.x-1,y=pos.y+1,z=pos.z}
		local East = {x=pos.x+1,y=pos.y,z=pos.z}
		local West = {x=pos.x-1,y=pos.y,z=pos.z}
		local South = {x=pos.x,y=pos.y+1,z=pos.z}
		local North = {x=pos.x,y=pos.y-1,z=pos.z}

		doSummonCreature('Orc Warlord', northWest)
		doSummonCreature('Orc Warlord', West)
		doSummonCreature('Orc Leader', southWest)
		doSummonCreature('Orc Leader', South)
		doSummonCreature('Orc Leader', southEast)
		doSummonCreature('Slime', East)
		doSummonCreature('Slime', northEast)
		doSummonCreature('Slime', North)
		setPlayerStorageValue(cid,3058,1)
	else
		return TRUE
	end
end
 
-- Set the greeting callback function
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_GREET, 'Arrrgh! Again?! What do you want?')
npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top