PDA

View Full Version : Return in a for()-loop


XCarBOn
21/07/2013, 10:01 AM
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

Misiur
21/07/2013, 10:03 AM
and continue checking

//change
return 0;
//to
continue;

XCarBOn
21/07/2013, 10:06 AM
So it skips slot 0 and continue with slot 1..?

Misiur
21/07/2013, 10:12 AM
1. Try the code
2. http://wiki.sa-mp.com/wiki/Control_Structures#continue

XCarBOn
21/07/2013, 10:14 AM
Tested it, works fine. Thanks!