Forum

> > CS2D > Scripts > Team Limiter
Forums overviewCS2D overview Scripts overviewLog in to reply

English Team Limiter

6 replies
To the start Previous 1 Next To the start

old Team Limiter

neiz
User Off Offline

Quote
Hi!,

How to make "Team Limited"?
That Like Team Terrorist have Limited Join.
so you can't join Terrorist Team again.
Max Player on Terrorist Team is 3.
and CT is normal.

Thanks!

old Re: Team Limiter

Louie
User Off Offline

Quote
Maybe something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
joins = 0
max_joins = 3
addhook("team", "_team")
function _team(id, team)
    if team == 1 and joins >= max_joins then
        return 1
    else
        joins = joins + 1
    end
end

addhook("leave", "_leave")
function _leave(id)
    if player(id, "team") == 1 then
        joins = joins - 1
    end
end
----- Untested

old Re: Team Limiter

Hajt
User Off Offline

Quote
Here's my simpler way.
1
2
3
4
5
6
7
8
9
neiz = {}

addhook("team","neiz.team")
function neiz.team()
	local terrorists = player(0,"team1")
	if #terrorists >= 3 then
		return 1
	end
end

old Re: Team Limiter

neiz
User Off Offline

Quote
@user Hajt: Your Scripts is Working Thanks!.
@user Louie: Nothing Happen, But Error Output not showed.

EDIT: user Hajt Your scripts give error if i am add cs2d lua cmd msg2
1
2
3
4
5
6
7
8
9
10
11
12
neiz = {}
parse("mp_autoteambalance 0")

addhook("team","neiz.team")
function neiz.team()
     local terrorists = player(0,"team1")
     if #terrorists >= 3 then
		msg2(id,"©180000000Terrorist Team is Full!, You can't join Terrorist.")
		parse("makect "..id)
		return 1
     end
end

• Error Output says:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Lua: Adding function 'neiz.team' to hook 'team'
U.S.G.N.: Sending serverlist ADD-request...
U.S.G.N.: Serverlist entry updated
U.S.G.N.: Ping/State 'playing'
Guuune joins the Terrorist Forces


[b]PlayWithWheel connected

[b]PlayWithWheel joins the Terrorist Forces


[b]Slayer connected

[b]Slayer joins the Terrorist Forces


[b]PlayWithJoystick connected

LUA ERROR: sys/lua/autorun/FurtyAdminScripts.lua:8: bad argument #1 to 'msg2' (number
expected, got nil)
 -> [C]: in function 'msg2'
 -> sys/lua/autorun/FurtyAdminScripts.lua:8: in function <sys/lua/autorun
FurtyAdminScripts.lua:5>
 -> in Lua hook 'team', params: 4, 1, 0
[b]PlayWithJoystick joins the Terrorist Forces

Help me Please.

old Re: Team Limiter

Hajt
User Off Offline

Quote
Have a look at cs2d lua hook team and then change this line:
1
function neiz.team()
to
1
function neiz.team(id)

old Re: Team Limiter

Dousea
User Off Offline

Quote
@user Hajt: Your script applies to all team so when there're 3 terrorists, counter-terrorists can't join.

1
2
3
4
5
function teamhook(id, team)
	return team == 1 and (#player(0, "team1") >= 3 and 1 or 0) or 0
end

addhook("team", "teamhook")
But if you want to add more expressions then use this.
1
2
3
4
5
6
7
8
9
function teamhook(id, team)
	if (team == 1 and #player(0, "team1") >= 3) then
		return 1
	end
	
	return 0
end

addhook("team", "teamhook")
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview