Forum

> > CS2D > Scripts > ID of MVP of the round
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch ID of MVP of the round

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

verschoben ID of MVP of the round

mrc
User Off Offline

Zitieren
How do I get the ID of the MVP of the round? I've tried this but this doesn't work...

1
2
3
4
5
6
addhook("endround","mvp")
function mvp(id)
if player(id,"mvp") then
parse("sv_msg2 "..id.." test@C")
end
end

Admin/Mod Kommentar

Moved to the right section. /Starkkz

alt Re: ID of MVP of the round

Cure Pikachu
User Off Offline

Zitieren
According to cs2d lua cmd player,
player(id,"mvp")
is how many times a player is called MVP. And cs2d lua hook endround's parameter is for how the round ended.
I am thinking, what if you make two tables containing the MVP count of all the players (updating both of them when someone joins/leaves, and on roundstart), update one of the tables when the round ends, and then compare the values between them?
1× editiert, zuletzt 16.04.18 18:34:03

alt Re: ID of MVP of the round

Talented Doge
User Off Offline

Zitieren
A simple alternate workaround

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
mvp = {}
for i = 1, game("sv_maxplayers") do mvp[i] = 0 end

addhook("endround", "endr")
addhook("startround", "st")

function st()
	for i = 1, player(0, "tableliving") do
		mvp[player(0, "tableliving")[i]] = player(player(0, "tableliving")[i], "mvp")
	end
end

function endr()
	for i = 1, player(0, "tableliving") do
		if player(player(0, "tableliving")[i], "mvp") == mvp[player(0, "tableliving")[i]] + 1 then
			msg("TEST DONE")
		end
	end
end

alt Re: ID of MVP of the round

Cure Pikachu
User Off Offline

Zitieren
user Talented Doge: I think dead players can get MVP if they planted the bomb and it blows up or have more kills than their living teammates, or something like that.
Also fixed some issues with yours. (Your line 2, 8 and 14 will throw errors)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mvp = {}
for i = 1, tonumber(game("sv_maxplayers")) do mvp[i] = 0 end

recentmvp = 0

addhook("endround","endr")
addhook("startround","st")

function st()
	for _, i in ipairs(player(0,"table")) do
		mvp[i] = player(i,"mvp")
	end
end

function endr()
	for _, i in ipairs(player(0,"table")) do
		if player(i,"mvp") > mvp[i] then
			recentmvp = i
			msg("Current MVP is "..player(recentmvp,"name"))
			break
		end
	end
end
EDIT: Why was this thread moved into the German section? It's in English.
5× editiert, zuletzt 20.07.18 05:08:29
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht