Scripts To Be Converted
 

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

Scripts To Be Converted

Started by Requiem, 09 March, 2005, 11:47:35

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Requiem

Please help me. Thanks a lot from now.

EDIT: Removed stupid joke.

A Script to PM unregged users.
-- Made by Optimus
-- 08/12/03

sBot = "BotName"

unRegUsers = {}
unRegUserFile = "unRegUsers.txt"

function Main()
	frmHub:RegBot(sBot)
	doloadTable(unRegUserFile)
	if frmHub:GetUsersCount() == 0 then unRegUsers = {}
		dosaveTable(user,data)
	end
end

function NewUserConnected(user)
	if user.iProfile == -1 then
		doLog_unRegUsers(user, data)
	end
end
function UserDisconnected(user)
	if unRegUsers[user.sName] then
		unRegUsers[user.sName] = nil
		dosaveTable(user,data)
	end
end

function DataArrival(user, data)
	if (strsub(data, 1, 1) == "<" ) then
		data=strsub(data,1,strlen(data)-1)
		_,_,cmd=strfind(data, "%b<>%s+(%S+)")

		if user.bOperator then
			if (cmd == "!unregpm") then				
				s,e,cmd,message = strfind(data,"%b<>%s+(%S+)%s+(.+)")

				if message then
					tosend = ""
					if (strlen ( message)*2/3+2) < 76 then
					border = strrep ("-", strlen (message)*2/3+2)
					else
					border = strrep ("-", 75)
					end
					tosend = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"

					if unRegUsers then
						for name,_ in unRegUsers do
							SendPmToNick(name,sBot, tosend)
						end
					end
				else
					user:SendData(sBot, "*** Please Enter a Message!")
				end
			end
		end
	end
end

function doLog_unRegUsers(user, data)
	if unRegUsers[user.sName] == nil then
		unRegUsers[user.sName] = 1
		dosaveTable(user,data)
	end
end

function doloadTable(unRegUserFile)
	assert(readfrom(unRegUserFile))
	dostring(read("*all"))
	readfrom()
end

function dosaveTable(user,data) 
	writeto(unRegUserFile)
	write("unRegUsers = {")
	for a,b in unRegUsers do 
	if b then 
	write(format("[%q]=",a)..b..",")
	end 
	end 
	write("}" )
	writeto()
end


--RegHound 1.0
--Requested by Sin
--Script by Mutor The Ugly 7/10/14
--
--Prompts unregistered users to register on repaeating interval
--Hounds in Main Chat, as well as PM
--
--

