what is wrong with this script?????
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

what is wrong with this script?????

Started by [NL]trucker, 15 December, 2003, 23:56:29

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

[NL]trucker

i have a script what should fire upon logon in pm to user
but it doesnt what is wrong with it?
in scripteditor it gives me no errors so i,m a bit clueless here please help.
-- Globals --

HubAddress = "funnyhub.no-ip.info"
BotName = "Welcome"
SendPM ="1" -- or 1
-- remove above comment for PM

-- Events --

function NewUserConnected(user)
i,j,share = strfind(user.sMyInfoString, "$(%d+)%$")

if share==nil then
user:Disconnect()
else
usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))

local tmp
tmp = "Hello "..user.sName.." and welcome to "..frmHub:GetHubName().."\r\n\r\n"
tmp = tmp.."\tYour IP: "..user.sIP.."\r\n"
tmp = tmp.."\tYour Nick: "..user.sName.."\r\n"
tmp = tmp.."\tYour share: "..usershare.."\r\n\r\n"
tmp = tmp.."\tHub IP:"..HubAddress.."\r\n"
tmp = tmp.."\tHub Name: "..frmHub:GetHubName().."\r\n"
tmp = tmp.."\tHub Desc: "..frmHub:GetHubDescr().."\r\n\r\n"
tmp = tmp.."\tUsers Online: "..frmHub:GetUsersCount().."\r\n"
tmp = tmp.."\tOperators Online: "..CountOPs().."\r\n"
local hr, mn = GetUpTime()
tmp = tmp.."\tUptime: "..hr.." hours, "..mn.." minutes\r\n"


tmp = "If you need any help with dc go here and check it out http://wind.prohosting.com/svideos/extfaq/software.html#directconn"

tmp =" ---------------------------------------------------------------------------"
tmp =" .. . .. "
tmp =" .. )\ .. "
tmp =" . ( ) .. -- -- "
tmp =" : . _\/_ . : "
tmp =" `()()()` "
tmp =" ll'`'``l THE FUNNYHUB CREW "
tmp =" ll l "
tmp =" ll l :: HubOwner : [NL]trucker "
tmp =" ll l ::Hub Masters: TeQuilla-hollandse.ko "
tmp =" ll l `` ::Hub SuperOp: [INT]masterload "
tmp=" ll l :: ::Hub-OP,s [NL] janeb -[NL]Spikey-DoJiN"
tmp=" ... ll l :: "
tmp=" : ':::. ll l ....:: Wish You All A "
tmp= " ``:::::::::::::.`` "
tmp= " :::::::::::` "
tmp= " "
tmp= " MERRY CHRISTMAS "
tmp= " AND "
tmp= " A "
tmp= " HAPPY NEW YEAR "
tmp=" --------------------------------------------------------------------------- "

if(SendPM) then
user:SendPM(BotName,tmp)
else
SendToAll(BotName,tmp)
end
end
end

-- Functions --

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

-- Gets the hubs uptime
-- return: hrs, mns
-- Author: RabidWombat
function GetUpTime()
local hFile, sFinal = openfile("..\\error.log", "r"), nil

if (hFile) then
local line = read(hFile)
while line do
if(strsub(line, -15) == "Serving started") then
-- s, e, sFinal = strfind(line, "([^-]+).+")
sFinal = strsub(line, 1, strlen(line) - 17) -- changed this line because there are '-' in the time, duh
end
line = read(hFile)
end

closefile(hFile)

local StartTime = JulianDate(SplitTimeString(sFinal));
-- Changed here too to new format
local EndTime = JulianDate(SplitTimeString(date("%d-%m-%Y %H:%M:%S")));
local diff = EndTime - StartTime;
return floor(diff) * 24 + floor(frac(diff) * 24), floor(frac(frac(diff)*24)*60);
end

return 0,0 -- this should NEVER happen
end

-- Split a specific Time string into its components
-- New Format: D-M-Y HR:MN:SC" - 24hr time
-- return: D,M,Y,HR,MN,SC HR is in 24hr format
function SplitTimeString(TimeString) --
local s,e,D,M,Y,HR,MN,SC = strfind(TimeString, "([^-]+).([^-]+).(%S+)%s([^:]+).([^:]+).(%S+)");

