Raised This Month: $ Target: $400
 0% 

Server crashes, something wrong


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 01-01-2011 , 17:44   Swap teams & scores
Reply With Quote #1

Hey, why my server crashes when plugin tries to swap teams & score...

here it is:

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

new const VERSION[] = "1.0"

const MAX_PLAYERS 32

const XTRA_OFS_PLAYERS 5
const OFFSET_TEAM 114

const TEAM_T 1
const TEAM_CT 2


new iRound;

new 
cvar_rounds;
public 
plugin_init()
{
    
register_plugin("Swap teams & score"VERSION"reinert")

    
register_logevent("Logevent_Round_End"2"1=Round_End")
    
    
cvar_rounds register_cvar("swap_rounds""6")
    
    
register_event("HLTV""event_new_round""a""1=0""2=0")
}

public 
event_new_round(){
    
iRound+=1;
    
client_print(0print_chat,"new round works")
    if(
iRound == get_pcvar_num(cvar_rounds) - 1){
    
set_task(2.5"LastRound")
    }
}

public 
LastRound(){
    new 
Players[32]
    new 
playerCountiplayer
    get_players
(PlayersplayerCount"ch")
    for (
i=0i<playerCounti++)
    
player Players[i]
    
    
client_cmd(player"stopsound")
    
client_cmd(player"spk tmreverse")
}

public 
Logevent_Round_End()
{
    
client_print(0print_chat,"round end works")
    if(
iRound == get_pcvar_num(cvar_rounds)){
    
set_task(0.1"SwapScore")
    
set_task(0.1"SwapPlayers")
    
iRound 0;
    }
}

public 
SwapScore()
{
    static 
scoreCTscoreT;
    
scoreT cs_get_team_score_:CS_TEAM_T );
    
scoreCT cs_get_team_score_:CS_TEAM_CT );
    
    
cs_set_team_score(_:CS_TEAM_TscoreCT)
    
cs_set_team_score(_:CS_TEAM_CTscoreT)
}
    

public 
SwapPlayers()
{
    new 
iPlayers[MAX_PLAYERS], iNumid
    get_players
(iPlayersiNum"h")
    for(new 
ii<iNumi++)
    {
        
id iPlayers[i]
        switch( 
get_pdata_int(idOFFSET_TEAMXTRA_OFS_PLAYERS) )
        {
            case 
TEAM_T:
            {
                
set_pdata_int(idOFFSET_TEAMTEAM_CTXTRA_OFS_PLAYERS)
            }
            case 
TEAM_CT:
            {
                
set_pdata_int(idOFFSET_TEAMTEAM_TXTRA_OFS_PLAYERS)
            }
        }
    
set_task(2.5,"Swaped")
    }
}

public 
Swaped(){
    new 
Players[32]
    new 
playerCountiplayer
    get_players
(PlayersplayerCount"ch")
    for (
i=0i<playerCounti++)
    
player Players[i]
    
    
client_cmd(player"stopsound")
    
client_cmd(player"spk tmreversed")

No errors in logs, I'm also using this CsHack module. (it's working -
[ 8] CS Hack RUN - cshack_amxx.dll v1.00 pl2 ANY ANY ).. Is there another, better way to swap teams and their scores ???

Last edited by reinert; 01-01-2011 at 17:48.
reinert is offline
Reply


Thread Tools
Display Modes

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:03.


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