Author Topic: How to change Settings through cmd?  (Read 3737 times)

0 Members and 1 Guest are viewing this topic.

Offline BottledHate

  • Triple Ace
  • **
  • Posts: 244
  • Karma: +2/-0
How to change Settings through cmd?
« on: 28 September, 2004, 03:25:29 »
requested by: Psycho_Chihuahua http://board.univ-angers.fr/thread.php?threadid=1735&boardid=4&styleid=1&page=1#9

here's how i set up commands in a scipt....

Code: [Select]

rUserDefined = {
cmd1 = "!cmd1",
cmd2 = "!cmd2",
cmd3 = "!cmd3",
}

function DataArrival(user, data)
   if (strsub(data, 1, 1) == "<" ) then
      data= strsub(data,1,strlen(data)-1)
      ------------
      local _,_,c =strfind(data, "%b<> (%S*)") --//find the first word.
      if CommandsTable[c] and user.bOperator then --//is the first word a command? ops only...
      local _,_,c,parms1=strfind(data, "%b<>%s+(%S+)%s*(.*)") --//fing the stuff after the word (parms1)
      CommandsTable[c](user,parms1)--//call the funciton forthe command with the arguments required.. (user and parm1)
      end
      ------------
   end
end

---------------------------------------
CommandsTable = {
   [rUserDefined.cmd1] = function(u,p1)--// (u,p1)user and parm1 sent from data arival
      --//do stuff!
      if p1 ~= "" then
         u:SendData("Command 1 triggered with parms: "..p1)
      else
         u:SendData("Command 1 triggered...")
      end
   end,
-------------------------    
  [rUserDefined.cmd2] = function(u)
      --//executecrap!
      SendToMain=1
      u:SendData("Command 2 triggered...")
   end,
-------------------------    
  [rUserDefined.cmd3] = function(u)
      --//...
      SendToMain=0
      u:SendData("Command 3 triggered...")
   end,
-------------------------    
}



there are pleny of other ways to do it.. i've foung this is fast... keeps the data arrival clean from too much command stuff, and it's easy to go back and edit the functions for each command later down the line...

hope this helps!

-BH


« Last Edit: 28 September, 2004, 03:34:25 by BottledHate »
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

PtokaX forum

How to change Settings through cmd?
« on: 28 September, 2004, 03:25:29 »

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
(No subject)
« Reply #1 on: 28 September, 2004, 03:31:56 »
thnx m8, i hope so to

gonna check it out right away
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline BottledHate

  • Triple Ace
  • **
  • Posts: 244
  • Karma: +2/-0
(No subject)
« Reply #2 on: 28 September, 2004, 03:35:02 »
made a couple little changes to make it easier dor u to see where to put your stuff at... ;)

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
(No subject)
« Reply #3 on: 28 September, 2004, 03:51:29 »
yeah, thnx  :D  a lot clearer now  :P

but i'll check it out tomorrow morning, gotta go to bed now.....my eyes are opened with toothpicks already
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
(No subject)
« Reply #4 on: 28 September, 2004, 18:55:25 »
Tryed doing a bit of Code shuffling to get further with my former request...just doesnt work sofar..

Code: [Select]
--AdTimer 1.0
--
--by American Idiot
--Yet another Hub Advert script
--Addon by Psycho-Chihuahua
--Sends hub Advert on timer or by command
--in Main or by PM
--
assert(dofile("Ad/Settings.cfg"),"error, settings file not present")
HubMsg1 = "Auf Deutsch --> [URL]http://www.dc-stammtisch.de[/URL]"
HubMsg2 = "In English --> [URL]http://board.univ-angers.fr[/URL]"
--

function Main()
SetTimer(mins*60000)
StartTimer()
end

function DataArrival(user, data)
s,e,cmd = strfind(data, "%b<>%s+(%S+)(%S+)")
if (cmd==Prefix..AdComm) and user.bOperator then
OnTimer()  
end
end




function TimerMsg()
local tmp
tmp = "\r\n\r\n\t---<>-------------------------------------------------------------------------------------<>---\r\n"  
tmp = tmp.."\t\t[ "..frmHub:GetHubName().." ]\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tHub Name: \t"..frmHub:GetHubName().."\r\n" -- add/remove tabs ' \t '  ...to center hub name
tmp = tmp.."\tHub Owner: \t"..HubOwner.."\r\n"
tmp = tmp.."\tHub Addy: \t"..Hubaddy.."\r\n"
tmp = tmp.."\tHub Zeit: \t( "..date("%H:%M").." ) -- "..TZone .."\r\n"
tmp = tmp.."\tHub Desc: \t"..frmHub:GetHubDescr().."\r\n"
tmp = tmp.."\tUmleitungs Addy: \t"..frmHub:GetRedirectAddress().."\r\n"
tmp = tmp.."\tReg Server: \t"..frmHub:GetRegServer().."\r\n"  
tmp = tmp.."\tRedirect Alle: \t"..RedirAll().."\r\n"
tmp = tmp.."\tRedirect Voll: \t"..RedirFull().."\r\n"
tmp = tmp.."\tMax Users: \t"..frmHub:GetMaxUsers().."\r\n"
tmp = tmp.."\tMin Share: \t"..frmHub:GetMinShare().."\r\n"
tmp = tmp.."\tHub Share: \t"..frmHub:GetCurrentShareAmount().."\r\n"
tmp = tmp.."\tMasters Online: \t\t"..CountMaster().."\r\n"
tmp = tmp.."\tOps Online: \t\t"..CountOPs().."\r\n"
tmp = tmp.."\tVips Online: \t\t"..CountVIPs().."\r\n"
tmp = tmp.."\tRegs Online: \t\t"..CountRegUsers().."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tTotal Online: \t\t"..frmHub:GetUsersCount().."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tHilfe zu DC++, Hubsoft und Scripts gibts in diesen Foren:\r\n"
tmp = tmp.."\t-- "..HubMsg1.."\r\n"
tmp = tmp.."\t-- "..HubMsg2.."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tMitteilung(en):\r\n"
tmp = tmp.."\t-- "..InfoMsg1.."\r\n"
tmp = tmp.."\t-- "..InfoMsg2.."\r\n"
tmp = tmp.."\t-- "..InfoMsg3.."\r\n"
tmp = tmp.."\t-- "..InfoMsg4.."\r\n"
tmp = tmp.."\t-- "..InfoMsg5.."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
end

function OnTimer()
   if SendAs=="PM" then
SendPmToAll(TimerMsg(), tmp)
    elseif SendAs=="MAIN" then
SendData(TimerMsg(), tmp)
    end
end

function RedirAll()
rdstatusall = frmHub:GetRedirectAll()
rastatus = ""
if rdstatusall == 1 then
rastatus = "on"
else
rastatus = "off"
end
return rastatus
end

function RedirFull()
rdstatusfull = frmHub:GetRedirectFull()
--local tmp, rdstatusfull = frmHub:GetRedirectFull(),0;
rfstatus = ""
if rdstatusfull == 1 then
rfstatus = "on"
else
rfstatus = "off"
end
return rfstatus
end

