Raised This Month: $51 Target: $400
 12% 

[CSGO]ZHR Plugins Error .


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
2389736818
Member
Join Date: Jul 2014
Location: China
Old 10-31-2016 , 09:21   [CSGO]ZHR Plugins Error .
Reply With Quote #1

PHP Code:
new Handle:cvar_zx2_swapteam_round
new 
Handle:cvar_mp_restartgame
new 
g_round
new 
g_score_ct
new 
g_score_t
new 
bool:IsSwap
new 
g_team_side
new 
m_iScore
new 
bool:IsBlockSwitchTeam[MAXPLAYERS+1]; 
new 
count2=0

public 
Cvar_mp_restartgame(Handle:cvar, const String:oldvalue[], const String:newvalue[]) 

    if(
cvar_mp_restartgame != INVALID_HANDLE
    { 
        if(
StringToInt(newvalue) > 0
        { 
            
g_score_t 0
            
g_score_ct 0
            
g_round 0
            
IsSwap false
        } 
    } 

public 
Action:ev_player_team(Handle:event, const String:name[], bool:dontBroadcast

    
decl client
    
client GetClientOfUserId(GetEventInt(event"userid")); 
    if(
client 0
    { 
        if(
IsBlockSwitchTeam[client]) 
        { 
            
IsBlockSwitchTeam[client] = false
            return 
Plugin_Handled
        } 
    } 
    return 
Plugin_Continue

public 
Action Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast

    
g_round++; 
    if(
g_team_side == CS_TEAM_CT
    { 
        
_SetTeamScore(CS_TEAM_CT,g_score_ct); 
        
_SetTeamScore(CS_TEAM_T,g_score_t); 
    } else if(
g_team_side == CS_TEAM_T) { 
        
_SetTeamScore(CS_TEAM_T,g_score_ct); 
        
_SetTeamScore(CS_TEAM_CT,g_score_t); 
    } 

public 
ev_round_freeze_end(Handle:event, const String:name[], bool:dontBroadcast

    
decl max_round
    
max_round GetConVarInt(cvar_zx2_swapteam_round); 
    if(
max_round <= 0
    { 
        return; 
    } 
    if(
g_round >= max_round
    { 
        
count2++; 
        if (
count2 == 1
        { 
        
IsSwap true
        
PrintToChatAll("\x05[ZHR]\x01 Round %d, Teams will be swapped at the end of this round!",g_round); 
        
EmitSoundToAll("ambient/misc/brass_bell_C.wav"); 
        } 
    } else { 
        
PrintToChatAll("\x05[ZHR]\x01 Round %d",g_round); 
    } 
    
PrintCenterTextAll("[ZHR] Round %d/%d",g_round,max_round); 

public 
Action Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast

    
decl reason
    
reason GetEventInt(event"reason"); 
    
decl winner
    
winner GetEventInt(event"winner"); 
    if(
winner == 3
    { 
        if(
g_team_side == CS_TEAM_CTg_score_ct++; 
        if(
g_team_side == CS_TEAM_Tg_score_t++; 
    } else if(
winner == 2) { 
        if(
g_team_side == CS_TEAM_Tg_score_ct++; 
        if(
g_team_side == CS_TEAM_CTg_score_t++; 
    } 
    if(
g_team_side == CS_TEAM_CT
    { 
        
_SetTeamScore(CS_TEAM_CT,g_score_ct); 
        
_SetTeamScore(CS_TEAM_T,g_score_t); 
    } else if(
g_team_side == CS_TEAM_T) { 
        
_SetTeamScore(CS_TEAM_T,g_score_ct); 
        
_SetTeamScore(CS_TEAM_CT,g_score_t); 
    } 
    if(
IsSwap
    { 
        if (
count2 == 1
        { 
            
SwapTeam(); 
            
g_round 0
            
IsSwap false
            if(
g_team_side == CS_TEAM_CT
            { 
                
g_team_side CS_TEAM_T
            } else { 
                
g_team_side CS_TEAM_CT
            } 
            
PrintToChatAll("\x05[ZHR]\x01 Score Swaped"); 
        } 
    } 
    if(
reason == 16
    { 
        
g_score_t 0
        
g_score_ct 0
        
g_round 0
        
IsSwap false
    } 

stock SwapTeam() 

    
decl maxclient,i,team
    
maxclient GetMaxClients(); 
    
EmitSoundToAll("ambient/misc/brass_bell_C.wav"); 
    for(
i=1;i<=maxclient;i++) 
    { 
        if(
IsClientInGame(i)) 
        { 
            
team GetClientTeam(i); 
            if(
team == CS_TEAM_CT
            { 
                
IsBlockSwitchTeam[i] = true
                
CS_SwitchTeam(i,CS_TEAM_T); 
                if(
IsPlayerAlive(i)) 
                { 
                } 
            } else if(
team == CS_TEAM_T) { 
                
IsBlockSwitchTeam[i] = true
                
CS_SwitchTeam(i,CS_TEAM_CT); 
                if(
IsPlayerAlive(i)) 
                { 
                } 
            } 
        } 
    } 
    
PrintToChatAll("\x04[ZHR] Team Swaped"); 

public 
bool:_SetTeamScore(indexvalue

    new 
team MAXPLAYERS 1
    
team FindEntityByClassname(-1"cs_team_manager"); 
    while (
team != -1
    { 
        if (
GetEntProp(teamProp_Send"m_iTeamNum"1) == index
        { 
            
SetEntProp(teamProp_Send"m_iScore"value4); 
            
ChangeEdictState(teamm_iScore); 
            return 
true
        } 
        
team FindEntityByClassname(team"cs_team_manager"); 
    } 
    return 
false

In contrast to the previous code I removed something

PHP Code:
new Handle:cvar_zx2_swapteam_round;
new 
Handle:cvar_mp_restartgame;
new 
g_round;
new 
g_score_ct;
new 
g_score_t;
new 
bool:IsSwap;
new 
g_team_side;
new 
bool:IsBlockSwitchTeam[MAXPLAYERS+1];
new 
count2=0;

public 
Cvar_mp_restartgame(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
    if(
cvar_mp_restartgame != INVALID_HANDLE)
    {
        if(
StringToInt(newvalue) > 0)
        {
            
g_score_t 0;
            
g_score_ct 0;
            
g_round 0;
            
IsSwap false;
        }
    }
}
public 
Action:ev_player_team(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl client;
    
client GetClientOfUserId(GetEventInt(event"userid"));
    if(
client 0)
    {
        if(
IsBlockSwitchTeam[client])
        {
            
IsBlockSwitchTeam[client] = false;
            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;
}
public 
ev_round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
    
g_round++;
    if(
g_team_side == CS_TEAM_CT)
    {
        
CS_SetClientContributionScore(CS_TEAM_CT,g_score_ct);
        
CS_SetClientContributionScore(CS_TEAM_T,g_score_t);
    } else if(
g_team_side == CS_TEAM_T) {
        
CS_SetClientContributionScore(CS_TEAM_T,g_score_ct);
        
CS_SetClientContributionScore(CS_TEAM_CT,g_score_t);
    }
}
public 
ev_round_freeze_end(Handle:event, const String:name[], bool:dontBroadcast

    
decl max_round
    
max_round GetConVarInt(cvar_zx2_swapteam_round); 
    if(
max_round <= 0
    { 
        return; 
    } 
    if(
g_round >= max_round
    { 
        
count2++; 
        if (
count2 == 1
        { 
        
IsSwap true
        
PrintToChatAll("\x05[ZHR]\x01 Round %d, Teams will be swapped at the end of this round!",g_round); 
        
EmitSoundToAll("ambient/misc/brass_bell_C.wav"); 
        } 
    } else { 
        
PrintToChatAll("\x05[ZHR]\x01 Round %d",g_round); 
    } 
    
PrintCenterTextAll("[ZHR] Round %d/%d",g_round,max_round); 

public 
ev_round_end(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl reason;
    
reason GetEventInt(event"reason");
    
decl winner;
    
winner GetEventInt(event"winner");
    if(
winner == 3)
    {
        if(
g_team_side == CS_TEAM_CTg_score_ct++;
        if(
g_team_side == CS_TEAM_Tg_score_t++;
    } else if(
winner == 2) {
        if(
g_team_side == CS_TEAM_Tg_score_ct++;
        if(
g_team_side == CS_TEAM_CTg_score_t++;
    }
    if(
g_team_side == CS_TEAM_CT)
    {
        
CS_SetClientContributionScore(CS_TEAM_CT,g_score_ct);
        
CS_SetClientContributionScore(CS_TEAM_T,g_score_t);
    } else if(
g_team_side == CS_TEAM_T) {
        
CS_SetClientContributionScore(CS_TEAM_T,g_score_ct);
        
CS_SetClientContributionScore(CS_TEAM_CT,g_score_t);
    }
    if(
IsSwap)
    {
        if (
count2 == 1)
        {
            
SwapTeam();
            
g_round 0;
            
IsSwap false;
            if(
g_team_side == CS_TEAM_CT)
            {
                
g_team_side CS_TEAM_T;
            } else {
                
g_team_side CS_TEAM_CT;
            }
            
PrintToChatAll("\x05[ZHR]\x01 Score Swaped");
        }
    }
    if(
reason == 16)
    {
        
g_score_t 0;
        
g_score_ct 0;
        
g_round 0;
        
IsSwap false;
    }
}
stock SwapTeam()
{
    
decl maxclient,i,team;
    
maxclient GetMaxClients();
    
EmitSoundToAll("ambient/misc/brass_bell_C.wav");
    for(
i=1;i<=maxclient;i++)
    {
        if(
IsClientInGame(i))
        {
            
team GetClientTeam(i);
            if(
team == CS_TEAM_CT)
            {
                
IsBlockSwitchTeam[i] = true;
                
CS_SwitchTeam(i,CS_TEAM_T);
                if(
IsPlayerAlive(i))
                {
                }
            } else if(
team == CS_TEAM_T) {
                
IsBlockSwitchTeam[i] = true;
                
CS_SwitchTeam(i,CS_TEAM_CT);
                if(
IsPlayerAlive(i))
                {
                }
            }
        }
    }
    
PrintToChatAll("\x04[ZHR] Team Swaped");

But still there is an error, what should I do.
log:
L 10/31/2016 - 21:04:43: SourceMod error session started
L 10/31/2016 - 21:04:43: Info (map "de_dust2") (file "errors_20161031.log")
L 10/31/2016 - 21:04:43: [SDKTOOLS] Invalid detour address passed - Disabling detour to prevent crashes
L 10/31/2016 - 21:05:54: [SM] Exception reported: Client index 2 is not valid
L 10/31/2016 - 21:05:54: [SM] Blaming: zhr.smx
L 10/31/2016 - 21:05:54: [SM] Call stack trace:
L 10/31/2016 - 21:05:54: [SM] [0] CS_SetClientContributionScore
L 10/31/2016 - 21:05:54: [SM] [1] Line 91, zhr/swapteam.inc::ev_round_end
__________________

Last edited by 2389736818; 10-31-2016 at 09:24.
2389736818 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 18:11.


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