Whats the problem ? - 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: Whats the problem ? (
/showthread.php?tid=76073)
Whats the problem ? -
Peter_Corneile - 03.05.2009
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/kill", true) == 0)
{
SetPlayerHealth(playerid, 0);
}
if(strcmp(cmdtext, "/help", true) == 0)
{
SendClientMessage(playerid, COLOR_RED, "** HELP **");
SendClientMessage(playerid, COLOR_RED, "** COMMANDS ** /help /kill** "); //More help here Florynho
}
{
new string[256];
GetPlayerName(playerid, string, 24);
format(string, 256, "%s Need Help!!!", string);
for (new i; i != GetMaxPlayers(); i ++)
if (GetPlayerTeam(i) == GetPlayerTeam(playerid))
SendClientMessage(i, GetPlayerColor(playerid), string);
return 0;
}
return 0;
}
Whats wrong with this code , i get these warnings
Код:
D:\samp02Xserver.win32\gamemodes\new.pwn(19) : warning 217: loose indentation
D:\samp02Xserver.win32\gamemodes\new.pwn(29) : warning 225: unreachable code
D:\samp02Xserver.win32\gamemodes\new.pwn(29) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
3 Warnings.
Re: Whats the problem ? -
Bearfist - 03.05.2009
Loose Intendation meanse something like this->
(for Example
Код:
if(strcmp("/bla",cmdtext,true) == 0)
{
blablabla
return 1;
}
->This would give the warning "loose intendation"<-
It says that function is not on the same line with other functions..don't know how to say it but
look ^^
Код:
if(strcmp("/bla",cmdtext,true) == 0)
{
blablabla
return 1;
}
Here not ^^
And your unreachable code is this->
Код:
new string[256];
GetPlayerName(playerid, string, 24);
format(string, 256, "%s Need Help!!!", string);
for (new i; i != GetMaxPlayers(); i ++)
if (GetPlayerTeam(i) == GetPlayerTeam(playerid))
SendClientMessage(i, GetPlayerColor(playerid), string);
return 0; //Here must be return 1; because return 0; below would never be reached
}
return 0;
}
So take this->
Код:
new string[256];
GetPlayerName(playerid, string, 24);
format(string, 256, "%s Need Help!!!", string);
for (new i; i != GetMaxPlayers(); i ++)
if (GetPlayerTeam(i) == GetPlayerTeam(playerid))
SendClientMessage(i, GetPlayerColor(playerid), string);
return 1;
}
return 0;
}
...In fact now you would have NO warnings
Bearfist
Re: Whats the problem ? -
Peter_Corneile - 03.05.2009
Oh , so spaces do matter

Thanks bro
Re: Whats the problem ? -
Bearfist - 04.05.2009
No problem