[solved] Warnings.
#1

Hello, I have a problem with /getid.
I almost get overloaded of warnings and I don't understand them.
The code:

pawn Код:
if(strcmp(cmd, "/getid", true) == 0)
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /getid [playername]");
new found, string[128], playername[MAX_PLAYER_NAME];
giveplayerid = ReturnUser(tmp);
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid,red, "Invalid Player ID.");
{
for(new i=0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, playername, MAX_PLAYER_NAME);
            new namelen = strlen(playername);
            new bool:searched=false;
        for(new pos=0; pos <= namelen; pos++)
            {
                if(searched != true)
                {
                if(strfind(playername,tmp,true) == pos)
                    {
                found++;
                        format(string,sizeof(string),"%d. %s (ID %d)",found,playername,i);
                        SendClientMessage(playerid, orange ,string);
                        searched = true;
                    }
                }
            }
        }
    }
    if(found == 0) SendClientMessage(playerid, red, "No players have this in their nick");
    return 1;
}
The warnings:
Код:
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(311) : warning 217: loose indentation
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(328) : warning 217: loose indentation
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(332) : warning 225: unreachable code
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(341) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(524) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(536) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(548) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(607) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(632) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(648) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(674) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nel\Desktop\Mijn spullen\GTA Games\Server test gta\filterscripts\Test.pwn(697) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


12 Warnings.
The unreachable code is:
pawn Код:
if(strcmp(cmdtext, "/lowrider", true) == 0) {
That command is bugged with the /getid command.
Can someone help me? Thanks.
Reply
#2

Local variable "string" has the same name as the global variable. Change the name and indent your code.
Reply
#3

I really don't understand it, what do I need to do? what name?
I'm stuck on that command like almost 2 days :/
Reply
#4

Try this:
pawn Код:
if(strcmp(cmd, "/getid", true) == 0)
{
  tmp = strtok(cmdtext, idx);
  if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /getid [playername]");
  new found, string_var[128], playername[MAX_PLAYER_NAME];
  giveplayerid = ReturnUser(tmp);
  if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid,red, "Invalid Player ID.");
  for(new i=0; i <= MAX_PLAYERS; i++)
  {
    if(IsPlayerConnected(i))
    {
      GetPlayerName(i, playername, MAX_PLAYER_NAME);
      new namelen = strlen(playername);
      new bool:searched = false;
      for(new pos = 0; pos <= namelen; pos++)
      {
        if(searched != true)
        {
          if(strfind(playername, tmp, true) == pos)
          {
            found++;
            format(string_var, sizeof(string_var), "%d. %s (ID %d)", found, playername, i);
            SendClientMessage(playerid, orange , string_var);
            searched = true;
          }
        }
      }
    }
  }
  if(found == 0) SendClientMessage(playerid, red, "No players have this in their nick");
  return 1;
}
Reply
#5

Teted it on my own only but...

THANKS!!! It works ))))))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)