View Single Post
404UserNotFound
BANNED
Join Date: Dec 2011
Old 03-15-2013 , 18:48   Re: Alongub, does this look correct to you? (TF2 Event question)
Reply With Quote #6

So I just ran a test compile to make sure everything I've done so far doesn't cause any issues, and to make sure I've not made any typos.

I got everything fixed up except for this one tricky little S.O.B. of an error that I can't fix.

In the code below, I've gotten 3 errors about this: "Local variable "client" shadows a variable at a preceding level". I've marked them with comments. I have no clue how to fix this and I've been googling around now for awhile and could not find any results.
PHP Code:
public Event_CapturedPoint(Handle:event, const String:name[], bool:dontBroadcast)
{    
    if (
g_bIsCreditsActive && g_bIsCreditsEnabled)
    {
        new 
client GetEventInt(event"player");
        new 
team GetEventInt(event"team");
        new 
String:teamname[MAX_LINE_WIDTH];
        
GetTeamName(teamteamnamesizeof(teamname));
        new 
accountIds[MaxClients];
        new 
count 0;
        new 
credits_player GetConVarInt(Credits_CapturePointPlayer);
        new 
credits_team GetConVarInt(Credits_CapturePointTeam);
        new 
displaymsg GetConVarInt(Credits_DisplayMessages);
        
        if (
credits_team 1)
        {
            for (new 
client 1client <= MaxClientsclient++) // Foreshadows here.
            
{
                if (
GetClientTeam(client) == team && IsValidClient(client))
                {
                    
accountIds[count] = Store_GetClientAccountID(client);
                    
count++;
                }
            }
            
Store_GiveCreditsToUsers(accountIdscountcredits_team);
            
            if (
displaymsg == 1)
            {
                
PrintToChat(team"%s%t"STORE_PREFIX"Capture Point Team Bonus"teamnamecredits_teamg_strCurrencyName);
            }
        }

        if (
credits_player 1)
        {
            
count 0;
            
decl String:cappers[MAXPLAYERS+1];
            if (
GetEventString(event"cappers"cappersMAXPLAYERS) > 0)
            {
                new 
len strlen(cappers);
                for(new 
0leni++)
                {
                    new 
client cappers{i}; // Foreshadows here.
                
                    
if (IsValidClient(client))
                    {
                        
accountIds[count] = Store_GetClientAccountID(client);
                        
count++;
                    }
                }
                
Store_GiveCreditsToUsers(accountIdscountcredits_player);
                
                if (
displaymsg == 1)
                {
                    
PrintToChat(client"%s%t"STORE_PREFIX"Capture Point Player"credits_playerg_strCurrencyName);
                }
            }
        }
    }
}


public 
Event_CapturedFlag(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (
g_bIsCreditsActive && g_bIsCreditsEnabled)
    {
        new 
client GetEventInt(event"player");
        new 
carrier GetEventInt(event"carrier");
        new 
team GetEventInt(event"team");
        new 
carrierid GetClientOfUserId(carrier);
        new 
String:carriername[MAX_LINE_WIDTH];
        new 
String:teamname[MAX_LINE_WIDTH];
        
GetClientName(carrieridcarriernamesizeof(carriername));
        
GetTeamName(teamteamnamesizeof(teamname));

        new 
count 0;
        new 
accountIds[MaxClients];
        
        new 
credits_grabbed GetConVarInt(Credits_FlagGrabbed);
        new 
credits_defended GetConVarInt(Credits_FlagDefended);
        new 
credits_player GetConVarInt(Credits_FlagCapturedPlayer);
        new 
credits_team GetConVarInt(Credits_FlagCapturedTeam);
        new 
displaymsg GetConVarInt(Credits_DisplayMessages);
        new 
displaynames GetConVarInt(Credits_DisplayNames);
        
        switch(
GetEventInt(event"eventtype"))
        {
            case 
1:
            {
                if (
credits_grabbed 1)
                {
                    if (
IsValidClient(client))
                    {
                        
Store_GiveCredits(Store_GetClientAccountID(client), credits_grabbed);
                        
                        if (
displaymsg == 1)
                        {
                            
PrintToChat(client"%s%t"STORE_PREFIX"Flag Grabbed"credits_grabbedg_strCurrencyName);
                        }
                    }
                }
            }
            case 
2:
            {
                if (
credits_player 1)
                {
                    
Store_GiveCredits(Store_GetClientAccountID(client), credits_player);
                    
                    if (
displaymsg == 1)
                    {
                        
PrintToChat(client"%s%t"STORE_PREFIX"Flag Captured Player"credits_playerg_strCurrencyName);
                    }
                }
                
                if (
credits_team 1)
                {
                    for (new 
client 1client <= MaxClientsclient++) // Foreshadows here.
                    
{
                        if (
GetClientTeam(client) == team && IsValidClient(client))
                        {
                            
accountIds[count] = Store_GetClientAccountID(client);
                            
count++;
                        }
                    }
                    
Store_GiveCreditsToUsers(accountIdscountGetConVarInt(Credits_CapturePointTeam));
                    
                    if (
displaymsg == 1)
                    {
                        
PrintToChat(team"%s%t"STORE_PREFIX"Flag Captured Team Bonus"teamnamecredits_teamg_strCurrencyName);
                    }
                }
            }
            case 
3:
            {
                if (
credits_defended 1)
                {
                    
Store_GiveCredits(Store_GetClientAccountID(client), credits_defended);
                    
                    if (
displaymsg == 1)
                    {
                        if (
displaynames == 1)
                        {
                            
PrintToChat(client"%s%t"STORE_PREFIX"Flag Defended Named"credits_grabbedg_strCurrencyNamecarriername);
                        }
                        else
                        {
                            
PrintToChat(client"%s%t"STORE_PREFIX"Flag Defended"credits_grabbedg_strCurrencyName);
                        }
                    }
                }
            }
        }
    }
    return;

404UserNotFound is offline