AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Save score of each team (https://forums.alliedmods.net/showthread.php?t=307096)

iceeedr 04-26-2018 12:09

Save score of each team
 
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?

Relaxing 04-26-2018 12:46

Re: Save score of each team
 
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

CrAzY MaN 04-26-2018 12:47

Re: Save score of each team
 
New file system is better.

iceeedr 04-26-2018 12:51

Re: Save score of each team
 
Quote:

Originally Posted by Relaxing (Post 2589542)
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?

Relaxing 04-26-2018 14:06

Re: Save score of each team
 
What's the purpose of this? I mean what you tryna reach?

Bugsy 04-26-2018 17:32

Re: Save score of each team
 
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.

iceeedr 04-26-2018 17:44

Re: Save score of each team
 
Quote:

Originally Posted by Bugsy (Post 2589597)
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 04-26-2018 20:33

Re: Save score of each team
 
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 04-27-2018 12:19

Re: Save score of each team
 
Quote:

Originally Posted by iceeedr (Post 2589613)
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
    
}



Bugsy 04-27-2018 20:54

Re: Save score of each team
 
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();
    }




All times are GMT -4. The time now is 04:32.

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