OnJoin
 

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

OnJoin

Started by ConejoDelMal, 12 April, 2005, 16:16:20

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ConejoDelMal

hey, i'm searching for an Onjoin script for Ptokax 16.09 only with a few info like:

Your Info:
Nick:
Ip:
Status:
Sharing:

-- script modded from "welcomemesses script by AmsterdamBulldogs" by jiten

login = {
	["BotName"] = "-=Brainu=-",
}

local kb = "1024"
local mb = kb*kb
local gb = mb*kb
local tb = gb*kb

function Main()
	frmHub:RegBot(login.BotName)
end

--// Profile Counter
function ProfileCounter(profile)
	local table, count = GetUsersByProfile(profile), 0
	for i, User in table do 
		if GetItemByName(User) then
			count = count + 1
		end
	end
	return count
end

function NewUserConnected(user)
	local timeanddate = os.date("%d-%m-%Y  %H:%M:%S")
	local tmp = os.clock() 
	local weeks, days, hours, minutes, seconds = math.floor(tmp/604800), math.floor(math.mod(tmp/86400, 7)), math.floor(math.mod(tmp/3600, 24)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60))
	if frmHub:GetHubTopic() == nil then
		topic = "No topic set"
	else
		topic = frmHub:GetHubTopic()
	end
	if user.sMyInfoString then
		local disp = ""
		doGetProfile =  GetProfileName(user.iProfile) or "N?o Registado"
		hubshare = string.format("%0.3f", frmHub:GetCurrentShareAmount()/(tb)).." TB"
		local _,_,share = string.find(user.sMyInfoString, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $[^$]+[^$]%$[^$]*%$%s*(%d+)%$" )

		if share then
			minshare = string.format("%0.3f", tonumber(share)/gb).." GB"
		else
			minshare = "Corrupt"
		end
		
		disp = disp.."A Tua Info:\r\n"
		disp = disp.."	Nick: "..user.sName.."\r\n"
		disp = disp.."	IP: "..user.sIP.."\r\n"
		disp = disp.."	Status: "..doGetProfile.."\r\n"
		disp = disp.."	Est?s a partilhar: "..minshare.."\r\n"
		msg = disp
	end
end

OpConnected = NewUserConnected

function MyINFOArrival(user, data)
	if not(msg==nil) then 
		user:SendData(msg)
		msg=nil
        end
end

jiten gave me this, but it sends me info on other users when connecting, and not always before the motd..
Rede-DC Comunidade Portuguesa de DC

jiten

#1
Here you go (another attempt):

-- script modded from "welcomemesses script by AmsterdamBulldogs" and Dessamator's Delaying script by jiten
-- removed unnecessary code and added table clearing
login = {
	["BotName"] = "CarinaLUA5",
}

local kb = "1024"
local mb = kb*kb
local gb = mb*kb
local tb = gb*kb

tDelay={}

function Main()
	frmHub:RegBot(login.BotName)
	SetTimer(1000)
	StartTimer()
end

--// Profile Counter
function ProfileCounter(profile)
	local table, count = GetUsersByProfile(profile), 0
	for i, User in table do 
		if GetItemByName(User) then
			count = count + 1
		end
	end
	return count
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
			local disp = ""
			doGetProfile =  GetProfileName(GetItemByName(i).iProfile) or "Not registered"
			local _,_,share = string.find(GetItemByName(i).sMyInfoString, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $[^$]+[^$]%$[^$]*%$%s*(%d+)%$" )
			if share then
				minshare = string.format("%0.3f", tonumber(share)/gb).." GB"
			else
				minshare = "Corrupt"
			end
			border1 = "  <========================= A Tua Info ================================>"
			disp = "\r\n\r\n"..border1.."\r\n"
			disp = disp.."	? Nick:				"..GetItemByName(i).sName.."\r\n"
			disp = disp.."	? IP:				"..GetItemByName(i).sIP.."\r\n"
			disp = disp.."	? Status:				"..doGetProfile.."\r\n"
			disp = disp.."	? Est?s a partilhar:			"..minshare.."\r\n"
			GetItemByName(i):SendData(disp)
			tDelay[user.sName] = nil
		end
	end
end

OpConnected = NewUserConnected
*Edit* Removed unnecessary code
Cheers

ConejoDelMal

Working great till now :)) thx a lot
Rede-DC Comunidade Portuguesa de DC

tezlo

hi, just a thought..
the tDelay table grows until hub restart since you never remove the entries, while it gets cycled every second
and if you don't intend to show hub uptime, share, topic or whatsoever, then maybe there's no need to calculate it
i get it that you copy/pasted from the scripts mentioned, but this is overkill
delayed = {}

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

function OnTimer()
	for nick, msg in delayed do
		SendToNick(nick, msg)
		delayed[nick] = nil
	end
end

function NewUserConnected(user)
	delayed[user.sName] = string.format("Your info..\n\tnick:\t%s\n\tip:\t%s\n\tprofile:\t%s\n\tshare:\t%0.2fGB",
		user.sName, user.sIP, GetProfileName(user) or "Unregistered", user.iShareSize/1024^3)
end

jiten


ConejoDelMal

QuoteOriginally posted by tezlo
hi, just a thought..
the tDelay table grows until hub restart since you never remove the entries, while it gets cycled every second
and if you don't intend to show hub uptime, share, topic or whatsoever, then maybe there's no need to calculate it
i get it that you copy/pasted from the scripts mentioned, but this is overkill
delayed = {}

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

function OnTimer()
	for nick, msg in delayed do
		SendToNick(nick, msg)
		delayed[nick] = nil
	end
end

function NewUserConnected(user)
	delayed[user.sName] = string.format("Your info..\n\tnick:\t%s\n\tip:\t%s\n\tprofile:\t%s\n\tshare:\t%0.2fGB",
		user.sName, user.sIP, GetProfileName(user) or "Unregistered", user.iShareSize/1024^3)
end

hmm...thx, but its not working, and no errors...
Rede-DC Comunidade Portuguesa de DC

tezlo

add this line if you want Ops to get the info..

OpConnected = NewUserConnected

ConejoDelMal

#7
QuoteOriginally posted by tezlo
add this line if you want Ops to get the info..

OpConnected = NewUserConnected

lol, thx! i'm commiting so many stupid mistakes in scripts lately..

*edited*
but its not showing profile, always says Unregistered...
Rede-DC Comunidade Portuguesa de DC

Madman

easy to fix..

just replace
user.sName, user.sIP, GetProfileName(user) or "Unregistered", user.iShareSize/1024^3)
with
user.sName, user.sIP, GetProfileName(user.iProfile) or "Unregistered", user.iShareSize/1024^3)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

ConejoDelMal

Am I that blind today? or am I just dumb?  :rolleyes:
Thx a  lot madman....i'm getting insane today
Rede-DC Comunidade Portuguesa de DC

Madman

np @ all...
happy to help =)
btw, beeing insane is good... just look at me... lol ;)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

jiten

QuoteOriginally posted by tezlo
hi, just a thought..
the tDelay table grows until hub restart since you never remove the entries, while it gets cycled every second
and if you don't intend to show hub uptime, share, topic or whatsoever, then maybe there's no need to calculate it
i get it that you copy/pasted from the scripts mentioned, but this is overkill

Yups, u're right.
Forgot to remove the entries and other stuffs that weren't necessary. I was in the moon yesterday  :D
Btw, I have updated the first post with the changes.

Cheers

SMF spam blocked by CleanTalk