Return in a for()-loop
#1

Following question:

I've made a serversided anti-weapon hack. Sometimes it's kinda buggy, because it detects player, who have no guns. So I've tried to skip players without guns in the weapon-check for the specific slot (Like Player1 has in slot 0 no guns -> The check skips this slot and continue checking for slot 1, and so on..).

Код:
public ACSUpdate(playerid)
{
	if(GetPVarInt(playerid, "Spawned") == 1)
	{
		for(new slot; slot < 11; slot++)
		{
			GetPlayerWeaponData(playerid, slot, WeaponCheck[playerid][slot], WeaponAmmoCheck[playerid][slot]);
			if(WeaponCheck[playerid][slot] == 0 && WeaponAmmoCheck[playerid][slot] == 0) return 0; // Here is the problem..
			if(Weapon[playerid][slot] != WeaponCheck[playerid][slot] || WeaponAmmo[playerid][slot] - WeaponAmmoCheck[playerid][slot] < 0 || WeaponAmmoCheck[playerid][slot] < 0)
			{
				ACSKick(playerid, "Waffen/Ammo Hack");
			}
		}
	}
	return 1;
}
How can I return to the for()-loop without stopping the whole function?


Thanks for help
Reply
#2

Quote:
Originally Posted by XCarBOn
Посмотреть сообщение
and continue checking
pawn Код:
//change
return 0;
//to
continue;
Reply
#3

So it skips slot 0 and continue with slot 1..?
Reply
#4

1. Try the code
2. https://sampwiki.blast.hk/wiki/Control_Structures#continue
Reply
#5

Tested it, works fine. Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)