PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: b_w_johan on 12 March, 2005, 22:32:17

Title: client checker
Post by: b_w_johan on 12 March, 2005, 22:32:17
--1) create bot discription ed                  --working
--2) send botname and discription to userlist            --working
--3.1) start timer1                     --working
--3.2) start timer2                     --making it work
--4) check connected user for TAG               --
--5) check if this TAG is in a file called clients.txt if not add.   --
--6) check if this TAG is already in the userlist.         --
--7) if its in already send PM                  --
--8) and disconnect.                     --
--9) if timer1 reaches 0 then send prefix            --
--10) if timer2 reaches 0 send clients.txt            --
--11) if command !client send clients.txt            --
--12) if command !prefix send prefix.txt            --
--13) if command !addtag then add this tag to the clients.txt   --
-- Maded by b_w_johan, TTB, Psvoo7
-- Maded for SCRIP']['ERS ELI']['E

BOTName = "[LUA4]Guard"
BOTDiscription = "LUA4 Scripted"
BOTVersion = "A1"
BOTTag = "<++v:"..BOTVersion.." "..BOTName..",M;A.H:0/0/3,S:0>"
BOTConnection = "2fst4u"
BOTMail = "dc.client@gmail.com"
BOTInfo = "$MyINFO $ALL "..BOTName.." "..BOTDiscription.." "..BOTTag.."$ $"..BOTConnection.." "..strchar(1).."$"..BOTMail.."$"

tag = "<[LUA4]Bot>"
info = "$MyINFO $ALL "..BOTName.." "..BOTDiscription.." "..tag.."$ $"..BOTConnection.." "..strchar(1).."$"..BOTMail.."$"

sec  = 1000
min  = sec*60
hour = min*60
days = hour*24

clientlist = 1*days
--prefix = 5*hours



function Main()
   frmHub:RegBot(BOTName)
   SendToAll("This hub is protected by [LUA5]Guard BOT")
   SetTimer(clientlist)
   StartTimer()
--   SetTimers(prefix)
--   StartTimer("1")
end

function OpConnected(user)
user:SendData(BOTInfo)
end
function NewUserConnected(user)
user:SendData(info)
end

function OnTimer()
   Sendclientlist()
end

--function OnTimer("1")
--   Sendprefix()
--end

function Sendclientlist()
SendToAll("test")
end

function Sendprefix()
SendToAll("\r\nList of User Discription\r\n\r\n[DCD]   =   DC Destroyer\r\n[XRZ]   =   Nothing Special yust Special Option for our webhost/Lua scripter/JAVA programmer =-p\r\n[LUA]   =   Lua Bot writer good in both 4&5\r\n[LUA4]   =   Lua4 Bot writer\r\n[LUA5]   =   Lua5 Bot writer\r\n[HTM]   =   Web(HTML)Scripter\r\n[JAS]   =   Web(java)Scripter\r\n[php]   =   Web(PHP)Scripter\r\n[JAV]   =   JAVA Programmer\r\n[VB]   =   Visual Basic Programmer\r\n[CPP]   =   C++ Programmer\r\n")
end

making samescript in both LUA 4 and 5 ....
but also the problem that i don't know how to add a second timer....

please help me with the timer rest of script ill try to make myself (maybe with some help from you all here =-p )=-p

greetings Johan
Title:
Post by: b_w_johan on 15 March, 2005, 16:07:14
is it impossible or something to have 2 timers in 1 script ??


if its possible can someone help me with it then ???

greetings Johan
Title:
Post by: Pothead on 15 March, 2005, 16:47:38
Just use the same timer, just reference it at the times you want. :)

**Edit for example

--Initilize shit
prefixcount = 0;
clientcount = 0;
prefixtime = 100000;
clienttime = 200000;

-- On Timer
function OnTimer ()
   prefixcount ++; clientcount++;
   if prefixcount > prefixtime then
        Send Prefix;
        prefixcount = 0;
   end
   if clientcount > clienttime then
        Send Client;
        clientcount = 0;
   end
end
Title:
Post by: [UK]Madman on 15 March, 2005, 17:06:40
An example in Lua 4 is phattys multitimer

>> Click (http://board.univ-angers.fr/thread.php?threadid=609&boardid=12&sid=829820222be4e2d5c7765defed3b6d52)  <<
Title:
Post by: b_w_johan on 17 March, 2005, 13:41:42
Thx for the reply's,

Syntax error: `=' expected;
  last token read: `+' at line 50 in file `...tings\Administrator.SERVER.000\Bureaublad\ptokax\scripts\test.lua'

this error i get while using potheads scrip=-p


--1) create bot discription ed --working
--2) send botname and discription to userlist --working
--3.1) start timer1 --working
--3.2) start timer2 --making it work
--4) check connected user for TAG --
--5) check if this TAG is in a file called clients.txt if not add. --
--6) check if this TAG is already in the userlist. --
--7) if its in already send PM --
--8) and disconnect. --
--9) if timer1 reaches 0 then send prefix --
--10) if timer2 reaches 0 send clients.txt --
--11) if command !client send clients.txt --
--12) if command !prefix send prefix.txt --
--13) if command !addtag then add this tag to the clients.txt --
-- Maded by b_w_johan, TTB, Psvoo7, Tejo
-- Maded for SCRIP']['ERS ELI']['E

