2 Warnings
#1

Код:
warning 219: local variable "count" shadows a variable at a preceding level
warning 219: local variable "count" shadows a variable at a preceding level
pawn Код:
count,

public CheckBunnyHopping(playerid)
{
    new animlib[32];
    new animname[32];
    GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
    if(strcmp(oldanim[playerid],animname,true) != 0)
    {
        strcat(PlayerSequence[playerid],oldanim[playerid],100);
        count++;
        if(count >= 3 && GetPVarInt(playerid,"HasSended") == 0)
        {
            if(strfind(PlayerSequence[playerid],"JUMP_LAUNCH",true) != -1
            && strfind(PlayerSequence[playerid],"JUMP_LAND",true) != -1
            && strfind(PlayerSequence[playerid],"JUMP_GLIDE",true) != -1)
            {
                new string[80];
                count=0;
                format(PlayerSequence[playerid],1,"");
                #if MODE == 0
                format(string,80,"[WARNING] %s are doing Bunny Hopping!",GetNick(playerid));
                for(new i=0; i<MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i) && IsPlayerAdmin(i))
                    {
                        SendClientMessage(i,COLOR_WHITE,string);
                    }
                }
                #else
                if(GetPVarInt(playerid,"Warnings") == MAX_WARNINGS)
                {
                    format(string,80,"[WARNING] %s has kicked for doing Bunny Hopping!",GetNick(playerid));
                    SendClientMessageToAll(COLOR_WHITE,string);
                    Kick(playerid);
                    return 1;
                }
                #endif
                SendClientMessage(playerid,COLOR_WHITE,"You're Bunny Hopping, stop or you will be kicked.");
                SetPVarInt(playerid,"HasSended",1);
                SetPVarInt(playerid,"Warnings",GetPVarInt(playerid,"Warnings")+1);
                SetTimerEx("ResetPlayer",5000,false,"d",playerid);
            }
            format(PlayerSequence[playerid],1,"");
            count=0;
        }
    }
    format(oldanim[playerid],32,"%s",animname);
    return 1;
}
Can anyone tell me how to get rid of those warnings?
Reply
#2

You made a global variable named "count" while you also made a local variable with the same name.

And why is "count" placed outside of the command? That makes no sense.
Reply
#3

Quote:
Originally Posted by milanosie
Посмотреть сообщение
You made a global variable named "count" while you also made a local variable with the same name.

And why is "count" placed outside of the command? That makes no sense.
Huh outside of the command?
Reply
#4

yes on top of the script you posted
pawn Код:
count,
This forum requires that you wait 120 seconds between posts. Please try again in 31 seconds.
Reply
#5

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
yes on top of the script you posted
pawn Код:
count,
This forum requires that you wait 120 seconds between posts. Please try again in 31 seconds.
This is what it gives me when I remove
pawn Код:
count,
Код:
error 017: undefined symbol "count"
warning 215: expression has no effect
error 017: undefined symbol "count"
error 017: undefined symbol "count"
warning 215: expression has no effect
error 017: undefined symbol "count"
warning 215: expression has no effect
Reply
#6

Show us the code. It's pretty self explanatory, define the variable count. Not as a global variable, but where it is needed.
Reply
#7

Well let me try,
The system does not know what "count" is, so we'v got to tell it what "count" is.
Lets add new count; INSIDE the command,
Now the script is like "aaaah, I now know count! Lets use it!".

AKA:

pawn Код:
public CheckBunnyHopping(playerid)
{
    new count=0;
    new animlib[32];
    new animname[32];
    GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
    if(strcmp(oldanim[playerid],animname,true) != 0)
    {
        strcat(PlayerSequence[playerid],oldanim[playerid],100);
        count++;
        if(count >= 3 && GetPVarInt(playerid,"HasSended") == 0)
        {
            if(strfind(PlayerSequence[playerid],"JUMP_LAUNCH",true) != -1
            && strfind(PlayerSequence[playerid],"JUMP_LAND",true) != -1
            && strfind(PlayerSequence[playerid],"JUMP_GLIDE",true) != -1)
            {
                new string[80];
                count=0;
                format(PlayerSequence[playerid],1,"");
                #if MODE == 0
                format(string,80,"[WARNING] %s are doing Bunny Hopping!",GetNick(playerid));
                for(new i=0; i<MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i) && IsPlayerAdmin(i))
                    {
                        SendClientMessage(i,COLOR_WHITE,string);
                    }
                }
                #else
                if(GetPVarInt(playerid,"Warnings") == MAX_WARNINGS)
                {
                    format(string,80,"[WARNING] %s has kicked for doing Bunny Hopping!",GetNick(playerid));
                    SendClientMessageToAll(COLOR_WHITE,string);
                    Kick(playerid);
                    return 1;
                }
                #endif
                SendClientMessage(playerid,COLOR_WHITE,"You're Bunny Hopping, stop or you will be kicked.");
                SetPVarInt(playerid,"HasSended",1);
                SetPVarInt(playerid,"Warnings",GetPVarInt(playerid,"Warnings")+1);
                SetTimerEx("ResetPlayer",5000,false,"d",playerid);
            }
            format(PlayerSequence[playerid],1,"");
            count=0;
        }
    }
    format(oldanim[playerid],32,"%s",animname);
    return 1;
}
Reply
#8

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Show us the code. It's pretty self explanatory, define the variable count. Not as a global variable, but where it is needed.
Here you go all of the code for it.

pawn Код:
#define MODE 1
#define MAX_WARNINGS 3

new oldanim[MAX_PLAYERS][32],
PlayerSequence[MAX_PLAYERS][100],
count,
pTimer[MAX_PLAYERS];

forward CheckBunnyHopping(playerid);
forward ResetPlayer(playerid);

public OnGameModetInit()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            pTimer[i]=SetTimerEx("CheckBunnyHopping",100,true,"d",i);
        }  
    }  
    return 1;
}  
       
public OnPlayerConnect(playerid)
{
    pTimer[playerid]=SetTimerEx("CheckBunnyHopping",100,true,"d",playerid);
    return 1;
}  

public OnPlayerDisconnect(playerid)
{
    KillTimer(pTimer[playerid]);
    return 1;
}
       
public CheckBunnyHopping(playerid)
{  
    new animlib[32];
    new animname[32];        
    GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);        
    if(strcmp(oldanim[playerid],animname,true) != 0)
    {                      
        strcat(PlayerSequence[playerid],oldanim[playerid],100);
        count++;           
        if(count >= 3 && GetPVarInt(playerid,"HasSended") == 0)
        {              
            if(strfind(PlayerSequence[playerid],"JUMP_LAUNCH",true) != -1
            && strfind(PlayerSequence[playerid],"JUMP_LAND",true) != -1
            && strfind(PlayerSequence[playerid],"JUMP_GLIDE",true) != -1)
            {                  
                new string[80];
                count=0;
                format(PlayerSequence[playerid],1,"");     
                #if MODE == 0
                format(string,80,"[WARNING] %s are doing Bunny Hopping!",GetNick(playerid));
                for(new i=0; i<MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i) && IsPlayerAdmin(i))
                    {
                        SendClientMessage(i,COLOR_WHITE,string);
                    }
                }          
                #else
                if(GetPVarInt(playerid,"Warnings") == MAX_WARNINGS)
                {
                    format(string,80,"[WARNING] %s has kicked for doing Bunny Hopping!",GetNick(playerid));
                    SendClientMessageToAll(COLOR_WHITE,string);
                    Kick(playerid);
                    return 1;
                }              
                #endif
                SendClientMessage(playerid,COLOR_WHITE,"You're Bunny Hopping, stop or you will be kicked.");
                SetPVarInt(playerid,"HasSended",1);
                SetPVarInt(playerid,"Warnings",GetPVarInt(playerid,"Warnings")+1);
                SetTimerEx("ResetPlayer",5000,false,"d",playerid);
            }
            format(PlayerSequence[playerid],1,"");
            count=0;
        }  
    }  
    format(oldanim[playerid],32,"%s",animname);
    return 1;
}

public ResetPlayer(playerid) return SetPVarInt(playerid,"HasSended",0);
   
GetNick(playerid) {
new N[MAX_PLAYER_NAME];
GetPlayerName(playerid, N, sizeof N);
return N;
}
Reply
#9

Quote:
Originally Posted by milanosie
Посмотреть сообщение
Well let me try,
The system does not know what "count" is, so we'v got to tell it what "count" is.
Lets add new count; INSIDE the command,
Now the script is like "aaaah, I now know count! Lets use it!".

AKA:

pawn Код:
public CheckBunnyHopping(playerid)
{
    new count=0;
    new animlib[32];
    new animname[32];
    GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
    if(strcmp(oldanim[playerid],animname,true) != 0)
    {
        strcat(PlayerSequence[playerid],oldanim[playerid],100);
        count++;
        if(count >= 3 && GetPVarInt(playerid,"HasSended") == 0)
        {
            if(strfind(PlayerSequence[playerid],"JUMP_LAUNCH",true) != -1
            && strfind(PlayerSequence[playerid],"JUMP_LAND",true) != -1
            && strfind(PlayerSequence[playerid],"JUMP_GLIDE",true) != -1)
            {
                new string[80];
                count=0;
                format(PlayerSequence[playerid],1,"");
                #if MODE == 0
                format(string,80,"[WARNING] %s are doing Bunny Hopping!",GetNick(playerid));
                for(new i=0; i<MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i) && IsPlayerAdmin(i))
                    {
                        SendClientMessage(i,COLOR_WHITE,string);
                    }
                }
                #else
                if(GetPVarInt(playerid,"Warnings") == MAX_WARNINGS)
                {
                    format(string,80,"[WARNING] %s has kicked for doing Bunny Hopping!",GetNick(playerid));
                    SendClientMessageToAll(COLOR_WHITE,string);
                    Kick(playerid);
                    return 1;
                }
                #endif
                SendClientMessage(playerid,COLOR_WHITE,"You're Bunny Hopping, stop or you will be kicked.");
                SetPVarInt(playerid,"HasSended",1);
                SetPVarInt(playerid,"Warnings",GetPVarInt(playerid,"Warnings")+1);
                SetTimerEx("ResetPlayer",5000,false,"d",playerid);
            }
            format(PlayerSequence[playerid],1,"");
            count=0;
        }
    }
    format(oldanim[playerid],32,"%s",animname);
    return 1;
}
Ok and now I get this error lol

pawn Код:
error 017: undefined symbol "GetNick"
Reply
#10

Quote:
Originally Posted by kujox222
Посмотреть сообщение
Ok and now I get this error lol

pawn Код:
error 017: undefined symbol "GetNick"
Ow lets see,

lets do the exact same thing but now for GetNick?
Ow what a great idea!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)