--User Settings-------------------------------------------------------------------------------------
--
--Name for bot[You can use your main bot, if so no need to register this bot. See 'function main'.
sBot = "BotName
--Interval [in minutes] to PM unregistered users
Mins =  "60"
--Message to send to unregistered Users
UnRegMsg = "message goes here
--
--End User Settings----------------------------------------------------------------------------------


UnRegTab = {}
UnReg = "UnReg.dat"


function Main() 
	SetTimer(Mins*60000) 
	StartTimer()
	--frmHub:RegBot(sBot)	--If using main bot, remark this line, add -- ie.. --frmHub:RegBot(sBot)
	LoadFromFile(UnReg)
end

function OnExit()
	SaveToFile(UnReg , UnRegTab , "UnRegTab")
end

function NewUserConnected(user, data)
	if (user.iProfile == -1 and UnRegTab[user.sName] == nil) then
		UnRegTab[user.sName] = 1
	end
end

function UserDisconnected(user, data)
	if (user.iProfile == -1 and UnRegTab[user.sName] ~= nil) then
		UnRegTab[user.sName] = nil
	end
end

function OnTimer()
	local usr,aux
		for usr, aux in UnRegTab do
			if (GetItemByName(usr) ~= nil) then
				sNick = GetItemByName(usr)
				sNick:SendPM(sBot, UnRegMsg)
				sNick:SendData(sBot, UnRegMsg)
			end
		end
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end


-- Spam King (spam blocker) (for PtokaX 0.3.2.6TD3) 
-- by: gg3k 
-- file: SpamKing.lua 
-- This script stops spammers using automessaging software. 
-- It blocks all traffic that is passed through DataArrival until the user has sent the validation code. 
-- This effectively prevents searchbots from getting any results from the hub too. 

BotName = "BotName" -- Name of the bot. 

TestReggedUsers = 1 -- Set to 1 if you want to require validation from registered users. 

TestOperators = 0 -- Set to 1 if you want to require validation from operators. 

NoChatUsers = { } 

--// This function is fired at the serving start 

function Main() 

end 

--// This function is fired when a new data arrives 

function DataArrival(curUser, sData) 

sData = strsub(sData, 1, strlen(sData)-1) 

if curUser.iProfile == -1 or TestReggedUsers == 1 then 

if NoChatUsers[curUser.sName] ~= nil then 

if NoChatUsers[curUser.sName] == 1 then 

NoChatUsers[curUser.sName] = random(1000, 9999) 

SendToNick(curUser.sName, "<"..BotName.."> To open mainchat please enter numbers here:"..NoChatUsers[curUser.sName] ) 

return 1 

else 

_,_,keystring = strfind(sData, "%b<>%s+(%S+)") 

if tostring(keystring) == tostring(NoChatUsers[curUser.sName]) then 

NoChatUsers[curUser.sName] = nil 

SendToNick(curUser.sName, "<"..BotName.."> Main Chat opened.") 

else 

SendToNick(curUser.sName, "<"..BotName.."> To open mainchat please enter numbers here: "..NoChatUsers[curUser.sName] ) 

end 

return 1 

end 

end 

end 

end 

--// This function is fired when a new user finishes the login 

function NewUserConnected(curUser) 

NoChatUsers[curUser.sName] = 1 

end 

--// This function is fired when an operator enters the hub 

function OpConnected(curUser) 

if TestOperators == 1 then 

NoChatUsers[curUser.sName] = 1 

end 

end 

--// This function is fired when an user disconnects 

function UserDisconnected(curUser) 

NoChatUsers[curUser.sName] = nil 

end 

--// This function is fired when an operator disconnects 

function OpDisconnected(curUser) 

NoChatUsers[curUser.sName] = nil 

end


Requiem

Continuing:

-- UserWelcome by RabidWombat
-- Rewritten for "YYYY. MM. DD. HH:MM:SS" time format in log by bastya_elvtars
-- added option if you use AshCan or higher by bastya_elvtars, this is for profiles, otherwise it lists ops only, and masters never.
-- added support for ptokax 0.330 (error.log is in the ptokax/logs directory @ 0.330) by bastya_elvtars 
-- Tested with AshCan, 15.18 & 15.25

-- Globals --

AshCanPlus=1 -- for ptokax under 0.325 AshCan, set to 0.
HubAddress = "trucker1.dyndns.org"
BotName = "(@)Truckers Garage(@)" -- use a bot thats in the userlist
SendPM = 1
--SendPM = nil -- uncomment this and comment the above for mainchat welcome. 
			    -- Note that if you don't specify a bot that is in ur userlist, (aka registered)
			    -- the connecting users will get the text in main as well.


-- 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 _, day, hr, mn = GetUpTime()
		tmp = tmp.."\tUptime: "..day.." days, "..hr.." hours, "..mn.." minutes.\r\n"
		
		if(SendPM) then
			user:SendPM(BotName,tmp)
		else
			user:SendData(BotName,tmp)
		end
	end
end 

-- Functions --

function CountOPs() 
	local tmp,count=opscount(),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 opscount()
	if AshCanPlus~=1 then
		local tmp = GetUsersByProfile(GetProfileName(1))
		return tmp
	else
		local tmp, tmp2 = GetUsersByProfile(GetProfileName(1)),GetUsersByProfile(GetProfileName(0))
		for m=1,getn(tmp2) do
			tinsert(tmp,tmp2[m])
		end return tmp
	end
	collectgarbage(); flush()
end

-- Gets the hubs uptime
-- return: hrs, mns
-- Author: RabidWombat
-- Updater: bastya_elvtars
function GetUpTime()
	local loggrabbing=function()
						if readfrom("../logs/error.log") then
							readfrom()
							return openfile("../logs/error.log", "r"), nil
						elseif readfrom ("../error.log") then
							readfrom()
							return openfile("../error.log", "r"), nil
						end -- compatibility with all ptokax
					end
	local fileparse=function()
					local hFile,sFinal=%loggrabbing()
					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)
						return sFinal
					else
						return date("%Y. %m. %d. %X")
					end
				end
	
		local StartTime = JulianDate(SplitTimeString(fileparse()));
		-- Changed here too to new format
		local EndTime = JulianDate(SplitTimeString(date("%Y. %m. %d. %X")));
		local diff =  EndTime - StartTime;
		local hours, mins= floor(diff) * 24 + floor(frac(diff) * 24), floor(frac(frac(diff)*24)*60)
		local hubuptime=hours*60+mins -- converting to minutes, that's to make days too
-- now parsing the minute data
		local days = floor(hubuptime/1440)
		local hrs = floor((hubuptime-(days*1440))/60)
		local min = floor((hubuptime-(days*1440)-(hrs*60)))
		return hubuptime, days, hrs, mins
--	return 0,0,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: Y,M,D,HR,MN,SC  HR is in 24hr format
function SplitTimeString(TimeString) -- 
	--local s,e,Y,M,D,HR,MN,SC = strfind(TimeString, "([^.]+). ([^.]+). ([^.]+). ([^:]*):([^:]*):(%S*)");
	-- 14/09/2004 16.23.25
	local grab=function(TimeString)
					if strfind(TimeString,"/")then
						local _,_,D,M,Y,HR,MN,SC=strfind(TimeString,"([^/]+).([^/]+).(%S+) ([^:]+).([^:]+).([^:]+)")
						return D,M,Y,HR,MN,SC
					elseif strfind (TimeString,"%d%-%d") then
						local _,_,D,M,Y,HR,MN,SC = strfind(TimeString, "([^-]+).([^-]+).(%S+) ([^:]+).([^:]+).(%S+)")
						return D,M,Y,HR,MN,SC
					elseif strfind (TimeString,"%d%d.%d%d.%d%d%d%d%s+") then
						local _,_,Y,M,D,HR,MN,SC = strfind(TimeString, "([^.]+).([^.]+).(%S+). ([^:]+).([^:]+).(%S+)")
						return D,M,Y,HR,MN,SC
					else
						local _,_,Y,M,D,HR,MN,SC = strfind(TimeString, "([^.]+). ([^.]+). ([^.]+). ([^:]+).([^:]+).(%S+)")
						return D,M,Y,HR,MN,SC
					end
				end

	local D,M,Y,HR,MN,SC=grab(TimeString)
	D = tonumber(D)
	M = tonumber(M)
	Y = tonumber(Y)
	HR = tonumber(HR)
	--assert(HR < 24)
	MN = tonumber(MN)
	--assert(MN < 60)
	SC = tonumber(SC)
	--assert(SC < 60)

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


Please dont tell me to use RoboCop's user welcome for the last script. I am using this script edited but when I tried to edit RC's it didn't work.

--Whisper 1.01
--by Mutor
--Request by Snoris
--
--Sends a "For your eyes only message" to another user in main.
--Added option for right click command
--
--User Settings-------------------------------------------------------------------------------------
Comm = "!fisilda"	-- Script Command
Bot = "bot"	-- Rename to your main Px bot
Confirmation = "1"	-- Show whisper confirmation [show to sender only] "1"=yes "0"=no
SendComm = "0"		-- Send user command [right click] "1"=yes "0"=no
--End User Settings----------------------------------------------------------------------------------
--
--$UserCommand 1 X  Where -> 1=Hub Menu 2=User Menu 3=Hub/User Menu 
--

function NewUserConnected(user)
	if SendComm == "1" then
		user:SendData("$UserCommand 1 2 Whisper To User $<%[mynick]> "..Comm.." %[nick] %[line:Whisper-Message]||")
		user:SendData(" *** Notice :: Right click 'Whisper' command enabled ***")
	end
end

OpConnected = NewUserConnected

function DataArrival(user, data)
	s,e,cmd,who,msg = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)")
	if (cmd == Comm) and user.bOperator then -- Use this for Ops use only
	local nick = GetItemByName(who)
		if not nick then
			SendToNick(user.sName," "..who.." is not online...") 
			return 1 
		end
			nick:SendData(Bot,""..user.sName.." whispers to you : " ..msg)
				if Confirmation == "1" then
					SendToNick(user.sName," msg whispered")
				end
	return 1
	end
	
end

Requiem

So anybody wont help me hah ?

jiten

Try this:

-- Made by Optimus
-- 08/12/03
-- converted to LUA 5 by jiten

sBot = "BotName"

unRegUsers = {}
unRegUserFile = "unRegUsers.txt"

function Main()
	frmHub:RegBot(sBot)
	doloadTable(unRegUserFile)
	if frmHub:GetUsersCount() == 0 then unRegUsers = {}
		dosaveTable(user,data)
	end
end

function NewUserConnected(user)
	if user.iProfile == -1 then
		doLog_unRegUsers(user, data)
	end
end
function UserDisconnected(user)
	if unRegUsers[user.sName] then
		unRegUsers[user.sName] = nil
		dosaveTable(user,data)
	end
end

function ChatArrival(user, data)
	if (string.sub(data, 1, 1) == "<" ) then
		data=string.sub(data,1,string.len(data)-1)
		_,_,cmd=string.find(data, "%b<>%s+(%S+)")

		if user.bOperator then
			if (cmd == "!unregpm") then				
				s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.+)")

				if message then
					tosend = ""
					if (string.len ( message)*2/3+2) < 76 then
					border = string.rep ("-", string.len (message)*2/3+2)
					else
					border = string.rep ("-", 75)
					end
					tosend = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"

					if unRegUsers then
						for name,_ in unRegUsers do
							SendPmToNick(name,sBot, tosend)
						end
					end
				else
					user:SendData(sBot, "*** Please Enter a Message!")
				end
			end
		end
	end
end

function doLog_unRegUsers(user, data)
	if unRegUsers[user.sName] == nil then
		unRegUsers[user.sName] = 1
		dosaveTable(user,data)
	end
end


function doloadTable(unRegUserFile)
	local handle = io.open(unRegUserFile,"r")
	if (handle ~= nil) then
                dofile(unRegUserFile)
		handle:flush()
		handle:close()
        end
end

function dosaveTable(user,data)
	local f = io.open(unRegUserFile, "w+")
	assert(unRegUserFile)
	f:write("unRegUsers = {")
	          for a,b in unRegUsers do
                  if b == 1 then
	          f:write(string.format("[%q]=",a)..b..",")
	          end 
        end 
        f:write("}") 
        f:flush()
        f:close()
end

jiten

#4
-- Optimized Lua 5 version by jiten
-- RegHound 1.0 by Mutor The Ugly 7/10/14
--
-- Prompts unregistered users to register on repaeating interval; Hounds in Main Chat, as well as PM
-- User Settings -------------------------------------------------------------------------------------
sBot = frmHub:GetHubBotName()	-- Name for bot[You can use your main bot, if so no need to register this bot. See 'function main'.
Mins =  "1"			-- Interval [in minutes] to PM unregistered users
UnRegMsg = "message goes here"	-- Message to send to unregistered Users
-- End User Settings ---------------------------------------------------------------------------------

Main = function() 
	SetTimer(Mins*60000) StartTimer()
-- 	frmHub:RegBot(sBot) -- If using main bot, remark this line, add -- ie.. --frmHub:RegBot(sBot)
end

OnTimer = function()
	local i,v
	for i,v in frmHub:GetOnlineNonOperators() do
		if v.iProfile == -1 then
			v:SendPM(sBot, UnRegMsg)
			v:SendData(sBot, UnRegMsg)
		end
	end
end

jiten

-- Spam King (spam blocker) (for PtokaX 0.3.2.6TD3) 
-- by: gg3k 
-- converted to LUA 5 by jiten
-- file: SpamKing.lua 
-- This script stops spammers using automessaging software. 
-- It blocks all traffic that is passed through DataArrival until the user has sent the validation code. 
-- This effectively prevents searchbots from getting any results from the hub too. 

BotName = "BotName" -- Name of the bot. 

TestReggedUsers = 1 -- Set to 1 if you want to require validation from registered users. 

TestOperators = 0 -- Set to 1 if you want to require validation from operators. 

NoChatUsers = { } 

--// This function is fired at the serving start 

function Main() 

end 

--// This function is fired when a new data arrives 

function ChatArrival(curUser, sData) 

sData = string.sub(sData, 1, string.len(sData)-1) 

if curUser.iProfile == -1 or TestReggedUsers == 1 then 

if NoChatUsers[curUser.sName] ~= nil then 

if NoChatUsers[curUser.sName] == 1 then 

NoChatUsers[curUser.sName] = math.random(1000, 9999) 

SendToNick(curUser.sName, "<"..BotName.."> To open mainchat please enter numbers here:"..NoChatUsers[curUser.sName] ) 

return 1 

else 

_,_,keystring = string.find(sData, "%b<>%s+(%S+)") 

if tostring(keystring) == tostring(NoChatUsers[curUser.sName]) then 

NoChatUsers[curUser.sName] = nil 

SendToNick(curUser.sName, "<"..BotName.."> Main Chat opened.") 

else 

SendToNick(curUser.sName, "<"..BotName.."> To open mainchat please enter numbers here: "..NoChatUsers[curUser.sName] ) 

end 

return 1 

end 

end 

end 

end 

--// This function is fired when a new user finishes the login 

function NewUserConnected(curUser) 

NoChatUsers[curUser.sName] = 1 

end 

--// This function is fired when an operator enters the hub 

function OpConnected(curUser) 

if TestOperators == 1 then 

NoChatUsers[curUser.sName] = 1 

end 

end 

--// This function is fired when an user disconnects 

function UserDisconnected(curUser) 

NoChatUsers[curUser.sName] = nil 

end 

--// This function is fired when an operator disconnects 

function OpDisconnected(curUser) 

NoChatUsers[curUser.sName] = nil 

end

jiten

--Whisper 1.01
--by Mutor
--Request by Snoris
--converted to LUA 5 by jiten
--
--Sends a "For your eyes only message" to another user in main.
--Added option for right click command
--
--User Settings-------------------------------------------------------------------------------------
Comm = "!fisilda"	-- Script Command
Bot = "bot"	-- Rename to your main Px bot
Confirmation = "1"	-- Show whisper confirmation [show to sender only] "1"=yes "0"=no
SendComm = "0"		-- Send user command [right click] "1"=yes "0"=no
--End User Settings----------------------------------------------------------------------------------
--
--$UserCommand 1 X  Where -> 1=Hub Menu 2=User Menu 3=Hub/User Menu 
--

function NewUserConnected(user)
	if SendComm == "1" then
		user:SendData("$UserCommand 1 2 Whisper To User $<%[mynick]> "..Comm.." %[nick] %[line:Whisper-Message]||")
		user:SendData(" *** Notice :: Right click 'Whisper' command enabled ***")
	end
end

OpConnected = NewUserConnected

function ChatArrival(user, data)
	s,e,cmd,who,msg = string.find(data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)")
	if (cmd == Comm) and user.bOperator then -- Use this for Ops use only
	local nick = GetItemByName(who)
		if not nick then
			SendToNick(user.sName," "..who.." is not online...") 
			return 1 
		end
			nick:SendData(Bot,""..user.sName.." whispers to you : " ..msg)
				if Confirmation == "1" then
					SendToNick(user.sName," msg whispered")
				end
	return 1
	end
	
end

Requiem

thanks jiten, and sorry for late response, all your effort is really great but command and message is seen on mainchat ( like " [00:23:32] <[?Gece???Bekcisi?]> !unregpm trying this... " ) when using this scirpt... can smo help?
-- Made by Optimus
-- 08/12/03
-- converted to LUA 5 by jiten

sBot = "BotName"

unRegUsers = {}
unRegUserFile = "unRegUsers.txt"

function Main()
	frmHub:RegBot(sBot)
	doloadTable(unRegUserFile)
	if frmHub:GetUsersCount() == 0 then unRegUsers = {}
		dosaveTable(user,data)
	end
end

function NewUserConnected(user)
	if user.iProfile == -1 then
		doLog_unRegUsers(user, data)
	end
end
function UserDisconnected(user)
	if unRegUsers[user.sName] then
		unRegUsers[user.sName] = nil
		dosaveTable(user,data)
	end
end

function ChatArrival(user, data)
	if (string.sub(data, 1, 1) == "<" ) then
		data=string.sub(data,1,string.len(data)-1)
		_,_,cmd=string.find(data, "%b<>%s+(%S+)")

		if user.bOperator then
			if (cmd == "!unregpm") then				
				s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.+)")

				if message then
					tosend = ""
					if (string.len ( message)*2/3+2) < 76 then
					border = string.rep ("-", string.len (message)*2/3+2)
					else
					border = string.rep ("-", 75)
					end
					tosend = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"

					if unRegUsers then
						for name,_ in unRegUsers do
							SendPmToNick(name,sBot, tosend)
						end
					end
				else
					user:SendData(sBot, "*** Please Enter a Message!")
				end
			end
		end
	end
