English ID of MVP of the round

3 replies
Goto Page
To the start Previous 1 Next To the start
16.04.18 06:19:15 pm
Up
mrc
User
Offline Off
How do I get the ID of the MVP of the round? I've tried this but this doesn't work...

Code:
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
CS2D Brasil @ www.CS2D.com.br

Admin/mod comment:

Moved to the right section. /Starkkz
16.04.18 06:23:05 pm
Up
Cure Pikachu
User
Offline Off
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
IMG:https://i.imgur.com/5UWPaft.png
IMG:https://i.imgur.com/xpsyQRX.png
16.04.18 06:36:01 pm
Up
Talented Doge
User
Offline Off
A simple alternate workaround

Code:
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
16.04.18 06:49:37 pm
Up
Cure Pikachu
User
Offline Off
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)
Code:
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
IMG:https://i.imgur.com/5UWPaft.png
IMG:https://i.imgur.com/xpsyQRX.png
To the start Previous 1 Next To the start