Forum

> > CS2D > Scripts > Reward for end
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Reward for end

16 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Reward for end

tos12345678
User Off Offline

Zitieren
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.

alt Re: Reward for end

tos12345678
User Off Offline

Zitieren
But, when i scripting with addhook endround then
Each players gains 100 coins
1× editiert, zuletzt 11.07.18 16:48:03

alt Re: Reward for end

KingShadow
User Off Offline

Zitieren
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
5× editiert, zuletzt 11.07.18 18:49:19

alt Re: Reward for end

Baloon
GAME BANNED Off Offline

Zitieren
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")

alt Re: Reward for end

KingShadow
User Off Offline

Zitieren
@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!
1× editiert, zuletzt 11.07.18 18:15:12

alt Re: Reward for end

Yates
Reviewer Off Offline

Zitieren
@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.

alt Re: Reward for end

KingShadow
User Off Offline

Zitieren
user Yates hat geschrieben
@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

alt Re: Reward for end

tos12345678
User Off Offline

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

alt Re: Reward for end

Masea
Super User Off Offline

Zitieren
user KingShadow hat geschrieben
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 hat geschrieben
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.

alt Re: Reward for end

princeofpersia
User Off Offline

Zitieren
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

alt Re: Reward for end

Cure Pikachu
User Off Offline

Zitieren
@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
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht