[solved] Warnings. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [solved] Warnings. (
/showthread.php?tid=97594)
[solved] Warnings. -
speedruntrainer - 15.09.2009
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.
Re: Weird warnings that fucks up some other commands: -
Correlli - 15.09.2009
Local variable "string" has the same name as the global variable. Change the name and indent your code.
Re: Weird warnings that fucks up some other commands: -
speedruntrainer - 15.09.2009
I really don't understand it, what do I need to do? what name?
I'm stuck on that command like almost 2 days :/
Re: Weird warnings that fucks up some other commands: -
Correlli - 15.09.2009
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;
}
Re: Weird warnings that fucks up some other commands: -
speedruntrainer - 15.09.2009
Teted it on my own only but...
THANKS!!! It works
))))))