BOTName = "[LUA4]Guard"
BOTDiscription = "LUA4 Scripted"
BOTVersion = "A1"
BOTTag = "<++v:"..BOTVersion.." "..BOTName..",M;A.H:0/0/3,S:0>"
BOTConnection = "2fst4u"
BOTMail = "dc.client@gmail.com"
BOTInfo = "$MyINFO $ALL "..BOTName.." "..BOTDiscription.." "..BOTTag.."$ $"..BOTConnection.." "..strchar(1).."$"..BOTMail.."$"

tag = "<[LUA4]Bot>"
info = "$MyINFO $ALL "..BOTName.." "..BOTDiscription.." "..tag.."$ $"..BOTConnection.." "..strchar(1).."$"..BOTMail.."$"

sec  = 1000
min  = sec*60
hour = min*60
days = hour*24

prefixcount = 0;
clientcount = 0;
prefixtime = 6*hour;
clienttime = 5*hour;

function Main()
frmHub:RegBot(BOTName)
SendToAll("This hub is protected by [LUA4]Guard BOT")
SetTimer()
StartTimer()

end

-- On Timer
function OnTimer ()
   prefixcount++; clientcount++;
   if prefixcount > prefixtime then
        SendPrefix;
        prefixcount = 0;
   end
   if clientcount > clienttime then
        SendClient;
        clientcount = 0;
   end
end




function OpConnected(user)
user:SendData(BOTInfo)
end
function NewUserConnected(user)
user:SendData(info)
end


function Sendclient()
SendToAll("test")
end

function Sendprefix()
SendToAll("\r\nList of User Discription\r\n\r\n[DCD] = DC Destroyer\r\n[XRZ] = Nothing Special yust Special Option for our webhost/Lua scripter/JAVA programmer =-p\r\n[LUA] = Lua Bot writer good in both 4&5\r\n[LUA4] = Lua4 Bot writer\r\n[LUA5] = Lua5 Bot writer\r\n[HTM] = Web(HTML)Scripter\r\n[JAS] = Web(java)Scripter\r\n[php] = Web(PHP)Scripter\r\n[JAV] = JAVA Programmer\r\n[VB] = Visual Basic Programmer\r\n[CPP] = C++ Programmer\r\n")
end


maybe im yust forgetting something =-p but ill try phattys multitmimer now lets see if i can get that working =-p

greetings Johan
Title:
Post by: Pothead on 17 March, 2005, 14:24:43
lol, i not suprised, i only wrote it as an example.  I dunno if  
++ works in in LUA.  You might have to try e.g. prefixcount = prefixcount + 1;

Same for the other counter.  Also in timer it's calling SendPrefix and SendClient , which don't exist.  Have a closer look at the capital letters. :)
Title:
Post by: b_w_johan on 17 March, 2005, 15:41:56
ok i take a look at phatys timer so its something like this:

-- On Timer
function OnTimer ()
   if prefixcount = 1 then
     prefixcount = prefixcount + 1
   clientcount = clientcount + 1
        Sendprefix()
        prefixcount = 0
   end
   if clientcount = 2 then
        Sendclient()
        clientcount = 0
   end
end

(but its still not working ....)

can someone help me???

greetings Johan
Title:
Post by: Pothead on 17 March, 2005, 16:10:53
You are missing somthing in
SetTimer()
;)


**Edit
And you screwed up the ontimer() part.  Just the code i gave you and make the corrections i said in the previous post. ?(
Title:
Post by: b_w_johan on 17 March, 2005, 17:28:35
ok maybe you can explain som more ......

you said i had to change the --on Timer part .... cause it didn't work so i used a bit of Madmans/phatty's post ... what is missing by SetTimer() ??
or do you meen i have to let it the way it was in my first post (clientlist) in here ????
Title:
Post by: Pothead on 17 March, 2005, 17:45:05
SetTimer() sets the timer to 0.
SetTimer(1) sets the timer to 1ms.
SetTimer(1000) sets the timer to 1 second.  
(well that's what i think the values represent in time)

--Initilize shit
prefixcount = 0;
clientcount = 0;
prefixtime = 100000;
clienttime = 200000;

-- On Timer
function OnTimer ()
   prefixcount = prefixcount + 1
   clientcount = clientcount + 1

   if prefixcount > prefixtime then
        Sendprefix();
        prefixcount = 0;
   end
   if clientcount > clienttime then
        Sendclient();
        clientcount = 0;
   end
end