end

function doLog_unRegUsers(user, data)
	if unRegUsers[user.sName] == nil then
		unRegUsers[user.sName] = 1
		dosaveTable(user,data)
	end
end


function doloadTable(unRegUserFile)
	local handle = io.open(unRegUserFile,"r")
	if (handle ~= nil) then
                dofile(unRegUserFile)
		handle:flush()
		handle:close()
        end
end

function dosaveTable(user,data)
	local f = io.open(unRegUserFile, "w+")
	assert(unRegUserFile)
	f:write("unRegUsers = {")
	          for a,b in unRegUsers do
                  if b == 1 then
	          f:write(string.format("[%q]=",a)..b..",")
	          end 
        end 
        f:write("}") 
        f:flush()
        f:close()
end

jiten

Try this one:

-- Made by Optimus
-- 08/12/03
-- converted to LUA 5 by jiten

sBot = "BotName"

unRegUsers = {}
unRegUserFile = "unRegUsers.txt"

function Main()
	frmHub:RegBot(sBot)
	doloadTable(unRegUserFile)
	if frmHub:GetUsersCount() == 0 then unRegUsers = {}
		dosaveTable(user,data)
	end
end

function NewUserConnected(user)
	if user.iProfile == -1 then
		doLog_unRegUsers(user, data)
	end
end
function UserDisconnected(user)
	if unRegUsers[user.sName] then
		unRegUsers[user.sName] = nil
		dosaveTable(user,data)
	end
end

function ChatArrival(user, data)
	data=string.sub(data,1,string.len(data)-1)
	_,_,cmd=string.find(data, "%b<>%s+(%S+)")
	if user.bOperator then
		if (cmd == "!unregpm") then				
			s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.+)")
			if message then
				tosend = ""
				if (string.len ( message)*2/3+2) < 76 then
					border = string.rep ("-", string.len (message)*2/3+2)
				else
					border = string.rep ("-", 75)
				end
				tosend = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
				if unRegUsers then
					for name,_ in unRegUsers do
						SendPmToNick(name,sBot, tosend)
					end
				end
			else
				user:SendData(sBot, "*** Please Enter a Message!")
			end
		return 1
		end
	end
end

function doLog_unRegUsers(user, data)
	if unRegUsers[user.sName] == nil then
		unRegUsers[user.sName] = 1
		dosaveTable(user,data)
	end
end


function doloadTable(unRegUserFile)
	local handle = io.open(unRegUserFile,"r")
	if (handle ~= nil) then
                dofile(unRegUserFile)
		handle:flush()
		handle:close()
        end
end

function dosaveTable(user,data)
	local f = io.open(unRegUserFile, "w+")
	assert(unRegUserFile)
	f:write("unRegUsers = {")
	          for a,b in unRegUsers do
                  if b == 1 then
	          f:write(string.format("[%q]=",a)..b..",")
	          end 
        end 
        f:write("}") 
        f:flush()
        f:close()
end


Best regards,

jiten

Requiem

Thank you very much.. Everything works perfect now..

(NL)waarom

-send unreg pm on timer
--Script by Optimus
--lua5
--massage on time in Main Chat, as well as PM
--
--

--User Settings-------------------------------------------------------------------------------------
--
--Name for bot[You can use your main bot, if so no need to register this bot. See 'function main'.
sBot = "?Unreg?"
--Interval [in minutes] to PM unregistered users
sec=1000
min=60*sec
hour=60*min
--Message to send to unregistered Users
UnRegMsg = "You can't download if your not Registered type !regme ..... on the dots your password(make up your own password) (then close the hub and logon again )  or else you keep getting this annoying message till you registered!"
--
--End User Settings----------------------------------------------------------------------------------


UnRegTab = {}
UnReg = "UnReg.dat"


function Main()
   SetTimer(30*min -- Set timer here
   StartTimer()
   frmHub:RegBot(sBot)   --If using main bot, remark this line, add -- ie.. --frmHub:RegBot(sBot)
   LoadFromFile(UnReg)
end

function OnExit()
   SaveToFile(UnReg , UnRegTab , "UnRegTab")
end

function NewUserConnected(user, data)
   if (user.iProfile == -1 and UnRegTab[user.sName] == nil) then
      UnRegTab[user.sName] = 1
   end
end

function UserDisconnected(user, data)
   if (user.iProfile == -1 and UnRegTab[user.sName] ~= nil) then
      UnRegTab[user.sName] = nil
   end
end

function OnTimer()
   local usr,aux
      for usr, aux in UnRegTab do
         if (GetItemByName(usr) ~= nil) then
            sNick = GetItemByName(usr)
            sNick:SendPM(sBot, UnRegMsg)
            sNick:SendData(sBot, UnRegMsg)
         end
      end
end

function Serialize(tTable, sTableName, sTab)
   assert(tTable, "tTable equals nil");
   assert(sTableName, "sTableName equals nil");

   assert(type(tTable) == "table", "tTable must be a table!");
   assert(type(sTableName) == "string", "sTableName must be a string!");

   sTab = sTab or "";
   sTmp = ""

   sTmp = sTmp..sTab..sTableName.." = {\n"

   for key, value in tTable do
      local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);

      if(type(value) == "table") then
         sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
      else
         local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
         sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
      end

      sTmp = sTmp..",\n"
   end

   sTmp = sTmp..sTab.."}"
   return sTmp
end

function SaveToFile(file , table , tablename)
   writeto(file)
   write(Serialize(table, tablename))
   writeto()
end

function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
loadstring(handle:read("*all"))
handle:flush()
handle:close()
end
end
-------------------------------------------------
this one is whit a timer in it will send pm as well in the main ;)

Herodes

took 36secs ... not tested..
-- PMUnRegs by Herodes 
function ChatArrival( user, data )
	data = string.sub(data, 1, -2)
	local s,e,cmd,args = string.find( data, "%b<>%s+(%S+)%s*(.*)")
	if cmd == "!pmunreg" then
		if args then
			for i, us in frmHub:GetOnlineUsers() do
				if us.iProfile == -1 then
					us:SendPM( "PMUnRegs", user.sName.." says: "..args)
				end
			end
		else
			user:SendData( "PMUnRegs", "Syntax Error Use: !pmunreg ")
		end
		return 1
	end
end

jiten

yw Requiem.

Here you go (NL)waarom (another one ;) )

--Script by Optimus 
--Converted to LUA 5 by jiten
--massage on time in Main Chat, as well as PM 
-- 
-- 

--User Settings------------------------------------------------------------------------------------- 
-- 
--Name for bot[You can use your main bot, if so no need to register this bot. See 'function main'. 
sBot = "?Unreg?" 
--Interval [in minutes] to PM unregistered users 
sec=1000 
min=60*sec 
hour=60*min 
--Message to send to unregistered Users 
UnRegMsg = "You can't download if your not Registered type !regme ..... on the dots your password(make up your own password) (then close the hub and logon again ) or else you keep getting this annoying message till you registered!" 
-- 
--End User Settings---------------------------------------------------------------------------------- 

UnRegTab = {} 
UnReg = "UnReg.dat" 


function Main() 
	SetTimer(30*min) -- Set timer here 
	StartTimer()
	frmHub:RegBot(sBot) --If using main bot, remark this line, add -- ie.. --frmHub:RegBot(sBot) 
	LoadFromFile(UnReg) 
end 

function OnExit() 
	SaveToFile(UnReg , UnRegTab , "UnRegTab") 
end 

function NewUserConnected(user, data) 
	if (user.iProfile == -1 and UnRegTab[user.sName] == nil) then 
		UnRegTab[user.sName] = 1 
	end 
end 

function UserDisconnected(user, data) 
	if (user.iProfile == -1 and UnRegTab[user.sName] ~= nil) then 
		UnRegTab[user.sName] = nil 
	end 
end 

function OnTimer() 
	local usr,aux 
	for usr, aux in UnRegTab do 
		if (GetItemByName(usr) ~= nil) then 
			sNick = GetItemByName(usr) 
			sNick:SendPM(sBot, UnRegMsg) 
			sNick:SendData(sBot, UnRegMsg) 
		end 
	end 
end 

function Serialize(tTable, sTableName, sTab)
        assert(tTable, "tTable equals nil");
        assert(sTableName, "sTableName equals nil");

        assert(type(tTable) == "table", "tTable must be a table!");
        assert(type(sTableName) == "string", "sTableName must be a string!");

        sTab = sTab or "";
        sTmp = ""

        sTmp = sTmp..sTab..sTableName.." = {\n"

        for key, value in tTable do
                local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
                        sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
                end

                sTmp = sTmp..",\n"
        end

        sTmp = sTmp..sTab.."}"
        return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
	handle:flush()
        handle:close()
end

function LoadFromFile(file)
	local handle = io.open(file,"r")
	if (handle ~= nil) then
                dofile(file)
		handle:flush()
		handle:close()
        end
end

Herodes

jiten: why do all that ? there is things in the new API that make it easier..
this was one of the points why the API was changed in the first place

jiten

Gonna try using it in the next scripts.
I'm still getting used to the new API.
Anyway, thanks for the hint  :]

Cheers

Herodes

The trick is when you want to get something from PtokaX look in the Scripting-Interface.txt cause it might just be giving it to you already ;)

jiten

Ok, I'll start looking for on it  :D

Optimus

-- Message Unregged Users
-- Made by Optimus
-- 03/30/05

sBot = "BotName"

Main = function()
	frmHub:RegBot(sBot)
end

ChatArrival = function(user, data)
	data=string.sub(data,1,string.len(data)-1)
	s,e,cmd=string.find(data, "%b<>%s+(%S+)")
	if (cmd == "!messunreg") then
		if user.bOperator then			
			local s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.*)")
			if message then
				local border = ""
				if (string.len ( message)*2/3+2) < 76 then
					border = string.rep ("-", string.len (message)*2/3+2)
				else
					border = string.rep ("-", 75)
				end message = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
				for id,who in frmHub:GetOnlineUsers() do
					if who.iProfile == -1 then
						who:SendPM(sBot, message)
					end
				end
			else
				user:SendData(sBot, "*** Usage: !messunreg ")
			end
		end
		return 1
	end
end


Check this 1 out much better

- Optimus

SMF spam blocked by CleanTalk