Forum

> > CS2D > Scripts > ID of MVP of the round
Forums overviewCS2D overview Scripts overviewLog in to reply

English ID of MVP of the round

3 replies
To the start Previous 1 Next To the start

moved ID of MVP of the round

mrc
User Off Offline

Quote
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 comment

Moved to the right section. /Starkkz

old Re: ID of MVP of the round

Cure Pikachu
User Off Offline

Quote
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?
edited 1×, last 16.04.18 06:34:03 pm

old Re: ID of MVP of the round

Talented Doge
User Off Offline

Quote
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

old Re: ID of MVP of the round

Cure Pikachu
User Off Offline

Quote
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.
edited 5×, last 20.07.18 05:08:29 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview