Raised This Month: $ Target: $400
 0% 

Switch team scores


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 11:04.


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