Forum

> > CS2D > Scripts > Max Players Ever Lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English Max Players Ever Lua

4 replies
To the start Previous 1 Next To the start

old Max Players Ever Lua

maPmaKer
User Off Offline

Quote
Hello people. I was wondering if somebody can do a lua for me and others who want to, that can register the maximum amount of players on a server for an amount of time like 1 day (24 hours).

It would be very useful for me.

Thanks!
maPmaKer

EDIT: Still need help...anyone?
edited 1×, last 30.12.10 10:05:26 am

old Re: Max Players Ever Lua

DannyDeth
User Off Offline

Quote
Well it wouldn't be too hard, but I think you would have a problem with the time thingy...

I am not sure if Lua has a function that measures in days , since 24 hours = 5184000 seconds = a long time, I am not sure if it will be easy

Well, might as well try else I never know
I will edit/post the script soon...

Well, here's one that counts how many times people connect to your server ( not how many players exactly ):
1
2
3
4
5
6
7
8
seconds = 0
player_count = 0
addhook("join","count_players")
function count_players()
	if( seconds < 51840000 ) then
		player_count = player_count + 1
	end
end

I will write another that counts how many players next

EDIT2: Here is a script that should record how many registered USGN players come on:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
seconds = 0
player_count = 0
players = {}
addhook("join","count_players")
function count_players(id)
	if( seconds < 51840000 ) then
		if( players[player(id,"usgn")] != nil )
			-- Do nothing coz the person has already been registered...
		else
			players[player(id,"usgn")]
			player_count = player_count + 1
		end
	end
end

You could maybe use IP addresses instead of USGN account if you like, you can replace "usgn" with "ip" in the script so it looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
seconds = 0
player_count = 0
players = {}
addhook("join","count_players")
function count_players(id)
	if( seconds < 51840000 ) then
		if( players[player(id,"ip")] != nil )
			-- Do nothing coz the person has already been registered...
		else
			players[player(id,"ip")]
			player_count = player_count + 1
		end
	end
end
Hope it works/you like it
edited 2×, last 30.12.10 10:23:42 am

old Re: Max Players Ever Lua

Banaan
User Off Offline

Quote
Sure it will be easy DannyDeth.

You should use minutes rather than seconds there. You have also forgotten to actually do something with the seconds; the seconds variable will always still 0 in your script.

Furthermore, this is a total counter, not a max counter.


Here is my implementation:
1
2
3
4
5
6
7
8
addhook("join","add_player")

maxPlayers = {}

function add_player()
	local d=os.date("%d-%m-%Y")
	if(#player(0,"table")>maxPlayers[d]) then maxPlayers[d]=#player(0,"table") end
end

This will result in a table (maxPlayers) containing the maximum amount of players for every day. To show the maximum amount of players of a certain day, simply use the Lua function print:
1
print(maxPlayers["30-12-2010"])
Will output something like 16

The keys of the table are in the format dd-mm-yyyy.

To show the maximum amount of players of today, use the following code:
1
print(maxPlayers[os.date("%d-%m-%Y")])

To continuously show it, use hudtxt in combination with a join hook, so that the hudtxt is updated every time a player joins.

Feel free to ask more about this script

old Thanks

maPmaKer
User Off Offline

Quote
Thanks for ur answers. I'll try 'em all

old Re: Max Players Ever Lua

DannyDeth
User Off Offline

Quote
@Banaan:
Oh shit yeah I forgot, LOL. Maybe it will record all of the players for all time

Stupid me, I always manage to screw up some way or another
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview