Raised This Month: $ Target: $400
 0% 

Switch team scores


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 04-25-2011 , 06:39   Switch team scores
Reply With Quote #1

Would someone make a plugin that switches team scores by admin command /switchscores.

PHP Code:
#include <cshack>

register_clcmd("say /switchscores""swap_scores")

public 
swap_scores()
{
    new 
scoreCT cs_get_team_score(_:CS_TEAM_CT)
    new 
scoreT cs_get_team_score(_:CS_TEAM_T)
    
    
cs_set_team_score(_:CS_TEAM_CTscoreT)
    
cs_set_team_score(_:CS_TEAM_TscoreCT)

This is not working, It crashes the server.

Also I've this code, but somewhy it makes both team scores to -1 instead of swaping them.

PHP Code:
#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define SCORE_T 0
#define SCORE_CT 1

new g_TeamScore[2];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("TeamScore""eventTeamScore""a");
    
    
register_clcmd("say /swap""switchScores")
}

public 
eventTeamScore()
{
    new 
sTeam[2];
    
read_data(1sTeam1);
    if( 
sTeam[0] == 'T' )
    {
        
g_TeamScore[SCORE_T] = read_data(2);
    }
    else
    {
        
g_TeamScore[SCORE_CT] = read_data(2);
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
switchScores()
{
    
cs_set_team_score(,g_TeamScore[SCORE_CT])
    
cs_set_team_score(,g_TeamScore[SCORE_T])
}

stock cs_set_team_score(const team , const score) {     
    new 
buffer[10];     
    
    switch(
team)
    {         
        case 
1copy(buffer "TERRORIST");
        case 
2copy(buffer "CT");
        
        default: return 
0;     
    }     
    
    
message_begin(MSG_ALL get_user_msgid("TeamScore") , {0,0,0});
    
write_string(buffer);
    
write_byte(score);
    
message_end();
    
    return 
1;


Last edited by reinert; 04-25-2011 at 06:45.
reinert is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2011 , 08:54   Re: Switch team scores
Reply With Quote #2

Are you plaining to swap players as well ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 04-25-2011 , 09:37   Re: Switch team scores
Reply With Quote #3

Yes, but it's not necessary right now, because how to swap players I already know.

Well I think I've figured out by looking at amx_teamscore plugin, but it's very complicated.

It's done with orpheu, but isn't there another way ?
reinert is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2011 , 09:44   Re: Switch team scores
Reply With Quote #4

I asked that because there is a cs function that switches teams and teams scores.

Command : amx_swap_teams
-> swap teams on next new round (better to use it at this time).

! Not tested on linux but should work fine.

Edit : Without orpheu, you can't change team scores, you can only change what players see in scoreboard so you would need to change every message sent.
Attached Files
File Type: sma Get Plugin or Get Source (swap_teams.sma - 1371 views - 1.7 KB)
File Type: zip [signatures]swap_teams.zip (6.8 KB, 722 views)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 04-25-2011 , 10:26   Re: Switch team scores
Reply With Quote #5

Oh ok, I've made it myself something like:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <orpheu>
#include <orpheu_memory>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define SCORE_T 0
#define SCORE_CT 1

#define set_mp_pdata(%1,%2)  ( OrpheuMemorySetAtAddress( g_pGameRules, %1, 1, %2 ) )
#define get_mp_pdata(%1)     ( OrpheuMemoryGetAtAddress( g_pGameRules, %1 ) )

new g_pGameRules;
new 
g_TeamScore[2];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("TeamScore""eventTeamScore""a");
    
    
register_clcmd"say /swap""ClientCommand_SetTeamScore");
}

public 
plugin_precache()
{
    
OrpheuRegisterHookOrpheuGetFunction"InstallGameRules" ), "OnInstallGameRules"OrpheuHookPost );
}

public 
OnInstallGameRules()
{
    
g_pGameRules OrpheuGetReturn();
}

public 
eventTeamScore()
{
    new 
sTeam[2];
    
read_data(1sTeam1);
    if( 
sTeam[0] == 'T' )
    {
        
g_TeamScore[SCORE_T] = read_data(2);
    }
    else
    {
        
g_TeamScore[SCORE_CT] = read_data(2);
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
ClientCommand_SetTeamScore ()
{                
    
set_mp_pdata"m_iNumCTWins"g_TeamScore[SCORE_T] );
           
    
set_mp_pdata"m_iNumTerroristWins"g_TeamScore[SCORE_CT] );
        
    
UpdateTeamScores( .notifyAllPlugins true );
}

UpdateTeamScores ( const bool:notifyAllPlugins false )
    {
        static 
OrpheuFunction:handleFuncUpdateTeamScores;

        if ( !
handleFuncUpdateTeamScores )
        {
            
handleFuncUpdateTeamScores OrpheuGetFunction"UpdateTeamScores""CHalfLifeMultiplay" )
        }

        ( 
notifyAllPlugins ) ?

            
OrpheuCallSuperhandleFuncUpdateTeamScoresg_pGameRules ) :
            
OrpheuCallhandleFuncUpdateTeamScoresg_pGameRules );
    } 
Tested and it works, but I think ur code is better anyways ? is it ?
reinert is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2011 , 10:28   Re: Switch team scores
Reply With Quote #6

If you want to swap players as well, yes.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 04-25-2011 , 10:30   Re: Switch team scores
Reply With Quote #7

Ok thanks, <3 ;D
reinert is offline
Old 05-06-2011, 09:20
reinert
This message has been deleted by reinert.
emaya93
Member
Join Date: Jun 2012
Old 01-02-2014 , 18:03   Re: Switch team scores
Reply With Quote #8

doesn't work on linux...

Code:
 12/31/2013 - 13:45:03: [ORPHEU] Function "InstallGameRules" not found  12/31/2013 - 13:45:03: [AMXX] Displaying debug trace (plugin "swap_teams.amxx")  12/31/2013 - 13:45:03: [AMXX] Run time error 10: native error (native "OrpheuGetFunction")  12/31/2013 - 13:45:03: [AMXX] [0] swap_teams.sma::plugin_precache (line 126) [AMXX] Loaded 1 admin from file Cmd_AddCommand: say already defined  12/31/2013 - 13:45:03: [ORPHEU] Function "CHalfLifeMultiplay::SwapAllPlayers" not found  12/31/2013 - 13:45:03: [AMXX] Displaying debug trace (plugin "swap_teams.amxx")  12/31/2013 - 13:45:03: [AMXX] Run time error 10: native error (native "OrpheuGetFunction")  12/31/2013 - 13:45:03: [AMXX] [0] swap_teams.sma::plugin_init (line 58)
__________________
I'm new here...

I'm not omniscient..
emaya93 is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 11-18-2015 , 00:19   Re: Switch team scores
Reply With Quote #9

Any help?


Quote:
L 11/17/2015 - 03:28:21: [ORPHEU] Invalid memory structure "m_iNumCTWins"
L 11/17/2015 - 03:28:21: [AMXX] Run time error 10 (plugin "swap_teams.amxx") (native "OrpheuMemorySetAtAddress") - debug not enabled!
L 11/17/2015 - 03:28:21: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
Debug.

Quote:
L 11/17/2015 - 0355: [ORPHEU] Invalid memory structure "m_iNumCTWins"
L 11/17/2015 - 0355: [AMXX] Displaying debug trace (plugin "swap_teams.amxx")
L 11/17/2015 - 0355: [AMXX] Run time error 10: native error (native "OrpheuMemorySetAtAddress")
L 11/17/2015 - 0355: [AMXX] [0] swap_teams.sma::ClientCommand_SetTeamScore (line 56)
Quote:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <orpheu>
#include <orpheu_memory>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define SCORE_T 0
#define SCORE_CT 1

#define set_mp_pdata(%1,%2) ( OrpheuMemorySetAtAddress( g_pGameRules, %1, 1, %2 ) )
#define get_mp_pdata(%1) ( OrpheuMemoryGetAtAddress( g_pGameRules, %1 ) )

new g_pGameRules;
new
g_TeamScore[2];

public
plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

register_event("TeamScore", "eventTeamScore", "a");

register_clcmd( "say /swap", "ClientCommand_SetTeamScore");
}

public
plugin_precache()
{
OrpheuRegisterHook( OrpheuGetFunction( "InstallGameRules" ), "OnInstallGameRules", OrpheuHookPost );
}

public
OnInstallGameRules()
{
g_pGameRules = OrpheuGetReturn();
}

public
eventTeamScore()
{
new
sTeam[2];
read_data(1, sTeam, 1);
if(
sTeam[0] == 'T' )
{
g_TeamScore[SCORE_T] = read_data(2);
}
else
{
g_TeamScore[SCORE_CT] = read_data(2);
}

return
PLUGIN_CONTINUE;
}

public
ClientCommand_SetTeamScore ()
{
set_mp_pdata( "m_iNumCTWins", g_TeamScore[SCORE_T] );

set_mp_pdata( "m_iNumTerroristWins", g_TeamScore[SCORE_CT] );

UpdateTeamScores( .notifyAllPlugins = true );
}

UpdateTeamScores ( const bool:notifyAllPlugins = false )
{
static
OrpheuFunction:handleFuncUpdateTeamScores;

if ( !
handleFuncUpdateTeamScores )
{
handleFuncUpdateTeamScores = OrpheuGetFunction( "UpdateTeamScores", "CHalfLifeMultiplay" )
}

(
notifyAllPlugins ) ?

OrpheuCallSuper( handleFuncUpdateTeamScores, g_pGameRules ) :
OrpheuCall( handleFuncUpdateTeamScores, g_pGameRules );
}
4ever16 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 02:33.


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