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

[CSGO]ZHR Plugins Error .


Post New Thread Reply   
 
Thread Tools Display Modes
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
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-31-2016 , 13:48   Re: [CSGO]ZHR Plugins Error .
Reply With Quote #2

https://sm.alliedmods.net/new-api/cs...tributionScore
HTML Code:
int client
     Client index to set score for.
You try to give a team instend of a client ID.

Also, wrong section, I suppose.
__________________

Last edited by Arkarr; 10-31-2016 at 13:48.
Arkarr is offline
2389736818
Member
Join Date: Jul 2014
Location: China
Old 11-01-2016 , 01:01   Re: [CSGO]ZHR Plugins Error .
Reply With Quote #3

I modified but can not compile .

compile log:
funtion prototypes do not match.

PHP Code:
public ev_round_end(Handle:event, const String:name[], bool:dontBroadcastint client

    
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
    }

__________________

Last edited by 2389736818; 11-01-2016 at 01:01.
2389736818 is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 11-01-2016 , 01:55   Re: [CSGO]ZHR Plugins Error .
Reply With Quote #4

Still wrong, CS_TEAM_CT / CS_TEAM_T are team index. You want to give a client ID. Tell me what you want to do, and I'll drop the code with explanation.
__________________
Arkarr is offline
2389736818
Member
Join Date: Jul 2014
Location: China
Old 11-01-2016 , 06:36   Re: [CSGO]ZHR Plugins Error .
Reply With Quote #5

Now I add this code do not know can not be used ,But also led to a chain reaction .

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 
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"); 
}

public 
bool:CS_SetClientContributionScore(int clientint value)  
{
    new 
team MAXPLAYERS 1;  
    
team FindEntityByClassname(-1"cs_team_manager");  
    while (
team != -1)  
    {
        if (
GetEntProp(teamProp_Send"m_iTeamNum"1) == int client)  
        {
            
SetEntProp(teamProp_Send"m_iScore"int value4);  
            
ChangeEdictState(teamm_iScore);  
            return 
true;  
        }
        
team FindEntityByClassname(team"cs_team_manager");  
    }
    return 
false;  

Attached Thumbnails
Click image for larger version

Name:	compile.png
Views:	80
Size:	30.3 KB
ID:	158388   Click image for larger version

Name:	compile1.png
Views:	86
Size:	31.3 KB
ID:	158389   Click image for larger version

Name:	compile2.png
Views:	89
Size:	28.8 KB
ID:	158390   Click image for larger version

Name:	compile3.png
Views:	75
Size:	14.2 KB
ID:	158391  
__________________

Last edited by 2389736818; 11-01-2016 at 06:55.
2389736818 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 10:58.


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