01.01.2011, 13:48
pawn Код:
foreach(Player, playerid) {
if(IsPlayerInForbidZone(playerid) == 1)
{
if(PlayerInfo[playerid][Class] == 10 || PlayerInfo[playerid][Class] == 11 || PlayerInfo[playerid][Class] == 12)
{
continue;
}
foreach(Player, playerid) {
if(IsPlayerInForbidZone(playerid) == 1)
{
if(PlayerInfo[playerid][Class] == 10 || PlayerInfo[playerid][Class] == 11 || PlayerInfo[playerid][Class] == 12)
{
continue;
}
for( new i = 0; i < 10; i ++ )
{
if( i < 5 ) continue;
printf( "%d", i );
}
// Prints 5, 6, 7, 8, 9
It could be some sort of problem with using it inside of a 'foreach' loop, make sure to double check the documentation regarding it.
It would also help if you showed the code that you tested it with (debugging the problem). |
foreach(Player, playerid) {
if(IsPlayerInForbidZone(playerid) == 1)
{
if(PlayerInfo[playerid][Class] == 10 || PlayerInfo[playerid][Class] == 11 || PlayerInfo[playerid][Class] == 12)
{
continue;
}
if(GetPVarInt(playerid, "ENTERED") == 0) {
SetPVarInt(playerid, "ENTERED", 1);
SetPVarInt(playerid, "LEAVE_TIME", randomEx(15, 30));
}
if(GetPVarInt(playerid, "ENTERED") == 1 && GetPVarInt(playerid, "LEAVE_TIME") > 0) {
SetPVarInt(playerid, "LEAVE_TIME", GetPVarInt(playerid, "LEAVE_TIME") -1);
format(String, sizeof(String), LoadText(playerid, "WARNING_TEXT"), GetPVarInt(playerid, "LEAVE_TIME"));
GameTextForPlayer(playerid, String, 4000, 3);
}
if(GetPVarInt(playerid, "LEAVE_TIME") == 0) {
PlayerInfo[playerid][WantedLevel] += 8;
SetPVarInt(playerid, "LEAVE_TIME", -1);
GameTextForPlayer(playerid, LoadText(playerid, "SHOOT_NOW"), 3000, 3);
}
}
}
if(PlayerInfo[playerid][Class] == 10 || PlayerInfo[playerid][Class] == 11 || PlayerInfo[playerid][Class] == 12)
Are you the only player on the server? If so, it's obviously going to stop after the first loop. Foreach only loops through the connected player IDs.
The problem persists because this line is true, making the loop to continue (which, in this case, it's at the end) pawn Код:
|