Forum

> > CS2D > Scripts > Simple script needed
Forums overviewCS2D overview Scripts overviewLog in to reply

English Simple script needed

9 replies
To the start Previous 1 Next To the start

old Simple script needed

Jaso
BANNED Off Offline

Quote
Only one player can join the t.
The t has to be random selected.
So if there is already a terrorist than no one else can join at t.

old Re: Simple script needed

Bowlinghead
User Off Offline

Quote
You mean, all are CT and than 1 Player is randomly selected and go to Terrorist, and no one can join the Terrorists?

I cant help .
I only can say, look in other Scripts.
In the Script Zombie Plague there is also a randomly System (After 10 Seconds, 1 Player go Zombies)
I only know, for randomly things use "math.randomseed" but its no real help...

old Re: Simple script needed

archmage
User Off Offline

Quote
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
27
math.randomseed(os.time())
addhook("startround", "select_t")
addhook("team", "check_team")

function select_t()
	local t = player(0, "team1")
	local ct = player(0, "team2")

	for _, v in pairs(t) do
		parse("makect "..v)
	end

	local random_id = ct[math.random(1, #ct)]
	
	parse("maket "..random_id)

	msg(player(random_id, "name").." was selected as the terrorist.@C")
end

function check_team(id, t)
	if ( t == 1 ) then	-- if the player attempts to join the terrorists
		if ( #player(0, "team1") > 1 ) then
			parse("makect "..id)
			msg2(id, "©255000000You cannot join the terrorists at this time.@C")
		end
	end
end

old Re: Simple script needed

Jaso
BANNED Off Offline

Quote
Edit: It goes in a loop the script doesnt stop....
edited 1×, last 04.05.11 10:05:18 am

old Re: Simple script needed

Jaso
BANNED Off Offline

Quote
It just goes like this:
Terrorists win
Counter terrorist win
Round draw

And its keeps happening just when you join ct or t it just happends
And it doesnt stop.

I use it with standart mode try it by yourself..

old Re: Simple script needed

archmage
User Off Offline

Quote
Try this:
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
27
28
29
30
31
math.randomseed(os.time())
addhook("startround", "select_t")
addhook("team", "check_team")

function select_t()
     local t = player(0, "team1")
     local ct = player(0, "team2")

	while (#t > 1) do
		parse("makect "..t[1])
		table.remove(t, 1)
	end

	ct = player(0, "team2")

     local random_id = ct[math.random(1, #ct)]
     
     parse("maket "..random_id)
	parse("makect "..t[1])

     msg(player(random_id, "name").." was selected as the terrorist.@C")
end

function check_team(id, t)
     if ( t == 1 ) then     -- if the player attempts to join the terrorists
          if ( #player(0, "team1") > 1 ) then
               parse("makect "..id)
               msg2(id, "©255000000You cannot join the terrorists at this time.@C")
          end
     end
end

old Re: Simple script needed

Jaso
BANNED Off Offline

Quote
•This message i get random
LUA ERROR: sys/lua/Select.lua:19: attempt to concatenate field '?' (a nil value)

LUA ERROR: sys/lua/Select.lua:16: bad argument #2 to 'random' (interval is empty) •this happend when i am alone in the server.

•If i add a bot the script creates a loop again and it keep saying terrorist win and if i add another bot it starts to say counter terrorists win in a loop.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview