AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   RoundEnd for each player? (https://forums.alliedmods.net/showthread.php?t=83277)

Sleepwalker 01-07-2009 01:41

RoundEnd for each player?
 
I'm trying to switch scores on the team but when it do it switch it for each player and I just want to do it once. So it switches the team score 3 times if it is 3 players on the server. Why?

Code:

register_logevent("event_EndRound",2,"1=Round_End");
Code:

public event_EndRound() {
        new t, c
        for(new x=1;x<=PL_MAX;x++) {
                if(!is_user_connected(x)) continue;
                if(get_user_team(x) == 1)
                        t = 1;
                if(get_user_team(x) == 2)
                        c = 1;
        }
        if(c == 1 && t == 1) {
                timer = -1;

                format(randed,63,"");

                new WinT;
                for(new i=1; i <= PL_MAX; i++) {
                        if(is_user_alive(i) && get_user_team(i) == 1)
                                WinT = 1;
                }

                if(WinT){
                        // Do Nothing
                }else{
                        cs_switch_teams();
                        cs_set_team_score(1, teamScores[CTS]);
                        cs_set_team_score(2, teamScores[TS]);
                }
                set_task(0.5,"displayHud",TASK_DISPHUD,"",_,"a",6);
        }
}


ConnorMcLeod 01-07-2009 02:08

Re: RoundEnd for each player?
 
Code:
public event_EndRound() {     new t, c     for(new x=1;x<=PL_MAX;x++) {         if(!is_user_connected(x)) continue;         if(get_user_team(x) == 1)             t += 1;         if(get_user_team(x) == 2)             c += 1;     }


Also, use switch( get_user_team(x) ) would be better, or store the value in a variable.
Haven't time to look further in your code.

Sleepwalker 01-07-2009 02:54

Re: RoundEnd for each player?
 
The code you wrote will not work for me. If you look again you can se that I just want to check that it is a player on each team.

jim_yang 01-07-2009 03:19

Re: RoundEnd for each player?
 
nobody know your logic from your code
if you just want to know which team win the round
register event like this
Code:

register_event("SendAudio","t_win","a","2=%!MRAD_terwin")
register_event("SendAudio","ct_win","a","2=%!MRAD_ctwin")

instead of your player calculator

Sleepwalker 01-07-2009 05:18

Re: RoundEnd for each player?
 
My code is like this:
Code:

1.        Check so there is a player on each team and not just 2 players
2.        If there is a player in each team check what team is the winner
3.        If it is T team that is the winning team... do nothing
        If it is CT team that is the winning team... run:

        cs_switch_teams();
        cs_set_team_score(1, teamScores[CTS]);
        cs_set_team_score(2, teamScores[TS]);

But my problem is that
Code:

        cs_set_team_score(1, teamScores[CTS]);
        cs_set_team_score(2, teamScores[TS]);

is running for each player and not once as I want.

* EDIT *
I have tested to switch from:
Code:

register_logevent("event_EndRound",2,"1=Round_End");
to:
Code:

register_event("SendAudio", "event_EndRound",  "a",  "2&%!MRAD_terwin",  "2&%!MRAD_ctwin");
But it stoped working when I did that.
Sorry for my bad english!

Sleepwalker 01-10-2009 01:01

Re: RoundEnd for each player?
 
Someone?


All times are GMT -4. The time now is 09:05.

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