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

NPC Cleaning with Delay?

Kungenn

Veteran OT User
Joined
Jun 10, 2007
Messages
1,623
Reaction score
282
Location
USA California
Hello, okay right on now :p

Okay so what I want is an NPC that cleans.

How to?

Well I'm not very good at this but I guess have the NPC selfsay /clean.

But with a delay.

I'll just write how I imagine the NPC.

Delay 45 Minutes
Broadcast ( Clean in 15 minutes. )
Delay 5 Minutes
Broadcast ( Clean in 10 minutes. )
Delay 5 Minutes
Broadcast ( Clean in 5 minutes. )
Delay 5 Minutes
selfsay /clean

Then loop from the start :)

Something like that,
or if possible, to have it in global.lua so I wont need an NPC but it doesn't really matter.. :p Which ever is the easiest.

Just want it to clean every hour to make the server run smoother.


Thanks in advance :)



Edit;

Though it should be possible in global.lua since the save function works like this, or so it seems to me atleast :p

Tried to do some experimental work but didn't really work :p
 
local cleanTime = 3600
local warnTime = 900
local warnTime1 = 600
local warnTime2 = 300
local warnTime3 = 30
local lastclean = 0
local focus = 0
local hasWarned = 0
function onThink()
if lastclean == 0 then
lastclean = os.time()
end
if os.difftime (os.time(), lastclean) >= (cleanTime-warnTime) and hasWarned == 0 then
selfSay("/B Clean in 15 minutes.")
lastclean = os.time()
hasWarned = 4
end
if os.difftime (os.time(), lastclean) >= (cleanTime-warnTime1) and hasWarned == 1 then
selfSay("/B Clen in 10 minutes.")
lastclean = os.time()
hasWarned = 3
end
if os.difftime (os.time(), lastclean) >= (cleanTime-warnTime2) and hasWarned == 2 then
selfSay("/B Clean in 5 minutes.")
lastclean = os.time()
hasWarned = 2
end
if os.difftime (os.time(), lastclean) >= (cleanTime-warnTime3) and hasWarned == 3 then
selfSay("/B Clean in 30s.")
lastclean = os.time()
hasWarned = 1
end
if os.difftime (os.time(), lastclean) >= (warnTime) and hasWarned == 4 then
selfSay('/clean')
lastclean = os.time()
hasWarned = 0
end
end
Not my Script.
 
Tried it as you posted it changed local time to 155 to see if it boardcasts, which it doesn't :/ And the script above, the NPC just say /B Clean blabla

It doesn't come as a broadcast.

The NPC has access="5" aswell.
 
Code:
local CLEAN_FREQUENCE = 3600 -- seconds

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
[b]local cleanTimer = CLEAN_FREQUENCE / 2 -- onThink for npc is fired every 2 seconds[/b]

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()
	cleanTimer = cleanTimer - 1
	if cleanTimer == 150 then
		doBroadcastMessage("Game map cleaning in 5 minutes.");
	elseif cleanTimer == 90 then
		doBroadcastMessage("Game map cleaning in 3 minutes.");
	elseif cleanTimer == 30 then
		doBroadcastMessage("Game map cleaning in 1 minute, please pick up your items!");
	elseif cleanTimer == 0 then
		cleanMap()
		cleanTimer = CLEAN_FREQUENCE / 2
	end

	npcHandler:onThink()
end

npcHandler:addModule(FocusModule:new())
 
[22/05/2008 12:58:07] Lua Script Error: [Npc interface]
[22/05/2008 12:58:07] data/npc/scripts/cleaner.lua:eek:nThink

[22/05/2008 12:58:07] data/npc/scripts/cleaner.lua:20: attempt to call global 'cleanMap' (a nil value)

What to do? I'm using TFS 0.2.12.
 
Is there a script like this but for Online and Regular server saving for TFS?

So I Dont have to leave it on for 24 hours just to edit some characters...
 
i tryed both scripts... the on posted in this thread works... but all it does is make's the npc say "/B clean blah" but not broadcasting it...

The other script does totaly nothing once so ever... im using the latest tfs (The Forgotten Server - Version 0.2rc12 (Mystic Spirit).)


So yea......

Anyways...

Any ideas?!?



And when i tryed to combine them.. (just added the broadcastmsg part)
i get this:

Code:
[15/06/2008  10:34:55] Lua Script Error: [Npc interface] 
[15/06/2008  10:34:55] data/npc/scripts/Clean.lua:onThink

[15/06/2008  10:34:55] data/npc/scripts/Clean.lua:14: attempt to call global 'BroadcastMessage' (a nil value)
Or when i left it as dobroadcast
Code:
[15/06/2008  10:34:56] Lua Script Error: [Npc interface] 
[15/06/2008  10:34:56] data/npc/scripts/Clean.lua:onThink

[15/06/2008  10:34:56] data/npc/scripts/Clean.lua:14: attempt to call global 'doBroadcastMessage' (a nil value)

And i am useing the newest tfs!
 
Last edited:
Back
Top