AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Server crashes, something wrong (https://forums.alliedmods.net/showthread.php?t=146828)

reinert 01-01-2011 17:44

Swap teams & scores
 
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 ???


All times are GMT -4. The time now is 02:03.

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