D = tonumber(D)
M = tonumber(M)
Y = tonumber(Y)
HR = tonumber(HR)
MN = tonumber(MN)
SC = tonumber(SC)

assert(HR < 24);
assert(MN < 60);
assert(SC < 60);

return D,M,Y,HR,MN,SC
end

function JulianDate(DAY, MONTH, YEAR, HOUR, MINUTE, SECOND) -- HOUR is 24hr format
local jy, ja, jm;

assert(YEAR ~= 0);
assert(YEAR ~= 1582 or MONTH ~= 10 or DAY < 4 or DAY > 15);
--The dates 5 through 14 October, 1582, do not exist in the Gregorian system!");

if(YEAR < 0 ) then
YEAR = YEAR + 1;
end

if( MONTH > 2) then
jy = YEAR;
jm = MONTH + 1;
else
jy = YEAR - 1;
jm = MONTH + 13;
end

local intgr = floor( floor(365.25*jy) + floor(30.6001*jm) + DAY + 1720995 );

--check for switch to Gregorian calendar
local gregcal = 15 + 31*( 10 + 12*1582 );
if(DAY + 31*(MONTH + 12*YEAR) >= gregcal ) then
ja = floor(0.01*jy);
intgr = intgr + 2 - ja + floor(0.25*ja);
end

--correct for half-day offset

local dayfrac = HOUR / 24 - 0.5;
if( dayfrac < 0.0 ) then
dayfrac = dayfrac + 1.0;
intgr = intgr - 1;
end

--now set the fraction of a day
local frac = dayfrac + (MINUTE + SECOND/60.0)/60.0/24.0;

--round to nearest second
local jd0 = (intgr + frac)*100000;
local jd = floor(jd0);
if( jd0 - jd > 0.5 ) then jd = jd + 1 end
return jd/100000;

end

function frac(num)
return num - floor(num);
end
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


plop

tmp was wrong and SendPM.
-- Globals --

HubAddress = "funnyhub.no-ip.info"
BotName = "Welcome"
SendPM = 1 -- or 1
-- remove above comment for PM

-- Events --

function NewUserConnected(user)
   i,j,share = strfind(user.sMyInfoString, "$(%d+)%$")
   if share==nil then
      user:Disconnect()
   else
      usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))
      local tmp
      tmp = "Hello "..user.sName.." and welcome to "..frmHub:GetHubName().."\r\n\r\n"
      tmp = tmp.."\tYour IP: "..user.sIP.."\r\n"
      tmp = tmp.."\tYour Nick: "..user.sName.."\r\n"
      tmp = tmp.."\tYour share: "..usershare.."\r\n\r\n"
      tmp = tmp.."\tHub IP:"..HubAddress.."\r\n"
      tmp = tmp.."\tHub Name: "..frmHub:GetHubName().."\r\n"
      tmp = tmp.."\tHub Desc: "..frmHub:GetHubDescr().."\r\n\r\n"
      tmp = tmp.."\tUsers Online: "..frmHub:GetUsersCount().."\r\n"
      tmp = tmp.."\tOperators Online: "..CountOPs().."\r\n"
      local hr, mn = GetUpTime()
      tmp = tmp.."\tUptime: "..hr.." hours, "..mn.." minutes\r\n"
      tmp = tmp.."If you need any help with dc go here and check it out [URL]http://wind.prohosting.com/svideos/extfaq/software.html#directconn\r\n[/URL]"
      tmp = tmp.." ---------------------------------------------------------------------------\r\n"
      tmp = tmp.." .. . .. \r\n"
      tmp = tmp.." .. )\ .. \r\n"
      tmp = tmp.." . ( ) .. -- -- \r\n"
      tmp = tmp.." : . _\/_ . : \r\n"
      tmp = tmp.." `()()()` \r\n"
      tmp = tmp.." ll'`'``l THE FUNNYHUB CREW \r\n"
      tmp = tmp.." ll l \r\n"
      tmp = tmp.." ll l :: HubOwner : [NL]trucker \r\n"
      tmp = tmp.." ll l ::Hub Masters: TeQuilla-hollandse.ko \r\n"
      tmp = tmp.." ll l `` ::Hub SuperOp: [INT]masterload \r\n"
      tmp = tmp.." ll l :: ::Hub-OP,s [NL] janeb -[NL]Spikey-DoJiN\r\n"
      tmp = tmp.." ... ll l :: \r\n"
      tmp = tmp.." : ':::. ll l ....:: Wish You All A \r\n"
      tmp = tmp.." ``:::::::::::::.`` \r\n"
      tmp = tmp.." :::::::::::` \r\n"
      tmp = tmp.." \r\n"
      tmp = tmp.." MERRY CHRISTMAS \r\n"
      tmp = tmp.." AND \r\n"
      tmp = tmp.." A \r\n"
      tmp = tmp.." HAPPY NEW YEAR \r\n"
      tmp = tmp.." --------------------------------------------------------------------------- "
      if SendPM == 1 then
         user:SendPM(BotName,tmp)
      else
         SendToAll(BotName,tmp)
      end
   end
end

-- Functions --

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

-- Gets the hubs uptime
-- return: hrs, mns
-- Author: RabidWombat
function GetUpTime()
   local hFile, sFinal = openfile("..\\error.log", "r"), nil
   if (hFile) then
      local line = read(hFile)
      while line do
         if(strsub(line, -15) == "Serving started") then
            -- s, e, sFinal = strfind(line, "([^-]+).+")
            sFinal = strsub(line, 1, strlen(line) - 17) -- changed this line because there are '-' in the time, duh
         end
         line = read(hFile)
      end
      closefile(hFile)
      local StartTime = JulianDate(SplitTimeString(sFinal));
      -- Changed here too to new format
      local EndTime = JulianDate(SplitTimeString(date("%d-%m-%Y %H:%M:%S")));
      local diff = EndTime - StartTime;
      return floor(diff) * 24 + floor(frac(diff) * 24), floor(frac(frac(diff)*24)*60);
   end
   return 0,0 -- this should NEVER happen
end

-- Split a specific Time string into its components
-- New Format: D-M-Y HR:MN:SC" - 24hr time
-- return: D,M,Y,HR,MN,SC HR is in 24hr format
function SplitTimeString(TimeString) --
   local s,e,D,M,Y,HR,MN,SC = strfind(TimeString, "([^-]+).([^-]+).(%S+)%s([^:]+).([^:]+).(%S+)");
   D = tonumber(D)
   M = tonumber(M)
   Y = tonumber(Y)
   HR = tonumber(HR)
   MN = tonumber(MN)
   SC = tonumber(SC)
   assert(HR < 24);
   assert(MN < 60);
   assert(SC < 60);
   return D,M,Y,HR,MN,SC
end

function JulianDate(DAY, MONTH, YEAR, HOUR, MINUTE, SECOND) -- HOUR is 24hr format
   local jy, ja, jm;
   assert(YEAR ~= 0);
   assert(YEAR ~= 1582 or MONTH ~= 10 or DAY < 4 or DAY > 15);
   --The dates 5 through 14 October, 1582, do not exist in the Gregorian system!");
   if(YEAR < 0 ) then
      YEAR = YEAR + 1;
   end
   if( MONTH > 2) then
      jy = YEAR;
      jm = MONTH + 1;
   else
      jy = YEAR - 1;
      jm = MONTH + 13;
   end
   local intgr = floor( floor(365.25*jy) + floor(30.6001*jm) + DAY + 1720995 );
   --check for switch to Gregorian calendar
   local gregcal = 15 + 31*( 10 + 12*1582 );
   if(DAY + 31*(MONTH + 12*YEAR) >= gregcal ) then
      ja = floor(0.01*jy);
      intgr = intgr + 2 - ja + floor(0.25*ja);
   end
   --correct for half-day offset
   local dayfrac = HOUR / 24 - 0.5;
   if( dayfrac < 0.0 ) then
      dayfrac = dayfrac + 1.0;
      intgr = intgr - 1;
   end
   --now set the fraction of a day
   local frac = dayfrac + (MINUTE + SECOND/60.0)/60.0/24.0;
   --round to nearest second
   local jd0 = (intgr + frac)*100000;
   local jd = floor(jd0);
   if( jd0 - jd > 0.5 ) then jd = jd + 1 end
   return jd/100000;
end

function frac(num)
   return num - floor(num);
end
plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

[NL]trucker

plop

thanks alot m8 but i get a few errors allready

Syntax error: function arguments expected;
  last token read: `=' at line 4 in file `E:\==DC==\ptotaxbuild15.16\scripts\welcome_info.lua'

the same in line 5 and 6
and in line 11 there is something wrong also.


Syntax error: expected;
  last token read: `function' at line 11 in file `E:\==DC==\ptotaxbuild15.16\scripts\welcome_info.lua'

i get this errors when i try to start the script in ptotax.

i,m using ptotax 0.330 15.16 and pzozzybot 3.7
is it because of ptotax or just something wrong with script?
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


plop

no error here on 15.16 or 15.18, i'll check later in combination with pzozy.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

[NL]trucker

#4
thnx plop but dont know what happened i copied the script you posted again and it worked so i gues the littlle xmas devil has plaid a joke on me .

anyway thnx m8

(:-

still doesnt work
if a new user connects he doesnt get to see the message.neither in main or in pm furthermore i get this message now when i try to start the script

Syntax error: `(' expected;
  last token read: `NewUserConnected' at line 10 in file `E:\==DC==\ptotaxbuild15.16\scripts\welcome_info.lua'

dont get it the ( is there so i dont understand why the editor doesnt see it even after i removed it and placed it again.


Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


[NL]trucker

hopefully we can solve the problem with this script.
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


[NL]trucker

plop

are ya still looking into this?


or someone else please

i really really want this script to work .
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


plop

QuoteOriginally posted by [NL]trucker
plop

are ya still looking into this?


or someone else please

i really really want this script to work .
yep, i'll visit your hub again l8er 2day so you can grab the script from my share.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

[NL]trucker

thnx plop


i will be away from comp till around 22.00 hours so hope to see ya then.
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


turkiye

QuoteOriginally posted by [NL]trucker
thnx plop


i will be away from comp till around 22.00 hours so hope to see ya then.

Yeah he haves this
At his info
Posts: 356
 8o

plop

just 2 inform every1.
it worked when he grabed this script from my share.
-- Globals --

HubAddress = "funnyhub.no-ip.info"
BotName = "Welcome"
SendPM = 1 -- or 1
NewYear = 0 -- send new year wish yes=1, no=0
-- remove above comment for PM

-- Events --

function NewUserConnected(user)
   i,j,share = strfind(user.sMyInfoString, "$(%d+)%$")
   if share==nil then
      user:Disconnect()
   else
      usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))
      local tmp
      tmp = "Hello "..user.sName.." and welcome to "..frmHub:GetHubName().."\r\n\r\n"
      tmp = tmp.."\tYour IP: "..user.sIP.."\r\n"
      tmp = tmp.."\tYour Nick: "..user.sName.."\r\n"
      tmp = tmp.."\tYour share: "..usershare.."\r\n\r\n"
      tmp = tmp.."\tHub IP:"..HubAddress.."\r\n"
      tmp = tmp.."\tHub Name: "..frmHub:GetHubName().."\r\n"
      tmp = tmp.."\tHub Desc: "..frmHub:GetHubDescr().."\r\n\r\n"
      tmp = tmp.."\tUsers Online: "..frmHub:GetUsersCount().."\r\n"
      tmp = tmp.."\tOperators Online: "..CountOPs().."\r\n"
      local hr, mn = GetUpTime()
      tmp = tmp.."\tUptime: "..hr.." hours, "..mn.." minutes\r\n"
      tmp = tmp.."If you need any help with dc go here and check it out [URL]http://wind.prohosting.com/svideos/extfaq/software.html#directconn\r\n[/URL]"
      if NewYear == 1 then
         tmp = tmp.." ---------------------------------------------------------------------------\r\n"
         tmp = tmp.." .. . .. \r\n"
         tmp = tmp.." .. )\ .. \r\n"
         tmp = tmp.." . ( ) .. -- -- \r\n"
         tmp = tmp.." : . _\/_ . : \r\n"
         tmp = tmp.." `()()()` \r\n"
         tmp = tmp.." ll'`'``l THE FUNNYHUB CREW \r\n"
         tmp = tmp.." ll l \r\n"
         tmp = tmp.." ll l :: HubOwner : [NL]trucker \r\n"
         tmp = tmp.." ll l ::Hub Masters: TeQuilla-hollandse.ko \r\n"
         tmp = tmp.." ll l `` ::Hub SuperOp: [INT]masterload \r\n"
         tmp = tmp.." ll l :: ::Hub-OP,s [NL] janeb -[NL]Spikey-DoJiN\r\n"
         tmp = tmp.." ... ll l :: \r\n"
         tmp = tmp.." : ':::. ll l ....:: Wish You All A \r\n"
         tmp = tmp.." ``:::::::::::::.`` \r\n"
         tmp = tmp.." :::::::::::` \r\n"
         tmp = tmp.." \r\n"
         tmp = tmp.." MERRY CHRISTMAS \r\n"
         tmp = tmp.." AND \r\n"
         tmp = tmp.." A \r\n"
         tmp = tmp.." HAPPY NEW YEAR \r\n"
         tmp = tmp.." --------------------------------------------------------------------------- "
      end
      if SendPM == 1 then
         user:SendPM(BotName,tmp.."|")
      else
         SendToAll(BotName,tmp.."|")
      end
   end
end

-- Functions --

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

-- Gets the hubs uptime
-- return: hrs, mns
-- Author: RabidWombat
function GetUpTime()
   local hFile, sFinal = openfile("..\\error.log", "r"), nil
   if (hFile) then
      local line = read(hFile)
      while line do
         if(strsub(line, -15) == "Serving started") then
            -- s, e, sFinal = strfind(line, "([^-]+).+")
            sFinal = strsub(line, 1, strlen(line) - 17) -- changed this line because there are '-' in the time, duh
         end
         line = read(hFile)
      end
      closefile(hFile)
      local StartTime = JulianDate(SplitTimeString(sFinal));
      -- Changed here too to new format
      local EndTime = JulianDate(SplitTimeString(date("%d-%m-%Y %H:%M:%S")));
      local diff = EndTime - StartTime;
      return floor(diff) * 24 + floor(frac(diff) * 24), floor(frac(frac(diff)*24)*60);
   end
   return 0,0 -- this should NEVER happen
end

-- Split a specific Time string into its components
-- New Format: D-M-Y HR:MN:SC" - 24hr time
-- return: D,M,Y,HR,MN,SC HR is in 24hr format
function SplitTimeString(TimeString) --
   local s,e,D,M,Y,HR,MN,SC = strfind(TimeString, "([^-]+).([^-]+).(%S+)%s([^:]+).([^:]+).(%S+)");
   D = tonumber(D)
   M = tonumber(M)
   Y = tonumber(Y)
   HR = tonumber(HR)
   MN = tonumber(MN)
   SC = tonumber(SC)
   assert(HR < 24);
   assert(MN < 60);
   assert(SC < 60);
   return D,M,Y,HR,MN,SC
end

function JulianDate(DAY, MONTH, YEAR, HOUR, MINUTE, SECOND) -- HOUR is 24hr format
   local jy, ja, jm;
   assert(YEAR ~= 0);
   assert(YEAR ~= 1582 or MONTH ~= 10 or DAY < 4 or DAY > 15);
   --The dates 5 through 14 October, 1582, do not exist in the Gregorian system!");
   if(YEAR < 0 ) then
      YEAR = YEAR + 1;
   end
   if( MONTH > 2) then
      jy = YEAR;
      jm = MONTH + 1;
   else
      jy = YEAR - 1;
      jm = MONTH + 13;
   end
   local intgr = floor( floor(365.25*jy) + floor(30.6001*jm) + DAY + 1720995 );
   --check for switch to Gregorian calendar
   local gregcal = 15 + 31*( 10 + 12*1582 );
   if(DAY + 31*(MONTH + 12*YEAR) >= gregcal ) then
      ja = floor(0.01*jy);
      intgr = intgr + 2 - ja + floor(0.25*ja);
   end
   --correct for half-day offset
   local dayfrac = HOUR / 24 - 0.5;
   if( dayfrac < 0.0 ) then
      dayfrac = dayfrac + 1.0;
      intgr = intgr - 1;
   end
   --now set the fraction of a day
   local frac = dayfrac + (MINUTE + SECOND/60.0)/60.0/24.0;
   --round to nearest second
   local jd0 = (intgr + frac)*100000;
   local jd = floor(jd0);
   if( jd0 - jd > 0.5 ) then jd = jd + 1 end
   return jd/100000;
end

function frac(num)
   return num - floor(num);
end
plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk