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

DextaaH

Member
Joined
Jul 24, 2011
Messages
335
Reaction score
7
Hi!

This might be a easy one, but i cant figure it out. NPC Benjamin is spamming alot but not every sec. But to often anyway. How to make it slower?

PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local thinkMsg = {
	"If you need help with letters or parcels, just ask me. I can explain everything.",
	"Hey, send a letter to your friend now and then. Keep in touch, you know.",
	"No, no, no, there IS no parcel bug, I'm telling you!",
	"Welcome to the post office!"
}

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 thinkCallback(cid)
	local rand = math.random(250)
	if thinkMsg[rand] then
		npcHandler:say(thinkMsg[rand])
	end
	return true
end

npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:addModule(FocusModule:new())

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Benjamin" script="data/npc/scripts/Benjamin.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="128" head="116" body="79" legs="117" feet="76" addons="0"/>
	<parameters>
		<parameter key="module_shop" value="1" />
		<parameter key="module_keywords" value="1" />
		<parameter key="shop_buyable" value="parcel,2595,15;letter,2597,8;" />
		<parameter key="message_greet" value="Hello. How may I help you |PLAYERNAME|? Ask me to {trade} if you would like to buy something. I can also explain the {mail} system."/>
		<parameter key="keywords" value="name;mail;frodo;" />
		<parameter key="keyword_reply1" value="My name is Benjamin, however not from the Royal Tibia Line." />
		<parameter key="keyword_reply2" value="The mail system? Hmm, you can purchase a {parcel}, {label}, or a {letter} to send information and goods accross the world. Remember to write their name on the first line and their city beneath it!" />
		<parameter key="keyword_reply3" value="Frodo? Shh...he may over hear us." />
		<parameter key="message_farewell" value="It was a pleasure to help you, |PLAYERNAME|."/>
		<parameter key="message_walkaway" value="Good bye..." />
		<parameter key="message_sendtrade" value="Here. Don't forget that you need to buy a label too if you want to send a parcel. Always write the name of the {receiver} in the first line and the name of the {city} in the second line." />
	</parameters>
</npc>
 
maybe this 1 xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Benjamin" script="data/npc/scripts/benjamin.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="128" head="116" body="79" legs="117" feet="76" addons="0"/>
    <parameters>
        <parameter key="message_greet" value="Hello. How may I help you |PLAYERNAME|? Ask me for a {trade} if you want to buy something. I can also explain the {mail} system."/>
        <parameter key="message_farewell" value="It was a pleasure to help you, |PLAYERNAME|."/>
        <parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="mail;letters;explain;depot;parcel;explain;" />
        <parameter key="keyword_reply1" value="With our mail system you can send {letters} and {parcels} to other Tibians. I can either explain how {letters} and {parcels} work or sell them to you if you ask me for a {trade}." />
        <parameter key="keyword_reply2" value="If you want to buy a letter, ask me for a {trade}. Or do you want me to {explain} how letters work?" />
        <parameter key="keyword_reply3" value="With a letter you can send a message to another Tibian's {depot}. If you want to send it to 'Ben' in 'Thais', use the letter - so that a form opens - and write 'Ben' in the first line and 'Thais' in the second line. Write your message below that. ..." />
        <parameter key="keyword_reply4" value="Each major city has at least one depot. Just step in front of one of the lockers and you can store items inside. Your mail will also arrive there. Each city has its own storage, don't forget where you store items!" />
        <parameter key="keyword_reply5" value="If you want to buy a parcel, ask me for a {trade}. Or do you want me to {explain} how parcels work?" />
        <parameter key="keyword_reply6" value="In a parcel you can send items to another Tibian's {depot}. Put your items into the parcel and also place a completed {label} with the name and the {city} of the {receiver} inside. Then drag your parcel on one of the blue {mailboxes} here to send it." />

        <parameter key="module_shop" value="1"/>
        <parameter key="shop_buyable" value="parcel,2595,15;letter,2597,8;label,2599,1;" />
        <parameter key="shop_sellable" value="" />
    </parameters>
</npc>

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

npcHandler:addModule(FocusModule:new())

sry if i missunderstood cus i jst wakeup
 
Back
Top Bottom