function CountMaster()
local tmp, count = GetUsersByProfile(GetProfileName(0)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end

function CountOPs()
local tmp, count = GetUsersByProfile(GetProfileName(1)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
function CountVIPs()
local tmp, count = GetUsersByProfile(GetProfileName(2)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
function CountRegUsers()
local tmp, count = GetUsersByProfile(GetProfileName(3)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end

well Botname shows correctly  :D  but thats it lol i hope someone sees what i'm trying to do here.
I woul like these parts of (AD/Settings.cfg) to be customizable by using cmd's.

Code: [Select]
mins = 180
SendAs = "MAIN" -- or PM
and the amount of InfoMsgx lines



here the settings.cfg atm
Code: [Select]
--User Settings-------------------------------------------------------------------------------------
-- bot = "HubInfo" -- wenn der bot einen eigenen Namen tragen soll dann l?sche die n?chste Zeile
bot = frmHub:GetHubBotName() -- Name des bots
mins = 180 -- Interval [in minuten] zwischen Ads
Hubaddy = "helvetia.ath.cx" -- Doh?
HubOwner = "Johnnie" -- Doh?
Prefix = "+" -- Prefix f?r den Befehl
AdComm = "werbung" -- Befehl um Ad direkt zu senden
TZone = " +1 GMT [EST]" -- Zeit Zone des hubs
SendAs = "MAIN" -- Wie soll der Ad angezeigt werden [MAIN oder PM]
--Eigene Meldungen---------------------------------------------------------------------------------
InfoMsg1 = "Hier kannste" -- Diese Meldungen
InfoMsg2 = "eigene Meldungen" -- kommen unterhalb der
InfoMsg3 = "reinschreiben" -- Werbung f?r die Foren
InfoMsg4 = ""
InfoMsg5 = "oder leer lassen"
--Ende User Settings--------------------------------------------------------------------------------
Never mind the German Lines *g there just for the one i got working so far (settable to MAIN or PM Ad)
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline BottledHate

  • Triple Ace
  • **
  • Posts: 244
  • Karma: +2/-0
(No subject)
« Reply #5 on: 29 September, 2004, 10:31:09 »
here ya go... not tested... if there are errors, i'm sure you can fix them from here... ;)


Code: [Select]
--AdTimer 1.0
--
--by American Idiot
--Yet another Hub Advert script
--Addon by Psycho-Chihuahua
--Sends hub Advert on timer or by command
--in Main or by PM
--Addon by BottledHate 09/29/05
----added user defined commands.

assert(dofile("Ad/Settings.cfg"),"error, settings file not present")
HubMsg1 = "Auf Deutsch --> [URL]http://www.dc-stammtisch.de[/URL]"
HubMsg2 = "In English --> [URL]http://board.univ-angers.fr[/URL]"

----------------------------------------//no save function.. so setting revert to 'Ad/Settomgs.cfg' on script restart.
AdUserDefined = {
cmd1 = "adsendas",   --//toggle main or pm. (don't add prefix here. user prefix from setings.)
cmd2 = "admins",   --//set interval in minutes (... prefix blah blag...)
}
----------------------------------------
function Main()
SetTimer(mins*60000)
StartTimer()
end

function DataArrival(user, data)
local s,e,cmd,parm1 = strfind(data, "%b<>%s+(%S*)%s*(%S*)")
if AdUserDefined[Prefix..cmd] and user.bOperator then
         AdCommandsTable[cmd](user,parm1)
         return 1
      end
end

function TimerMsg()
local tmp
tmp = "\r\n\r\n\t---<>-------------------------------------------------------------------------------------<>---\r\n"  
tmp = tmp.."\t\t[ "..frmHub:GetHubName().." ]\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tHub Name: \t"..frmHub:GetHubName().."\r\n" -- add/remove tabs ' \t '  ...to center hub name
tmp = tmp.."\tHub Owner: \t"..HubOwner.."\r\n"
tmp = tmp.."\tHub Addy: \t"..Hubaddy.."\r\n"
tmp = tmp.."\tHub Zeit: \t( "..date("%H:%M").." ) -- "..TZone .."\r\n"
tmp = tmp.."\tHub Desc: \t"..frmHub:GetHubDescr().."\r\n"
tmp = tmp.."\tUmleitungs Addy: \t"..frmHub:GetRedirectAddress().."\r\n"
tmp = tmp.."\tReg Server: \t"..frmHub:GetRegServer().."\r\n"  
tmp = tmp.."\tRedirect Alle: \t"..RedirAll().."\r\n"
tmp = tmp.."\tRedirect Voll: \t"..RedirFull().."\r\n"
tmp = tmp.."\tMax Users: \t"..frmHub:GetMaxUsers().."\r\n"
tmp = tmp.."\tMin Share: \t"..frmHub:GetMinShare().."\r\n"
tmp = tmp.."\tHub Share: \t"..frmHub:GetCurrentShareAmount().."\r\n"
tmp = tmp.."\tMasters Online: \t\t"..CountMaster().."\r\n"
tmp = tmp.."\tOps Online: \t\t"..CountOPs().."\r\n"
tmp = tmp.."\tVips Online: \t\t"..CountVIPs().."\r\n"
tmp = tmp.."\tRegs Online: \t\t"..CountRegUsers().."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tTotal Online: \t\t"..frmHub:GetUsersCount().."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tHilfe zu DC++, Hubsoft und Scripts gibts in diesen Foren:\r\n"
tmp = tmp.."\t-- "..HubMsg1.."\r\n"
tmp = tmp.."\t-- "..HubMsg2.."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tMitteilung(en):\r\n"
tmp = tmp.."\t-- "..InfoMsg1.."\r\n"
tmp = tmp.."\t-- "..InfoMsg2.."\r\n"
tmp = tmp.."\t-- "..InfoMsg3.."\r\n"
tmp = tmp.."\t-- "..InfoMsg4.."\r\n"
tmp = tmp.."\t-- "..InfoMsg5.."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
end

function OnTimer()
   if SendAs=="PM" then
SendPmToAll(TimerMsg(), tmp)
    elseif SendAs=="MAIN" then
SendData(TimerMsg(), tmp)
    end
end

function RedirAll()
rdstatusall = frmHub:GetRedirectAll()
rastatus = ""
if rdstatusall == 1 then
rastatus = "on"
else
rastatus = "off"
end
return rastatus
end

function RedirFull()
rdstatusfull = frmHub:GetRedirectFull()
--local tmp, rdstatusfull = frmHub:GetRedirectFull(),0;
rfstatus = ""
if rdstatusfull == 1 then
rfstatus = "on"
else
rfstatus = "off"
end
return rfstatus
end

function CountMaster()
local tmp, count = GetUsersByProfile(GetProfileName(0)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end

function CountOPs()
local tmp, count = GetUsersByProfile(GetProfileName(1)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
function CountVIPs()
local tmp, count = GetUsersByProfile(GetProfileName(2)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
function CountRegUsers()
local tmp, count = GetUsersByProfile(GetProfileName(3)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
----------------------------------------
AdCommandsTable = {
   [AdUserDefined.cmd1] = function(u)--//toggle main or pm
      if SendAs == "MAIN" then
         SendAs = "PM"
         u:SendData("***AdTimer 1.0: Messages will be sent to PM***")
      else
         SendAs = "MAIN"
         u:SendData("***AdTimer 1.0: Messages will be sent to MAIN***")
      end
   end,
-------------------------    
  [AdUserDefined.cmd2] = function(u,p1) --//set minutes.
      p1 = tonumber(p1)
      if type(p1) == "number" then --//make sure the parm for minutes is a number.
         mins = p1
         StopTimer()
         Main()
         u:SendData("***AdTimer 1.0: mins set to: "..p1.."***")
      else --// parm not a number...
         u:SendData("***AdTimer 1.0: Error: Syntax: "..Prfefix..AdUserDefined.cmd2.."   -where = minutes.***"
      end
   end,
}
----------------------------------------


hope this helps!

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
(No subject)
« Reply #6 on: 01 October, 2004, 02:42:25 »
hmmm tried fiddling round with it but couldnt get it to work (guess i didnt get the drift of it)

What i need on this is

1. a pre set timer value i.e. "mins = 180"  (and a cmd to change its value while running)
and
2. To be able to switch from showing in PM and Main while running.


but i need to be able to use the old cmd's as well

like in this case +werbung to show ad immediatley....and i couldnt get that to work


this is what im using atm
Code: [Select]
--AdTimer 1.0
--
--by American Idiot
--modded by Psycho-Chihuahua
--Yet another Hub Advert script
--Sends hub Advert on timer or by command
--in Main or by PM
--
--User Settings-------------------------------------------------------------------------------------
bot = "HubInfo" -- Name des bots
mins = 180 -- Interval [in minuten] zwischen Ads
Hubaddy = "helvetia.ath.cx" -- Doh?
HubOwner = "Johnnie" -- Doh?
Prefix = "+" -- Prefix f?r den Befehl
AdComm = "werbung" -- Befehl um Ad direkt zu senden
TZone = " +1 GMT [EST]" -- Zeit Zone des hubs
SendAs = "MAIN" -- Wie soll die Werbung angezeigt werden [MAIN oder PM]
--End User Settings----------------------------------------------------------------------------------

--End of Settings File
--Beginning of script
HubMsg1 = "Auf Deutsch --> [URL]http://www.dc-stammtisch.de[/URL]"
HubMsg2 = "In English --> [URL]http://board.univ-angers.fr[/URL]"
--

function Main()
SetTimer(mins*60000)
StartTimer()
end

function DataArrival(user, data)
s,e,cmd = strfind(data, "%b<>%s+(%S+)(%S+)")
if (cmd==Prefix..AdComm) and user.bOperator then
OnTimer()  
end
end




function OnTimer()
local tmp
tmp = "\r\n\r\n\t---<>-------------------------------------------------------------------------------------<>---\r\n"  
tmp = tmp.."\t\t[ "..frmHub:GetHubName().." ]\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tHub Name: \t"..frmHub:GetHubName().."\r\n" -- add/remove tabs ' \t '  ...to center hub name
tmp = tmp.."\tHub Owner: \t"..HubOwner.."\r\n"
tmp = tmp.."\tHub Addy: \t"..Hubaddy.."\r\n"
tmp = tmp.."\tHub Zeit: \t( "..date("%H:%M").." ) -- "..TZone .."\r\n"
tmp = tmp.."\tHub Desc: \t"..frmHub:GetHubDescr().."\r\n"
tmp = tmp.."\tRedirect Addy: \t"..frmHub:GetRedirectAddress().."\r\n"
tmp = tmp.."\tReg Server: \t"..frmHub:GetRegServer().."\r\n"  
tmp = tmp.."\tRedirect Alle: \t"..RedirAll().."\r\n"
tmp = tmp.."\tRedirect Voll: \t"..RedirFull().."\r\n"
tmp = tmp.."\tMax Users: \t"..frmHub:GetMaxUsers().."\r\n"
tmp = tmp.."\tMin Share: \t"..frmHub:GetMinShare().."\r\n"
tmp = tmp.."\tHub Share: \t"..frmHub:GetCurrentShareAmount().."\r\n"
tmp = tmp.."\tMasters Online: \t\t"..CountMaster().."\r\n"
tmp = tmp.."\tOps Online: \t\t"..CountOPs().."\r\n"
tmp = tmp.."\tVips Online: \t\t"..CountVIPs().."\r\n"
tmp = tmp.."\tRegs Online: \t\t"..CountRegUsers().."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tTotal Online: \t\t"..frmHub:GetUsersCount().."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tOpen Hubs die f?r uns werben:\r\n"
tmp = tmp.."\t-- Biba`s-World - bibabu.homeip.net\r\n"
tmp = tmp.."\t-- Chiller German Hub - chillers.no-ip.com\r\n"
tmp = tmp.."\t--  ??????Garden of HELVETIA Hub?????? - gardenofhelvetia.ath.cx \r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tHilfe zu DC++, Hubsoft und Scripts gibts in diesen Foren:\r\n"
tmp = tmp.."\t-- "..HubMsg1.."\r\n"
tmp = tmp.."\t-- "..HubMsg2.."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
    if SendAs=="PM" then
SendPmToAll(bot,tmp)
    elseif SendAs=="MAIN" then
SendToAll(bot,tmp)
    end
end

function RedirAll()
rdstatusall = frmHub:GetRedirectAll()
rastatus = ""
if rdstatusall == 1 then
rastatus = "Aktiviert"
else
rastatus = "Deaktiviert"
end
return rastatus
end

function RedirFull()
rdstatusfull = frmHub:GetRedirectFull()
--local tmp, rdstatusfull = frmHub:GetRedirectFull(),0;
rfstatus = ""
if rdstatusfull == 1 then
rfstatus = "Aktiviert"
else
rfstatus = "Deaktiviert"
end
return rfstatus
end

function CountMaster()
local tmp, count = GetUsersByProfile(GetProfileName(0)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end

function CountOPs()
local tmp, count = GetUsersByProfile(GetProfileName(1)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
function CountVIPs()
local tmp, count = GetUsersByProfile(GetProfileName(2)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
function CountRegUsers()
local tmp, count = GetUsersByProfile(GetProfileName(3)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
« Last Edit: 01 October, 2004, 02:44:08 by Psycho_Chihuahua »
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline BottledHate

  • Triple Ace
  • **
  • Posts: 244
  • Karma: +2/-0
(No subject)
« Reply #7 on: 01 October, 2004, 05:08:43 »
Code: [Select]
--AdTimer 1.0
--
--by American Idiot
--modded by Psycho-Chihuahua
--Yet another Hub Advert script
--Sends hub Advert on timer or by command
--in Main or by PM
--
--User Settings-------------------------------------------------------------------------------------

AdUserDefined = {
cmd1 = "adsendas",   --//toggle main or pm. (don't add prefix here. user prefix from setings.)
cmd2 = "admins",   --//set interval in minutes (... prefix blah blag...)
}



bot = "HubInfo" -- Name des bots
mins = 180 -- Interval [in minuten] zwischen Ads
Hubaddy = "helvetia.ath.cx" -- Doh?
HubOwner = "Johnnie" -- Doh?
Prefix = "+" -- Prefix f?r den Befehl
AdComm = "werbung" -- Befehl um Ad direkt zu senden
TZone = " +1 GMT [EST]" -- Zeit Zone des hubs
SendAs = "MAIN" -- Wie soll die Werbung angezeigt werden [MAIN oder PM]
--End User Settings----------------------------------------------------------------------------------

--End of Settings File
--Beginning of script
HubMsg1 = "Auf Deutsch --> [URL]http://www.dc-stammtisch.de[/URL]"
HubMsg2 = "In English --> [URL]http://board.univ-angers.fr[/URL]"
--

function Main()
SetTimer(mins*60000)
StartTimer()
end



function DataArrival(user, data)
s,e,cmd = strfind(data, "%b<>%s+(%S+)(%S+)")
if (cmd==Prefix..AdComm) and user.bOperator then
OnTimer()  
end
local s,e,cmd,parm1 = strfind(data, "%b<>%s+(%S*)%s*(%S*)")
if AdUserDefined[strsub(cmd,2)] and user.bOperator then
         AdCommandsTable[cmd](user,parm1)
         return 1
      end
     
end




function OnTimer()
local tmp
tmp = "\r\n\r\n\t---<>-------------------------------------------------------------------------------------<>---\r\n"  
tmp = tmp.."\t\t[ "..frmHub:GetHubName().." ]\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tHub Name: \t"..frmHub:GetHubName().."\r\n" -- add/remove tabs ' \t '  ...to center hub name
tmp = tmp.."\tHub Owner: \t"..HubOwner.."\r\n"
tmp = tmp.."\tHub Addy: \t"..Hubaddy.."\r\n"
tmp = tmp.."\tHub Zeit: \t( "..date("%H:%M").." ) -- "..TZone .."\r\n"
tmp = tmp.."\tHub Desc: \t"..frmHub:GetHubDescr().."\r\n"
tmp = tmp.."\tRedirect Addy: \t"..frmHub:GetRedirectAddress().."\r\n"
tmp = tmp.."\tReg Server: \t"..frmHub:GetRegServer().."\r\n"  
tmp = tmp.."\tRedirect Alle: \t"..RedirAll().."\r\n"
tmp = tmp.."\tRedirect Voll: \t"..RedirFull().."\r\n"
tmp = tmp.."\tMax Users: \t"..frmHub:GetMaxUsers().."\r\n"
tmp = tmp.."\tMin Share: \t"..frmHub:GetMinShare().."\r\n"
tmp = tmp.."\tHub Share: \t"..frmHub:GetCurrentShareAmount().."\r\n"
tmp = tmp.."\tMasters Online: \t\t"..CountMaster().."\r\n"
tmp = tmp.."\tOps Online: \t\t"..CountOPs().."\r\n"
tmp = tmp.."\tVips Online: \t\t"..CountVIPs().."\r\n"
tmp = tmp.."\tRegs Online: \t\t"..CountRegUsers().."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tTotal Online: \t\t"..frmHub:GetUsersCount().."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tOpen Hubs die f?r uns werben:\r\n"
tmp = tmp.."\t-- Biba`s-World - bibabu.homeip.net\r\n"
tmp = tmp.."\t-- Chiller German Hub - chillers.no-ip.com\r\n"
tmp = tmp.."\t--  ??????Garden of HELVETIA Hub?????? - gardenofhelvetia.ath.cx \r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tHilfe zu DC++, Hubsoft und Scripts gibts in diesen Foren:\r\n"
tmp = tmp.."\t-- "..HubMsg1.."\r\n"
tmp = tmp.."\t-- "..HubMsg2.."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
    if SendAs=="PM" then
SendPmToAll(bot,tmp)
    elseif SendAs=="MAIN" then
SendToAll(bot,tmp)
    end
end

function RedirAll()
rdstatusall = frmHub:GetRedirectAll()
rastatus = ""
if rdstatusall == 1 then
rastatus = "Aktiviert"
else
rastatus = "Deaktiviert"
end
return rastatus
end

function RedirFull()
rdstatusfull = frmHub:GetRedirectFull()
--local tmp, rdstatusfull = frmHub:GetRedirectFull(),0;
rfstatus = ""
if rdstatusfull == 1 then
rfstatus = "Aktiviert"
else
rfstatus = "Deaktiviert"
end
return rfstatus
end

function CountMaster()
local tmp, count = GetUsersByProfile(GetProfileName(0)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end

function CountOPs()
local tmp, count = GetUsersByProfile(GetProfileName(1)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
function CountVIPs()
local tmp, count = GetUsersByProfile(GetProfileName(2)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
function CountRegUsers()
local tmp, count = GetUsersByProfile(GetProfileName(3)), 0;
if tmp then
for id = 0, getn(tmp) do
if GetItemByName(tmp[id]) then
count = count + 1;
end
end
end
return count
end
AdCommandsTable = {
   [AdUserDefined.cmd1] = function(u)--//toggle main or pm
      if SendAs == "MAIN" then
         SendAs = "PM"
         u:SendData("***AdTimer 1.0: Messages will be sent to PM***")
      else
         SendAs = "MAIN"
         u:SendData("***AdTimer 1.0: Messages will be sent to MAIN***")
      end
   end,
-------------------------    
  [AdUserDefined.cmd2] = function(u,p1) --//set minutes.
      p1 = tonumber(p1)
      if type(p1) == "number" then --//make sure the parm for minutes is a number.
         mins = p1
         StopTimer()
         Main()
         u:SendData("***AdTimer 1.0: mins set to: "..p1.."***")
      else --// parm not a number...
         u:SendData("***AdTimer 1.0: Error: Syntax: "..Prfefix..AdUserDefined.cmd2.."   -where = minutes.***"
      end
   end,
}
----------------------------------------
« Last Edit: 01 October, 2004, 05:13:06 by BottledHate »
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
(No subject)
« Reply #8 on: 02 October, 2004, 05:25:50 »
gr8t work there BH but this one of American Idiot's is a little easier for me to understand :D and all i had to change was the Language and the Hub Share from GB to TB

here's the english one adapted to TB for Current Hub Shareand corrected so PM is correctly PM'd  :D

Code: [Select]
--AdTimer 1.2
--
--by American Idiot
--Optimized by Optimus, thx
--
--Yet another Hub Advert script
--Sends hub Advert on timer or by command
--
--
--User Settings-------------------------------------------------------------------------------------
bot = "HubAd" -- Name for bot
mins = 180 -- Interval [in minutes] between Ads
Hubaddy = "hubaddy.no-ip.com" -- Duh?
HubOwner = "Your_Nick" -- Duh?
Prefix = "+" -- Set Command Prefix
AdComm = "ad" -- Command to send Ad immediately
PmComm = "adpm" -- Toggle ad, send to  main or PM
Ad2Pm = "no" -- send ad as pm? may be toggled
TZone = " -5 GMT [EST]" -- Time Zone hub resides in
HubMsg1 = "" -- Additional notices/info to be sent with ad
HubMsg2 = "" -- Additional notices/info to be sent with ad
HubMsg3 = "" -- Additional notices/info to be sent with ad
--End User Settings----------------------------------------------------------------------------------

frmHub:RegBot(bot)

function Main()
SetTimer(mins*60000)
StartTimer()
end

function DataArrival(user, data)
s,e,cmd = strfind(data, "%b<>%s+(%S+)(%S+)")
if (cmd==Prefix..AdComm) and user.bOperator then
OnTimer()
elseif (cmd==Prefix..PmComm) and user.bOperator then  
if Ad2Pm == "yes" then Ad2Pm = "no"
user:SendData("Hub advert will now be sent to the main chat")
elseif Ad2Pm == "no" then Ad2Pm = "yes"
user:SendData("Hub advert will now be sent as a private message")
end
return 1
end
end

function OnTimer()
local tmp
tmp = "\r\n\r\n\t---<>-------------------------------------------------------------------------------------<>---\r\n"  
tmp = tmp.."\t[ "..frmHub:GetHubName().." ]\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tHub Name: \t"..frmHub:GetHubName().."\r\n"
tmp = tmp.."\tHub Owner: \t"..HubOwner.."\r\n"
tmp = tmp.."\tHub Addy: \t"..Hubaddy.."\r\n"
tmp = tmp.."\tHub Time: \t( "..date("%B %d %Y %X ").." ) - "..TZone .."\r\n"
tmp = tmp.."\tHub Desc: \t"..frmHub:GetHubDescr().."\r\n"
tmp = tmp.."\tRedirect To: \t"..frmHub:GetRedirectAddress().."\r\n"
tmp = tmp.."\tReg Server: \t"..frmHub:GetRegServer().."\r\n"  
tmp = tmp.."\tRedirect All: \t"..RedirAll().."\r\n"
tmp = tmp.."\tRedirect Full: \t"..RedirFull().."\r\n"
tmp = tmp.."\tMax Users: \t"..frmHub:GetMaxUsers().."\r\n"
tmp = tmp.."\tMin Share: \t"..format("%.2f GigaBytes",frmHub:GetMinShare()/1024).."\r\n"
tmp = tmp.."\tHub Share: \t"..format("%.2f TeraBytes",frmHub:GetCurrentShareAmount()/(1024 * 1024 * 1024 * 1024)).."\r\n"
tmp = tmp.."\tMasters Online: \t"..cProfile("Master").."\r\n"
tmp = tmp.."\tOps Online: \t"..cProfile("Operator").."\r\n"
tmp = tmp.."\tVips Online: \t"..cProfile("VIP").."\r\n"
tmp = tmp.."\tRegs Online: \t"..cProfile("REG").."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tTotal Online:\t\t"..frmHub:GetUsersCount().."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
tmp = tmp.."\tNotice(s):\r\n"
tmp = tmp.."\t-- "..HubMsg1.."\r\n"
tmp = tmp.."\t-- "..HubMsg2.."\r\n"
tmp = tmp.."\t-- "..HubMsg3.."\r\n"
tmp = tmp.."\t---<>-------------------------------------------------------------------------------------<>---\r\n"
if Ad2Pm == "yes" then
SendPmToAll(bot,tmp)
else
SendToAll(bot,tmp)
end
end

function RedirAll()
local rdstatusall = frmHub:GetRedirectAll()
local rastatus = ""
if rdstatusall == 1 then
rastatus = "on"
else
rastatus = "off"
end
return rastatus
end

function RedirFull()
local rdstatusfull = frmHub:GetRedirectFull()
local rfstatus = 0
if rdstatusfull == 1 then
rfstatus = "on"
else
rfstatus = "off"
end
return rfstatus
end

--// Profile Counter
function cProfile(what)
local disp = ""
local table,online,offline = GetUsersByProfile(what),0,0
for i, User in table do
if GetItemByName(User) then
online = online + 1
else
offline = offline + 1
end
end
disp = disp.."Online: "..online.."\t\tOffline: "..offline
return disp
end
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline BottledHate

  • Triple Ace
  • **
  • Posts: 244
  • Karma: +2/-0
(No subject)
« Reply #9 on: 02 October, 2004, 05:42:53 »
no problem :)

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
(No subject)
« Reply #10 on: 02 October, 2004, 05:54:20 »
funny thing is it crashes the hub when i start it - but if i take it out of scripts when i start the hub and then put them back into script then restart thescripts it works fine.

same affect on TD 4/4.99 and on 0.330 builds 15.25 and 15.8

but like i say if i add it after the hub is running the script works fine
« Last Edit: 02 October, 2004, 05:54:43 by Psycho_Chihuahua »
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

PtokaX forum

(No subject)
« Reply #10 on: 02 October, 2004, 05:54:20 »