English Team Limiter

6 replies
Goto Page
To the start Previous 1 Next To the start
28.04.16 10:59:34 pm
Up
neiz
User
Offline Off
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!
Sword Art Online
29.04.16 06:34:46 am
Up
Louie
User
Offline Off
Maybe something like:
Code:
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
No system is safe.
29.04.16 07:23:49 am
Up
Hajt
User
Offline Off
Here's my simpler way.
Code:
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
29.04.16 09:07:40 am
Up
neiz
User
Offline Off
@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
Code:
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:
Code:
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.
Sword Art Online
29.04.16 09:20:10 am
Up
Hajt
User
Offline Off
Have a look at cs2d lua hook team and then change this line:
Code:
1
function neiz.team()

to
Code:
1
function neiz.team(id)
29.04.16 01:27:52 pm
Up
Ortimh
User
Offline Off
@user Hajt: Your script applies to all team so when there're 3 terrorists, counter-terrorists can't join.

Code:
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.
Code:
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")
I'm awesome ... and I really like cookies.
29.04.16 04:09:22 pm
Up
neiz
User
Offline Off

Thanks user Ortimh!
Sword Art Online
To the start Previous 1 Next To the start