Raised This Month: $ Target: $400
 0% 

[TF2] Fire teamplay_round_win event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
floube
SourceMod Donor
Join Date: Jan 2013
Location: Austria
Old 09-13-2013 , 09:25   [TF2] Fire teamplay_round_win event
Reply With Quote #1

Heyo,

I am trying to fire a teamplay_round_win for the BLU team, but somehow the player does not notice anything like he should. (See the attached files, that's how it should look like)

It may depend on the map, which has one capture point. (BLU team can't reach it, only RED can)

That's my code:
PHP Code:
new Handle:hNewEvent CreateEvent("teamplay_round_win"true);
SetEventInt(hNewEvent"team"3);
SetEventInt(hNewEvent"winreason"0);
SetEventInt(hNewEvent"flagcaplimit"0);
SetEventInt(hNewEvent"full_round"1);
SetEventFloat(hNewEvent"round_time"1.0);
SetEventInt(hNewEvent"losing_team_num_caps"1);
SetEventInt(hNewEvent"was_sudden_death"0);

FireEvent(hNewEventfalse); 
Attached Thumbnails
Click image for larger version

Name:	2013-09-13_00001.jpg
Views:	234
Size:	29.2 KB
ID:	125749  
floube is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-13-2013 , 09:51   Re: [TF2] Fire teamplay_round_win event
Reply With Quote #2

Events are just notifications of something that already happened.

If you want to actually end the round, you need to do one of these two things:

  • Call a team's game_round_win's RoundWin method.
  • Call a team_control_point_master's SetWinner method. It takes a team number (2 = RED, 3 = BLU).
Generally, you'll want to use game_round_win if one exists for that team. Having said that, modes that use game_round_win usually only have one if they need to do something special on win, such as a multi-stage map resetting back to stage one when RED wins.

Something like this...

PHP Code:
stock FindEntityByClassname2(startEnt, const String:classname[])
{
    
/* If startEnt isn't valid shifting it back to the nearest valid one */
    
while (startEnt > -&& !IsValidEntity(startEnt)) startEnt--;
    return 
FindEntityByClassname(startEntclassname);
}

stock RoundWin(TFTeam:team)
{
    new 
ent = -1;
    if (
team != TFTeam_Unassigned && team != TFTeam_Spectator)
    {
        while ((
ent FindEntityByClassname2(ent"game_round_win")) != -1)
        {
            if (!
IsValidEntity(ent))
            {
                continue;
            }
            new 
roundTeam GetEntProp(entProp_Data"m_iTeamNum");
            if (
_:team == roundTeam)
            {
                
AcceptEntityInput(ent"RoundWin");
                return;
            }
        }
    }
    
    
// Since we didn't return yet, we didn't find a game_round_win for that team.
    
ent FindEntityByClassname2(ent"team_control_point_master");
    
    if (
ent == -|| !IsValidEntity(ent))
    {
        
// No team_control_point_master either... lets create one.
        
ent CreateEntityByName("team_control_point_master");
        
DispatchKeyValue(ent"targetname""master_control_point");
        
DispatchKeyValue(ent"StartDisabled""0");
        
DispatchSpawn(ent);
    }
    
    
SetVariantInt(_:team);
    
AcceptEntityInput(ent"SetWinner");

Note: I haven't tested this. Except for the team_control_point_master creation and win triggering, which is used in Prop Hunt.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-13-2013 at 10:14.
Powerlord is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 09-14-2013 , 07:04   Re: [TF2] Fire teamplay_round_win event
Reply With Quote #3

Chck how I do it in my freeze tag plugin. If i remember correctly, creating a tcpm and firing a win will crash multistage maps if the last round winner is red. An alternatice is to either create another entity (possibky win) or just fire a stalemate for multistage maps.

I forgot what i did.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
floube
SourceMod Donor
Join Date: Jan 2013
Location: Austria
Old 09-15-2013 , 07:02   Re: [TF2] Fire teamplay_round_win event
Reply With Quote #4

Powerlord's version worked fine, for now.

Thanks.
floube is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode