Forum

> > CS2D > Scripts > Counting player lua request
Forums overviewCS2D overview Scripts overviewLog in to reply

English Counting player lua request

7 replies
To the start Previous 1 Next To the start

old Counting player lua request

sadswsww
User Off Offline

Quote
i need a lua that when player press F2 then the x go up to 1. If x = 5 then check all the player, who pressed f2 will be ....kill !
Thanks for reading √

old Re: Counting player lua request

Alistaire
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook('serveraction', 'serveractionHook')

a = 0

function count(id)
	a = a + 1
	if a == 5 then
		a = 0
		parse('killplayer '..id)
	end
end

function serveractionHook(id, action)
	if action == 1 then
		count(id)
	end
end

old Re: Counting player lua request

Zeik
User Off Offline

Quote
I think he meant....

1
2
When a player presses F2: x = x + 1;
if x == 5: all players who pressed F2 get killed;

So all 5 get killed and surely he wants the counter to reset.

old Re: Counting player lua request

AlcatrazZ
BANNED Off Offline

Quote
The code like user Zeik sayed:
not tested >


Note: I think that he want to vote system. So my not tested code available to reach count = 5 by once player.
edited 1×, last 20.05.14 04:13:33 pm

old Re: Counting player lua request

Dousea
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
x = 0
f2 = {}

for id = 1, 32 do
	f2[id] = false
end

addhook ("serveraction", "serveractionhook")

function serveractionhook (id, action)
	if (action == 1) then
		f2[id] = true
		
		x = x + 1
		
		if (x == 5) then
			x = 0
			
			for id = 1, 32 do
				if (f2[id]) then
					parse ("killplayer " .. id)
				end
			end
		edne
	end
end

old Re: Counting player lua request

AlcatrazZ
BANNED Off Offline

Quote
@user Dousea: Oh, not bad √ . I need to learn how to write simpler scripts in lua. We need to fix this code, because all players who press F2 and reach the result, f2/players table need to be reset.

Note: I think that we worked on the script together, so we created 2 posts.
I think that he want to vote system. So my not tested code available to reach count = 5 by once player.

old Re: Counting player lua request

Zeik
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
x = 0
f2 = strkl(f2)

function strkl(x) -- [start] -> [reset and/or kill]
	for i = 1, 32 do
		if (x[i]) then
			parse ("killplayer " .. i)
        end
		x[i] = false
	end
	return x
end

addhook ("serveraction", "serveractionhook")
function serveractionhook (id, action)
     if (action == 1) then
          f2[id] = true
          x = x + 1
          if (x == 5) then
               x = 0
			   strkl(f2)
          end
     end
end

I don't know if it works...
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview