PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Madman on 23 November, 2004, 17:59:53

Title: Clear OnTimer
Post by: Madman on 23 November, 2004, 17:59:53
Hi, i want to clear
NNicks = {}
ontimer...
But only if is one or more username in it...

This is beacuse i have more things to clear
and i only want to clear them if they have users in them..

--Crazy Animals 2.0 Script Powered by Demone.Astaroth
--//Modded By Madman
--//Called NuttyNicks instead
--//Added Timer
--//More Nicks Added

--Script temporarily gives to users a strange nick :)
--2 options (fixed and random nicks, always for the current session); stopping command clean the memory

--Commands:
--  !NNick fix -- Let's start the fixed NNickals' nick party!
--  !NNick on -- Let's start the random NNickals' nick party!
--  !NNick off -- Stop the parties

Bot = "NuttYNicks"
HubBot = frmHub:GetHubBotName() --//Gets The HubBots Name
HubName = frmHub:GetHubName() --//Gets The HubName
OpChat = frmHub:GetOpChatName() --//Gets The OpChats Name

NNick = 0

NuttyNicks = {
"Two-rostrum Platypus",
"Marmot drowning in the chocolate",
"Cold snowy bison",
"Antelope with feet in the cement",
"Hot Pigskin",
"Kiwi's beak",
"Twisting hamster",
"Demented anteater",
"Caffettiera che sta per esplodere",
"Emasculate crocodile",
"Thermo-tapir",
"Gnu beaten by demented fridges",
"Sucker shark with plastic teeth",
"Canary with sticky wings",
"Disgusting insect",
"Crane creeping without legs",
"Blind guide dog",
"Calamary with rostrum",
"Mad koala",
"Flamingo in the toilet",
"Salmon still talking on the plate",
"Door mat with noses",
"Beaks soup",
"Multipurpose octopus",
HubBot,
OpChat,
HubName,
"Madman Is The Devil",
"Werdis Nickus",
Bot,
}

NNicks = {}

NNTime = 1000 * 60 * 10

function Main()
frmHub:RegBot(Bot)
frmHub:GetHubBotName() --//Returns The Name Of The HubBot
frmHub:GetOpChatName() --//Returns The Name Of The OpChat-Bot
frmHub:GetHubName() --//Returns The HubName
end

function OnTimer()
NNicks=nil
NNick=0
StopTimer()
SendToAll(Bot, "Nutty Nicks Cleared")
end

function DataArrival(curUser, data)
s,e,cmd= strfind(data,"%b<>%s+(%S+)")
if NNick==1 then
if NNicks[curUser.sName]==nil then
NNicks[curUser.sName]=NuttyNicks[random(1, getn(NuttyNicks))]
end
end
if curUser.bOperator ~= nil then
s,e,cmd,status= strfind(data,"%b<>%s(.+)%s(.+)")
if (cmd == "!nn") then
if strfind(status, "fix") then
StopTimer()
SetTimer(NNTime)
StartTimer()
SendToAll(Bot, curUser.sName.. " made all nicks go weird")
NNick=1
elseif strfind(status, "off") then
SendToAll(Bot, curUser.sName.." made all nicks normal")
NNicks[curUser.sName]=nil
NNick=0
elseif strfind(status, "on") then
StopTimer()
SetTimer(NNTime)
StartTimer()
SendToAll(Bot, curUser.sName.. " made all nicks go weird")
NNick=2
end
return 1
end
end
if NNick==1 then
if not strfind(data, "$.+") then
s,e,mes = strfind(data, "%b<> (.*)")
if NNicks[curUser.sName]~=nil then
SendToAll(NNicks[curUser.sName], mes)
return 1
end
end
elseif NNick==2 then
if not strfind(data, "$.+") then
s,e,mes = strfind(data, "%b<> (.*)")
Nutty=NuttyNicks[random(1, getn(NuttyNicks))]
SendToAll(Nutty, mes)
return 1
end
end
end
Title:
Post by: enema on 23 November, 2004, 18:23:33
What does this bot should do anyway? (dont have time to run trough)
Title:
Post by: Madman on 23 November, 2004, 18:51:57
It changes the names on the users writing in main

[18:47:32] Madman made all nicks go weird
[18:47:51] This is with the
[18:47:58] command !nn fix
[18:48:06] Madman made all nicks go weird
[18:48:11] and this is
[18:48:24] with the
[18:48:35] command !nn on

It's me writing all the posts ;p

*edit*
Another Question
Is it posibole to have 2 timers?
like
StartNNTimer() and StartDrunkTimer()
and ofcourse set and stop to them...
Title:
Post by: Herodes on 23 November, 2004, 22:13:15
just use

function OnTimer()
NNicks = {}
end

it doesnt make any difference if there are any nicks in there or not ...


and as far as the multitimers are concerned check how much help you can find when searching the forum on "multi timer" ;)
Title:
Post by: Madman on 23 November, 2004, 23:49:39
Thanks i'll have a look at it tomorrow... to late for it now..

*edit*
So i looked at it anyway... ;p

I know it will clean the nicks..

But i want some kind of option...
for it to clean only if it contains nick or something... :/

Since i want to use 2 timers
SetTimer(DrunkTime)
SetTimer(NuttyNicks)
They are 2 diffrent commands on the timers...

The Drunk thing make the user not able to type and then the script types something from the table when the user tries to type....

The NuttyNick changes the nick on users writing in main..

The thing is that i want Drunk To last 5 min before it clened by the timer...
But the NuttyNick, should last 10 min instead...

The NuttyNick is only a part of my script....
Title:
Post by: Herodes on 24 November, 2004, 15:55:47
If you only have two tables to empty with one of them having the half interval of the other then y not make it like this ... ?sec = 1000
min = 60*sec

time1 = 5*min
tcount = 0

function Main()
SetTimer(sec)
StartTimer()
end

function OnTimer()
if tcount == time1 then
table1 = {}
tcount = 0
elseif tcoun == (time1/2) then
table2 = {}
end
end
Title:
Post by: Madman on 24 November, 2004, 19:37:23
Thanks, i'll give it a try.. =)