Jump to content

[HELP] Check which team won the round


NickMBR

Recommended Posts

I'm trying to create a map that adjust itself based on the number of victories of each team. (CSGO SDK)

 

For this I need to run a vscript file at every round checking which team won.

I tried to use the logic_eventlistener using the event "round_end" and running a vscript file with no sucess.

It works with a event that happen more often, like "bullet impact" but  not with round_end.

 

Is there any way I can check the team than won at the end of each round ?

Edited by NickMBR
Link to comment
Share on other sites

I read/replied to your question on Facepunch; if you would be so kind as to explain what gamemode and such you have in mind, then I can probably write the Vscript needed for you. A simple snippet won't be helpful if I have no idea how you plan on ending rounds.

 

Thanks,

 

What I want to do is simple, I want to check which team won the round. The gamemode is custom, so it can't run on events like bomb_defused or bomb_exploded (same for hostage/vip/gg)

 

For example, if CT won the round then it increments a var "CTWinnings", when it reachs certain value it starts to modify the map via entfire and propspawn functions.

 

I don't want to force a round to end, what I want is simple to check which team won.

 

I'd tried to use the events like round_end and the logic_eventlistener but it don't work. Only works with other game events when the round is active.

Edited by NickMBR
Link to comment
Share on other sites

As I said, it's pretty simple, round ends when the all players of one of the teams die. I don't know yet if I'll make them respawn, but let's say they spawn only once.

 

More detailed, at the end of each round, check which team won, if it's the CT, then run a function called CTWon() incrementing a count var to make changes in the future. Same thing with the TR's using a function TRWon() also incrementing/decrementing as they won or lose.

 

This functions will then be called when they reach a certain value in the count vars, making the map changes for the next round. Using for example func_brushes, wall_toggles, EntFire, EntSpawn, PropSpawn, etc.

 

For example, the CT's won 3 consecutives rounds, incrementing a value of 1 each, the count var will have 3, when the 3 is compared in the Vscript, it will them make changes to the map. What happens if they lose ? Decrement a value of one. Same for the Tr's.

 

I can run functions with the logic_eventlistener but not the one that I need, that is the "round_end" one.

 

L4D2 has a OnGameEvent_Event_x function, not implemented in CSGO tho.

 

Hope you understand.

Link to comment
Share on other sites

One of the options that comes to mind is to have a script constantly check for the presence of a CT/T on the map; as soon as the result is 0 for either one of them, that means the opposite team would still have a member left.

 

For example; 

while (Entities.FindByModel(variable, "models/player/tm_phoenix.mdl") != null) {
  printl("Terrorists are still alive");
}

If that returns null, then all the terrorists should be dead; in which the CT's have won the round.

 

I'm not sure if going by models alone is doing the trick though, dead bodies could share the shame model and that would cause issues. Another way is to check for player team ID's and health, and go by that.

 

All in all this feels a bit too dirty, I was pretty sure the eventlistener should do the trick. I'll do some testing when I get home to see what is causing the issue.

 

Edit: Another entity-based option would be to have a trigger_multiple over your entire map with a teamfilter, and have it trigger a script event as soon as nobody from that team is touching it anymore (meaning they're dead). 

 

Edit2 (Solution): Was able to do a small test during my lunch break, it seems to work fine after I killed the last bot outside of warmup.

Firing: (game_playerdie)
Firing: (game_playerkill)
(22.92) output: (NULL,NULL) -> (round_end_script,RunScriptCode,0.0)(RoundEnded())
+++++Bot Keith with Max Difficulty 1 will become Bot Chad with Max Difficulty 2
+++++Bot Ron with Max Difficulty 1 will become Bot Joe with Max Difficulty 2
+++++Bot Ian with Max Difficulty 1 will become Bot Xavier with Max Difficulty 2
Achievements disabled: cheats turned on in this app session.
Achievements disabled, ignoring achievement progress for SILENT_WIN
(22.94) input <NULL>: round_end_script.RunScriptCode(RoundEnded())
======================ROUND ENDED==========================

The ==ROUND ENDED== is the Vscript outputting a line after the logic_eventlistener has been triggered by round_end.

 

Attached the VMF and .NUT files for the heck of it, you'll notice I haven't done anything strange. 

round_end.zip

Edited by Spherix
Link to comment
Share on other sites

Well, the eventlistener just runs the round_end when the team filter is "don't care", it don't fire when the filter is team(orange) or (blue).

 

I did almost the same thing you did in this test map, the difference is that I was using the team filter.

 

I know that the round_end event returns 3 vars:

 

(byte) Winner Team

(byte) Reason

(string) Round End Message

 

Is there any way I can read the logic_eventlistener inside the Vscript and get this vars ?

 

BTW, the trigger_multiple with the filter_activator_team for both teams can do the trick for a while, as it takes only 4 entities and the rest the vscript will handle.

 

Thank you !

Edited by NickMBR
Link to comment
Share on other sites

Managed to do some small tests and it seems to be either broken or just not parsing the team ID's at all. The game event is always round_end. I noticed a round_officially_ended as well (which fires a splitsecond before the round is actually restarted), but a logic_eventlistener didn't even pick those up.

 

What you could do after the generic round_end is detected, is do a count of the amount of players per team left. That should be done quick enough for the script to figure out which team should be awarded points as it has or hasn't got any players left.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Mapcore Supporters

    Funds go towards hosting and license costs, Discord server boosts, and more. If you'd like to donate, check out our Patreon announcement.

×
×
  • Create New...