again help needed
 

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

again help needed

Started by ConejoDelMal, 10 April, 2005, 22:53:58

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ConejoDelMal

I am having a bit of a problem, since the latest ptokax, i cant seem to have motd displayed before the scripts, is there something i should add to the scripts? (simple ones, like onjoin)

thx
Rede-DC Comunidade Portuguesa de DC

Dessamator

#1
yaps u need some sort of timer, to delay the script onjoin msg
u could try something like this ::
 
tDelay={}
function Main()
	SetTimer(1000)
	StartTimer()
end

function NewUserConnected(user)
	tDelay[user.sName] ={}
	tDelay[user.sName]["time"] = "1"	
end

function OnTimer()
	for i,v in tDelay do
		tDelay[i]["time"]= tDelay[i]["time"]-1
		if tDelay[i]["time"] ==0 then
-----> put ur code here <----------
                                end
                 end
end

 
Ignorance is Bliss.

ConejoDelMal

ok, but i'm a bit lost here... when i have a script like:
Bot = "-=Brainu=-"



function NewUserConnected(user) 

	if user.iProfile == 4 then
		SendToAll(Bot, "O Networker -= "..user.sName.." =- entrou no Hub")
	end

	if user.iProfile == 1 then
		SendToAll(Bot, "O Operador -= "..user.sName.." =- entrou no Hub")
	end

	if user.iProfile == 0 then
		SendToAll(Bot, "O Admin -= "..user.sName.." =- entrou no Hub")
	end

	if user.iProfile == 2 then
		SendToAll(Bot, "O ViP -= "..user.sName.." =- entrou no Hub")
	end

	if user.iProfile == 5 then
		SendToAll(Bot, "O Master -= "..user.sName.." =- entrou no Hub")
	end

	if (user.sName == "{HubListPinger}") then 
		SendToAll(Bot, "O Bot "..user.sName.." entrou no Hub.")
		SendToAll(Bot, "A Lista de Users em [URL]www.lusoleader.co.nr[/URL] foi Actualizada")
	end
end

function UserDisconnected(user)

	if user.iProfile == 4 then
		SendToAll(Bot, "O Networker-= "..user.sName.." =- saiu do Hub")
	end

	if user.iProfile == 1 then
		SendToAll(Bot, "O Operador -= "..user.sName.." =- saiu do Hub")
	end

	if user.iProfile == 0 then
		SendToAll(Bot, "O Admin -= "..user.sName.." =- saiu do Hub")
	end

	if user.iProfile == 2 then
		SendToAll(Bot, "O ViP -= "..user.sName.." =- saiu do Hub")
	end

	if user.iProfile == 5 then
		SendToAll(Bot, "O Master -= "..user.sName.." =- saiu do Hub")
	end

	if (user.sName == "{HubListPinger}") then 
		SendToAll(Bot, "O Bot "..user.sName.." saiu do Hub.")
	end
end

OpConnected=NewUserConnected

OpDisconnected=UserDisconnected

how does it stays in the end?
Rede-DC Comunidade Portuguesa de DC

Herodes

try this ..
--- touched by Herodes
-- to provide an example of delayed messages..

Bot = "-=Brainu=-"
tDelay = {}

function Main()
	SetTimer(1000)
	StartTimer()
end

function OnTimer()
	for i,v in tDelay do
		v[3] = v[3] - 1
		if v[3] == 0 then
			SendToAll( v[2], v[1] )
		end
		tDelay[i] = nil
	end
end

function AddDelayedMessage( msg, delay )
	table.insert( tDelays, { msg, Bot, delay or 1 } )
end

function NewUserConnected(user) 
	local tProfiles = {
		[0] = "O Admin -= "..user.sName.." =- entrou no Hub",
		[1] = "O Operador -= "..user.sName.." =- entrou no Hub",
		[2] = "O ViP -= "..user.sName.." =- entrou no Hub",
		[4] = "O Networker -= "..user.sName.." =- entrou no Hub",
		[5] = "O Master -= "..user.sName.." =- entrou no Hub",
	}
	if tProfiles[user.iProfile] then
		AddDelayedMessage( tProfiles[user.iProfile] )
	elseif (user.sName == "{HubListPinger}") then
		AddDelayedMessage( "O Bot {HubListPinger} entrou no Hub." )
		AddDelayedMessage( "A Lista de Users em [URL]www.lusoleader.co.nr[/URL] foi Actualizada" )
	end
end

function UserDisconnected(user)
	local tProfiles = {
		[0] = "O Admin -= "..user.sName.." =- saiu do Hub",
		[1] = "O Operador -= "..user.sName.." =- saiu do Hub",
		[2] = "O ViP -= "..user.sName.." =- saiu do Hub",
		[4] = "O Networker-= "..user.sName.." =- saiu do Hub",
		[5] = "O Master -= "..user.sName.." =- saiu do Hub",
	}
	if tProfiles[user.iProfile] then
		AddDelayedMessage( tProfiles[user.iProfile] )
	elseif (user.sName == "{HubListPinger}") then
		AddDelayedMessage( "O Bot {HubListPinger} saiu do Hub." )
	end
end

OpConnected=NewUserConnected
OpDisconnected=UserDisconnected

Dessamator

#4
or this::

--By Dessamator
Bot = "-=Brainu=-"
tDelay={}
function Main()
	SetTimer(1000)
	StartTimer()
end

function NewUserConnected(user)
	if not(user.iProfile=="3") and user.bRegistered  then
		tDelay[user.sName] ={}
		tDelay[user.sName]["time"] = "1"	
	end
end

function OnTimer()
local Profiles ={ [0] = "Admin",
	   [1] = "Operador",
	   [2] = "Vip",
	   [3] = "",
	   [4] = "Networker",
	   [5] = "Master",
}
	for i,v in tDelay do
		tDelay[i]["time"] = tDelay[i]["time"]- 1
		if tDelay[i]["time"] ==0 then
			if not(GetItemByName(i).iProfile=="3" or nil)  then
				SendToAll(Bot,"O "..Profiles[GetItemByName(i).iProfile].." "..i.." =- entrou no Hub")	
			elseif (GetItemByName(i).sName == "{HubListPinger}") then
				SendToAll( "O Bot {HubListPinger} entrou no Hub." )
			end
                end
        end
end


function UserDisconnected(user)
local Profiles ={ [0] = "Admin",
	   [1] = "Operador",
	   [2] = "Vip",
	   [3] = "",
	   [4] = "Networker",
	   [5] = "Master",
}
	if not(user.iProfile=="3") and user.bRegistered  then
		SendToAll(Bot, "O "..Profiles[user.iProfile].." =- saiu do Hub")
	elseif (user.sName == "{HubListPinger}") then
		temp="O Bot {HubListPinger} entrou no Hub."
		temp=temp.."A Lista de Users em [URL]www.lusoleader.co.nr[/URL] foi Actualizada"
		SendToAll(temp)
	end	
tDelay[user.sName]["time"] = nil
end

OpConnected=NewUserConnected
OpDisconnected=UserDisconnected


Less repitition, :D
Ignorance is Bliss.

Herodes

You are missing very important aspects.

1)having the tables local in the functions enables you to not store them in the mem.
2)Doing it the way I propose you can customise the messages.
3) having a function to insert the data in a table in, again, the proposed format, makes it possible to extend it to include more stuff like a Botname, a different time delay etc.
4) I noticed that you are not emptying ( =nil ) the index of the table eventhough it has completed its mission. that could cause considerable mem usage, at least in a high-traffic hub ..

Watch both scripts through, and look out for the points I am mentioning ..

bastya_elvtars

Just do an x=os.clock() and wait until os.clox()-x==2 or something else. This is a better way than starting timer on every join, but this is only my 2 cents...
Everything could have been anything else and it would have just as much meaning.

ConejoDelMal

#7
thx a lot, i will try it, but maybe i still annoy you with this  :P

*Edited*
Herodes, in your script i get this:
in_out.lua:23: bad argument #1 to `insert' (table expected, got nil)
Rede-DC Comunidade Portuguesa de DC

bastya_elvtars

replace tDelays to tDelay and it will work.
Everything could have been anything else and it would have just as much meaning.

ConejoDelMal

#9
QuoteOriginally posted by bastya_elvtars
replace tDelays to tDelay and it will work.

thx a lot! really didnt noticed that one...
and btw, tried to make it the way you said, or better, still trying without sucess..

And Dessamator, yours worked fine aswell, but if it uses more mem, i prefer not to thx anyway :)

*Edited*
I have another question, when you want to send a delayed message to a new connecting user, how do you make it? tried as previous, but it cant identify the user.sName, i guess its because its delayed :P
This one is about a OnJoin, a simple one with nick, ip, share and status of the user only
Rede-DC Comunidade Portuguesa de DC

jiten

Are you trying to convert BrainMaster?

Dessamator

QuoteOriginally posted by Herodes
You are missing very important aspects.

1)having the tables local in the functions enables you to not store them in the mem.
2)Doing it the way I propose you can customise the messages.
3) having a function to insert the data in a table in, again, the proposed format, makes it possible to extend it to include more stuff like a Botname, a different time delay etc.
4) I noticed that you are not emptying ( =nil ) the index of the table eventhough it has completed its mission. that could cause considerable mem usage, at least in a high-traffic hub ..

Watch both scripts through, and look out for the points I am mentioning ..

for point 1, i do agree, but i just did it that way to avoid repetition,
for point 2, well i just did it in a way which he asked he never asked for customization, and possibly he doesnt need it !!
for point 3, i do agree again, but well, he didnt ask for it,
point 4 agreed also and done !!, post edited above
Ignorance is Bliss.

Dessamator

QuoteOriginally posted by bastya_elvtars
Just do an x=os.clock() and wait until os.clox()-x==2 or something else. This is a better way than starting timer on every join, but this is only my 2 cents...

hmm, good idea ill try it l8r !!
Ignorance is Bliss.

Dessamator

#13
well bastya, i tried the os.clocks, but in the same function newuserconnected, it always sent the msg before the motd, havent tried it on a different function, anyways, heres a way of doing it without using using a timer or the os.clocks , ::::::::::::

--By Dessamator
Bot = "-=Brainu=-"
function Main()
end

function NewUserConnected(user)
local Profiles ={ [0] = "Admin",
   [1] = "Operador",
   [2] = "Vip",
   [3] = "",
   [4] = "Networker",
   [5] = "Master",
}
	if not(user.iProfile=="3") and user.bRegistered  then
		temp="O "..Profiles[user.iProfile].." "..user.sName.." =- entrou no Hub"
	elseif (user.sName == "{HubListPinger}") then
		temp="O Bot {HubListPinger} entrou no Hub."
	end

end

function MyINFOArrival(User, Data)
	if not(temp==nil) then 
		SendToAll(Bot,temp)
		temp=nil
        end
end	

function UserDisconnected(user)
local Profiles ={ [0] = "Admin",
   [1] = "Operador",
   [2] = "Vip",
   [3] = "",
   [4] = "Networker",
   [5] = "Master",
}

	if not(user.iProfile=="3") and user.bRegistered  then
		SendToAll(Bot, "O "..Profiles[user.iProfile].." =- saiu do Hub")
	elseif (user.sName == "{HubListPinger}") then
		temp="O Bot {HubListPinger} entrou no Hub."
		temp=temp.."A Lista de Users em [URL]www.lusoleader.co.nr[/URL] foi Actualizada"
		SendToAll(temp)
	end
end

OpConnected=NewUserConnected
OpDisconnected=UserDisconnected
Ignorance is Bliss.

jiten


bastya_elvtars

Here is a script, using tezlo's routine. Sorry, it is not fully converted, I just scavanged it.

-- chatdelay by tezlo

list = {}
delay = 2
-- in seconds


function DataArrival(user, data)
	if string.sub(data, 1, 1) == "<" and not user.bOperator then
		local time, now = list[user.sName], os.clock()
		if time and time+delay > now then
			user:SendData(">> wait")
			return 1
		else
			list[user.sName] = now
		end
	end
Everything could have been anything else and it would have just as much meaning.

Dessamator

QuoteOriginally posted by bastya_elvtars
Here is a script, using tezlo's routine. Sorry, it is not fully converted, I just scavanged it.

-- chatdelay by tezlo

list = {}
delay = 2
-- in seconds


function DataArrival(user, data)
	if string.sub(data, 1, 1) == "<" and not user.bOperator then
		local time, now = list[user.sName], os.clock()
		if time and time+delay > now then
			user:SendData(">> wait")
			return 1
		else
			list[user.sName] = now
		end
	end

nop i converted it and tried it, doesnt work, or mayb i just dont know how to do that !!
Ignorance is Bliss.

Herodes

btw keep in mind that we are talking about a 2ms delay .. maybe it isn't enough .. I really find that using the OnTimer would by far the simplest and more efficient way to do such thing ..

Dessamator

QuoteOriginally posted by Herodes
btw keep in mind that we are talking about a 2ms delay .. maybe it isn't enough .. I really find that using the OnTimer would by far the simplest and more efficient way to do such thing ..

hmm, but that response is directed to my newest script or to bastya's unworking script??????

mine is cooler, hehe, no timers no delays, no extra tables !!!
Ignorance is Bliss.

Herodes

#19
QuoteOriginally posted by Dessamator
QuoteOriginally posted by Herodes
btw keep in mind that we are talking about a 2ms delay .. maybe it isn't enough .. I really find that using the OnTimer would by far the simplest and more efficient way to do such thing ..
hmm, but that response is directed to my newest script or to bastya's unworking script??????
directed to the method bastya proposes and the way you have tried to implement it.

Dessamator

QuoteOriginally posted by Herodes
QuoteOriginally posted by Dessamator
QuoteOriginally posted by Herodes
btw keep in mind that we are talking about a 2ms delay .. maybe it isn't enough .. I really find that using the OnTimer would by far the simplest and more efficient way to do such thing ..
hmm, but that response is directed to my newest script or to bastya's unworking script??????
directed to the method bastya proposes and the way you have tried to implement it.

hmm ok, i tried more than 2ms(a second), but even so, it always displayed after the motd, which leads me to believe, that maybe the whole newuserarrival is processed before the motd, and never after, just a guess!
Ignorance is Bliss.

Herodes

QuoteOriginally posted by Dessamator
hmm ok, i tried more than 2ms(a second), but even so, it always displayed after the motd, which leads me to believe, that maybe the whole newuserarrival is processed before the motd, and never after, just a guess!
Have no doubts. that is the way that the procedure works. meant for saving the motd bandwidth if a user has to be disconnected on entry.

Dessamator

QuoteOriginally posted by Herodes
QuoteOriginally posted by Dessamator
hmm ok, i tried more than 2ms(a second), but even so, it always displayed after the motd, which leads me to believe, that maybe the whole newuserarrival is processed before the motd, and never after, just a guess!
Have no doubts. that is the way that the procedure works. meant for saving the motd bandwidth if a user has to be disconnected on entry.

yah it figures, i tried using a loop, with a big delay, i tried to use it the way bastya suggested, but the info always got sent b4 the motd, so i solved it by using myinfoarrival.

But heres another question, whats the hierarchy(from first to last) in those arrivals, from what i can c on the ptokax, first of all is the Supports, Key , validatenick, getnicklist, and myinfo, what about the rest?
Ignorance is Bliss.

Herodes

#23
QuoteOriginally posted by Dessamator
yah it figures, i tried using a loop, with a big delay, i tried to use it the way bastya suggested, but the info always got sent b4 the motd, so i solved it by using myinfoarrival.
Basically waiting for the time to change isn't helping,.. thats because you are literally and simply 'waiting'. What you really need is make a check on if a certain time period has been spent.

for the DC Protocol parsing order :
I am not aware the order in which it is working and I suppose that it shoulde be different for client supporting various DC Protocol enhancements like for example Quicklist.

The only way you can test it is make a script with all of them and log in a table ( with table.insert so that you still have ordered entries ) and then trigger a listing from it and see what happened..

SMF spam blocked by CleanTalk