Raised This Month: $ Target: $400
 0% 

Solved Save score of each team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-26-2018 , 12:09   Save score of each team
Reply With Quote #1

Good afternoon, how could I save the points of each team at a specific time, then use the saved values, would it be better to use an array or fvault?

Last edited by iceeedr; 04-28-2018 at 12:34.
iceeedr is offline
Send a message via Skype™ to iceeedr
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 04-26-2018 , 12:46   Re: Save score of each team
Reply With Quote #2

You can just use a simple file and save it there.
It can also get better statistics. Like map's name, current message log time & players, results and even count all winings of both teams and retrieve a specific win ratio & the percentage of wins.
Personally I would go for the magical fopen
__________________
Relaxing is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-26-2018 , 12:51   Re: Save score of each team
Reply With Quote #3

Quote:
Originally Posted by Relaxing View Post
You can just use a simple file and save it there.
It can also get better statistics. Like map's name, current message log time & players, results and even count all winings of both teams and retrieve a specific win ratio & the percentage of wins.
Personally I would go for the magical fopen
My problem is that I need to save something like this:
g_ScoreTeamCt (and a value)
g_ScoreTeamTr (and a value)

to later be able to use the "global", how would I do this with fopen? or with nfvault? Could you give me a small example?
iceeedr is offline
Send a message via Skype™ to iceeedr
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 04-26-2018 , 12:47   Re: Save score of each team
Reply With Quote #4

New file system is better.
__________________
CrAzY MaN is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 04-26-2018 , 14:06   Re: Save score of each team
Reply With Quote #5

What's the purpose of this? I mean what you tryna reach?
__________________
Relaxing is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-26-2018 , 17:32   Re: Save score of each team
Reply With Quote #6

If I understand correctly, you have 2 global arrays which each hold player values, one array for each team. You want to save this on map change/shutdown or something and restore the values?

There are many options, I'd personally save the array data to a binary file or use nvault array. This is based on what I know, if there other things going on then SQL may be better.
__________________
Bugsy is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-26-2018 , 17:44   Re: Save score of each team
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
If I understand correctly, you have 2 global arrays which each hold player values, one array for each team. You want to save this on map change/shutdown or something and restore the values?

There are many options, I'd personally save the array data to a binary file or use nvault array. This is based on what I know, if there other things going on then SQL may be better.
Well, at the moment I have nothing, the score I need to save is not that of the teamscore itself but rather the one of the HUD that I created that every EVENT TR WIN and EVENT CT Win sets ++ in globals, at a certain point of the game , a "battle" of knives begins where hud gets 0x0 and later ++ with the winning team, it is before that time of the battle that I want to save the score Time ct = 7 time tr = 8 for example, end of the battle I use the global hud score and continue from where I was.
iceeedr is offline
Send a message via Skype™ to iceeedr
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-26-2018 , 20:33   Re: Save score of each team
Reply With Quote #8

If there is any way to "count" how many times the event is called already help, since I can set the global == called times.

sorry for bump.
iceeedr is offline
Send a message via Skype™ to iceeedr
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-27-2018 , 12:19   Re: Save score of each team
Reply With Quote #9

Quote:
Originally Posted by iceeedr View Post
If there is any way to "count" how many times the event is called already help, since I can set the global == called times.

sorry for bump.
Tried this...but :/

