Forum

> > CS2D > Scripts > Reward for end
Forums overviewCS2D overview Scripts overviewLog in to reply

English Reward for end

16 replies
To the start Previous 1 Next To the start

old Reward for end

tos12345678
User Off Offline

Quote
Hi, i need a help in this script

If counter-terrostist win then
each counter-terrorist player will receive: coins[id]=coins[id]+100

\\
I would ask for an example script, thanks.

old Re: Reward for end

tos12345678
User Off Offline

Quote
But, when i scripting with addhook endround then
Each players gains 100 coins
edited 1×, last 11.07.18 04:48:03 pm

old Re: Reward for end

KingShadow
User Off Offline

Quote
1
2
3
4
5
6
7
8
addhook('endround','endround_hook')
function endround_hook(mode)
if mode==2 then
for _, id in ipairs(player(0, "team2")) do
coins[id]=coins[id]+100
end
end
end
edited 5×, last 11.07.18 06:49:19 pm

old Re: Reward for end

Baloon
GAME BANNED Off Offline

Quote
1
2
3
4
5
6
7
8
function end_hook(mode)
 if mode==2 then
  for k,id in ipairs(player(0,"team2")) do
   coins[id]=coins[id]+100
  end
 end
end
addhook("endround","end_hook")

old Re: Reward for end

KingShadow
User Off Offline

Quote
@user Masea: what is your problem with me ? i just writing too fast so i made that :v also i forgot to add id in ipairs

PS:Edited!
edited 1×, last 11.07.18 06:15:12 pm

old Re: Reward for end

Yates
Reviewer Off Offline

Quote
@user KingShadow: His issue is that your code doesn't do what the person asked and that's very annoying. Please don't do that. If you don't fully understand the request, don't post. If you want to understand the request, ask.

old Re: Reward for end

KingShadow
User Off Offline

Quote
user Yates has written
@user KingShadow: His issue is that your code doesn't do what the person asked and that's very annoying. Please don't do that. If you don't fully understand the request, don't post. If you want to understand the request, ask.


dude i edited it i know and i understand what he wants but i was writing too fast

old Re: Reward for end

tos12345678
User Off Offline

Quote
This code doesn't working with my coins=initArray(32)
in shortcut i dont get coins after CT win.

old Re: Reward for end

Masea
Super User Off Offline

Quote
user KingShadow has written
i just writing too fast so i made that :v
Then write slowly instead if that could teach me something wrong. Nothing enforces you to post faster than the light, right?

user KingShadow has written
also i forgot to add id in ipairs
Lol. How did you forget that though? It was main and the only thing user tos12345678 wants anyway.

Furthermore, your approach is actually true - I have many problemos with you indeed.

old Re: Reward for end

princeofpersia
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
--HOOK--

addhook("endround","end_hook")
addhook("join","join_hook")

--TABLES--

coins = {}

--FUNCTIONS--

function join_hook(id)
  coins[id] = 0
end

function end_hook(mode)
 if mode == 2 then
  for _,id in pairs(playerlist) do
   if player(id, 'team') == 2 then
     coins[id] = coins[id] + 100
   end
  end
 end
end

old Re: Reward for end

Cure Pikachu
User Off Offline

Quote
@user princeofpersia: You did not call anything like
playerlist = player(0,"table")
so your code will just bug out at line 18. Just do what user KingShadow and user Baloon did with the looping.

Let's not forget that once objectives are thrown into the picture, CTs can win in a variety of ways that isn't killing the opposition (see cs2d lua hook endround). If you want to factor that, try this:
1
2
3
4
5
6
7
8
addhook("endround","end_hook")
function end_hook(mode)
	if mode == 2 or mode == 22 or (mode%10 == 1 and mode > 1) then
		for _, id in pairs(player(0,"team2")) do
			coins[id] = coins[id] + 100
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview