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

Clean npc!

Saj

Remember my name
Joined
Feb 26, 2008
Messages
2,127
Reaction score
6
Hey, I use this code
Code:
cleanTime = 3600 -- clean every 60 minutes
warnTime = 10 -- gives 30 second warning
lastclean = 0
focus = 0
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 Global floor clean in "..warnTime.." seconds.")
lastclean = os.time()
hasWarned = 1
end
if os.difftime (os.time(), lastclean) >= (warnTime) and hasWarned == 1 then
selfSay('/clean')
lastclean = os.time()
hasWarned = 0
end
end

Too clean but it doesn't clean, could anyone help me?
 
Err like this maybe? :p
PHP:
-- Config ;D
CLEAN = {
	TIME=1*60*6, -- clean each hour
	MESSAGE = "Server is cleaning..."
}
WARN = {
	INTERVAL=30, -- Warns 30 seconds before the clean.
	TIMES = 3, -- how many times to warn before the clean?
	MESSAGE = "Cleaning in 30 seconds."
}

-- Don't touch!
LAST_CLEAN = os.time()
TIMES_WARNED = WARN.TIMES
function onThink()
	if (os.time()-LAST_CLEAN) >= (cleanTime-(WARN.INTERVAL*TIMES_WARNED)) then
		selfSay("/B "..WARN.MESSAGE)
		TIMES_WARNED = TIMES_WARNED-1
		if TIMES_WARNED == 0 then 
			selfSay("/clean")
			LAST_CLEAN = os.time()
			TIMES_WARNED = WARN.TIMES
		end
	end
end

Not tested ^.^
 
Last edited:
it doesnt work it says :
clean2.lua:9: '>' expected <to close '<' at line 6> 'Message'

ps: I use TFS.
 
Simple error LOL, just a "," missed, try again (updated)

and get your siggy outta my screen! stupid endless animation with 10000k images in it, GRRR lags da shit outta my comp -.-
 
I will remove my sig and I will try that out.

EDIT : I get this error now : clean2.lua:16: attempt to perform arithmetic on global 'cleantime' <a nil value>
 
Last edited:
That your saying is there is no way I can make a npc or something to clean the server without me? :S
 
Code:
local CLEAN_FREQUENCE = 3600 -- seconds

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

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())
Easiest auto-cleaning NPC for trunk, will add it to repository in my next commit.
 
Last edited:
Yes... compile trunk and run it with npc script Elf give you. Or you'll need to compile your own cleaning :wink: .

@Elf

You can add more warning messages, nuub. XD // Polskie; Odpisz na gadu na pytanie me ;[
 
Last edited:
Back
Top Bottom