PHP Code:
public EventTeamScore()
{
    if(
TPlacar CPlacar == 4)
    {
        
formatex(szKeycharsmax(szKey), "data_score"
        
formatex(ScoreTcharsmax(ScoreT), "%d"TPlacar)
        
formatex(ScoreCcharsmax(ScoreC), "%d"CPlacar)
        
nfv_set_data(ScoreTeamsszKeyTPlacarCPlacar)
    }
}

public 
TrWins() 
{
    
TPlacar++
    if(
TPlacar == && CPlacar == 0)
    {
        new 
g_load_c1[25], g_load_c2[25]
        
formatex(szKeycharsmax(szKey), "data_score"
        
        if(!
nfv_get_data(ScoreTeamsszKeyCPlacarTPlacar)) return; 
        
parse(g_load_c1charsmax(g_load_c1), g_load_c2charsmax(g_load_c2))
                
        
CPlacar str_to_num(g_load_c1)
        
TPlacar str_to_num(g_load_c2)    
//blablabla
    
}

iceeedr is offline
Send a message via Skype™ to iceeedr
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-27-2018 , 20:54   Re: Save score of each team
Reply With Quote #10

If I understand correctly you do not need to store the scores in a file since you only temporarily need to store them eg. not between maps/shut down/different day etc. This code is basically taking the team scoring out of the servers hands and overriding the scoreboard with variable values. If you want to actually set team scores you can use orpheu or something.

This will use the scoreboard as normal for gameplay. When you want to start a knife battle use the /start chat command. The team scores will reset to 0:0 and will keep score accordingly for each team. When done with the knife battle, use the /stop command. Scores will go back to what they were before the knife battle started. Additional conditions can be added based on the scores of each team.

Map start, T=0 CT=0
Regular play results in T=3 CT=6
Knife battle start, T=0 CT=0
Knife battle results in T=6 CT =2
Knife battle end, scores go back to T=3 CT=6

PHP Code:
#include <amxmodx>
#include <cstrike>

new const Version[] = "0.1";

new 
g_iRegularScoresCsTeams ];
new 
g_iKnifeBattleScoresCsTeams ];
new 
bool:g_bInKnifeBattle;
new 
g_MsgTeamScore;

public 
plugin_init() 
{
    
register_plugin"Knife Battle Scoring" Version "bugsy" );
    
    
register_message( ( g_MsgTeamScore get_user_msgid"TeamScore" ) ) , "TeamScoreMessage" );

    
register_clcmd"say /start" "StartKnifeBattle" );
    
register_clcmd"say /stop" "StopKnifeBattle" );
}

public 
TeamScoreMessage()
{
    static 
iPrevTScore iPrevCTScore;
    new 
szTeam] , iScore;
    
    
get_msg_arg_stringszTeam charsmaxszTeam ) );
    
iScore get_msg_arg_int);
    
    switch ( 
szTeam] )
    {
        case 
'T':
        {
            if ( 
g_bInKnifeBattle == true )
            {
                if ( 
iScore iPrevTScore )
                    
set_msg_arg_intARG_SHORT , ++g_iKnifeBattleScoresCS_TEAM_T ] );
                    
                
iPrevTScore iScore;
            }
            else
            {
                
g_iRegularScoresCS_TEAM_T ] = iScore g_iKnifeBattleScoresCS_TEAM_T ];
                
set_msg_arg_intARG_SHORT g_iRegularScoresCS_TEAM_T ] );
            }
        }
        case 
'C':
        {
            if ( 
g_bInKnifeBattle == true )
            {
                if ( 
iScore iPrevCTScore )
                    
set_msg_arg_intARG_SHORT , ++g_iKnifeBattleScoresCS_TEAM_CT ] );
                
                
iPrevCTScore iScore;
            }
            else
            {
                
g_iRegularScoresCS_TEAM_CT ] = iScore g_iKnifeBattleScoresCS_TEAM_CT ];
                
set_msg_arg_intARG_SHORT g_iRegularScoresCS_TEAM_CT ] );
            }    
        }
    }
}    
    
public 
StartKnifeBattle()
{
    
client_printprint_chat "* Knife battle started" );
    
    
g_bInKnifeBattle true;
    
    
g_iKnifeBattleScoresCS_TEAM_T ] = 0;
    
g_iKnifeBattleScoresCS_TEAM_CT ] = 0;
    
    
cs_set_team_scoreCS_TEAM_T );
    
cs_set_team_scoreCS_TEAM_CT );
}

public 
StopKnifeBattle()
{
    
client_printprint_chat "* Knife battle ended" );
    
    
g_bInKnifeBattle false;
    
    
cs_set_team_scoreCS_TEAM_T g_iRegularScoresCS_TEAM_T ] );
    
cs_set_team_scoreCS_TEAM_CT g_iRegularScoresCS_TEAM_CT ] );
}

cs_set_team_scoreCsTeams:cstTeam iScore )
{     
    if ( 
CS_TEAM_T <= cstTeam <= CS_TEAM_CT )
    {
        
message_beginMSG_ALL g_MsgTeamScore , {0,0,0} );
        
write_stringcstTeam == CS_TEAM_T "TERRORIST" "CT" );
        
write_shortiScore );
        
message_end();
    }

__________________

Last edited by Bugsy; 04-27-2018 at 21:44.
Bugsy 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 04:32.


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