Raised This Month: $ Target: $400
 0% 

Game Event: TeamScore


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoldNux
Senior Member
Join Date: Mar 2018
Old 03-11-2018 , 14:02   Game Event: TeamScore
Reply With Quote #1

My friend is trying to help me build a plugin that saves the score after a reset.
We always have to keep track of the score after changing teams when playing 5 v 5.
It's not working properly right now, maybe someone could help us out.

We want the plugin to not reset the score after a restart, and that the team scores are swapped.

Thanks!


Code:
#include <amxmodx>   #define PLUGIN "keepscore" #define VERSION "1.0" #define AUTHOR "DaniwA"   new score_T,score_CT; new score_T_old,score_CT_old;   public plugin_init(){     register_plugin(PLUGIN, VERSION, AUTHOR);     register_event("TeamScore","get_teamscore","a");     register_event("HLTV", "new_round", "a", "1=0", "2=0");     register_cvar("ks_secondhalf", "0"); //0 = warmup, 1 = första halvan, 2 = andra halvan     }   public get_teamscore(){     new team[32];     read_data(1,team,31);       if(!strcmp(team,"TERRORIST"))         score_T = read_data(2);     else         score_CT = read_data(2);       if(get_cvar_num("ks_secondhalf") == 1){         score_T_old = score_T;         score_CT_old = score_CT;         }         new_round();     return PLUGIN_CONTINUE;     }   public new_round(){       if(get_cvar_num("ks_secondhalf") == 2)         set_task(0.1,"send_messages",1);       return PLUGIN_CONTINUE;     }   public send_messages(){     message_begin(MSG_ALL,get_user_msgid("TeamScore"),{0,0,0},0);     write_string("TERRORIST");     write_short(score_T+score_T_old);     message_end();       message_begin(MSG_ALL,get_user_msgid("TeamScore"),{0,0,0},0);     write_string("CT");     write_short(score_CT+score_CT_old);     message_end();     return PLUGIN_CONTINUE;     }
__________________
Try my version of de_dust2, I think it's great and you should check it out!
https://gamebanana.com/mods/83731
GoldNux is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 03-11-2018 , 14:33   Re: Game Event: TeamScore
Reply With Quote #2

Just the logic: Use an external global variable to store the score(out of your code).
Code:
new t_win, ct_win, external_data; // Right after team swap or 15 rounds have successfully passed. external_data = t_win t_win = ct_win ct_win = external_data
__________________
Relaxing is offline
GoldNux
Senior Member
Join Date: Mar 2018
Old 03-11-2018 , 15:01   Re: Game Event: TeamScore
Reply With Quote #3

Quote:
Originally Posted by Relaxing View Post
Just the logic: Use an external global variable to store the score(out of your code).
Code:
new t_win, ct_win, external_data; // Right after team swap or 15 rounds have successfully passed. external_data = t_win t_win = ct_win ct_win = external_data
I'm not a programmer, and maybe my mate will understand what you mean.
I sort of do, but I'm wondering if the rest of the team will be able to see this variable?

I also requested a plugin that lets me set the scores manually, that way I can just set the scores after resetting the round..
__________________
Try my version of de_dust2, I think it's great and you should check it out!
https://gamebanana.com/mods/83731

Last edited by GoldNux; 03-11-2018 at 15:02.
GoldNux is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 03-11-2018 , 15:39   Re: Game Event: TeamScore
Reply With Quote #4

The variable(both t_win & ct_win) will absolutely be able to for anyone since it's the team score.
__________________
Relaxing is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 03-16-2018 , 21:40   Re: Game Event: TeamScore
Reply With Quote #5

Quote:
Originally Posted by Relaxing View Post
The variable(both t_win & ct_win) will absolutely be able to for anyone since it's the team score.
something like this

PHP Code:
#define isTeam(%0)         (CS_TEAM_T <= cs_get_user_team(%0) <= CS_TEAM_CT)
#define MAX_PLAYERS    32

new CtPlacarTrPlacarRounds

public plugin_init()
{
register_event("SendAudio""EventEndRnd","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw");
}

public 
EventEndRnd()
{
    
Rounds ++
    if(
CtPlacar TrPlacar == 15)
    {
        
set_task(2.0"SwapTeams")
    }
}

public 
SwapTeams()
{
    new 
iPlayers[MAX_PLAYERS], iNum
    get_players
(iPlayersiNum)
    for(new 
iidiNum;i++)
    {
        
id iPlayers[i]
        
        if(
isTeam(id))
        {
            
cs_set_user_team(id, (cs_get_user_team(id) == CS_TEAM_T) ? CS_TEAM_CT CS_TEAM_T)
        }
    }
    if(
live..overtime..etc
    
{

        new 
iScore CtPlacar
        CtPlacar 
TrPlacar
        TrPlacar 
iScore

//it's enought for a exemple

Last edited by iceeedr; 12-22-2020 at 09:08.
iceeedr is offline
Send a message via Skype™ to iceeedr
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 15:01.


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