SA-MP Forums Archive
stock makes compiler crash - 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)
+--- Thread: stock makes compiler crash (/showthread.php?tid=369509)



stock makes compiler crash - oliver12 - 17.08.2012

Why this stock makes compiler crashing?
Код:
stock OnAutoOmanik(playerid)
{
	foreach(x, MAX_HOUSESPERPLAYER)
	{
	    if(APlayerData[playerid][Houses][x] != 0)
	    {
	    	foreach(i, 10)
	    	{
				new autoid = GetPlayerVehicleID(playerid);
	    	    if(AHouseData[x][VehicleIDs][i] == autoid)
	    	    {
	    	        return 1;
		    }
	    }
	}
	return 0;
}



Re: stock makes compiler crash - ToiletDuck - 17.08.2012

pawn Код:
stock OnAutoOmanik(playerid)
{
        foreach(x, MAX_HOUSESPERPLAYER)
    {
        if(APlayerData[playerid][Houses][x] != 0)
        {
            foreach(i, 10)
            {
                new autoid = GetPlayerVehicleID(playerid);
                if(AHouseData[x][VehicleIDs][i] == autoid)
                {
                    return 1;
            }
        }
    }
    return 0;
    }
}
try


Re: stock makes compiler crash - RedJohn - 17.08.2012

Try this boy:
pawn Код:
stock OnAutoOmanik(playerid)
{
    foreach(x, MAX_HOUSESPERPLAYER)
    {
        if(APlayerData[playerid][Houses][x] != 0)
        {
            foreach(i, 10)
            {
                new autoid = GetPlayerVehicleID(playerid);
                if(AHouseData[x][VehicleIDs][i] == autoid)
                {
                    return 1;
                }
            }
        }
    }
    return 0;
}



Re: stock makes compiler crash - oliver12 - 17.08.2012

Same result with both of them.


Re: stock makes compiler crash - Vince - 17.08.2012

I'm pretty sure the foreach statement is wrong. I've never actually used foreach so I may be wrong, but from what I've seen, the right syntax is foreach(identifier, index) e.g. foreach(Player, i). You have it the other way round.


Re: stock makes compiler crash - oliver12 - 17.08.2012

How could I forgot that !? thank you


Re: stock makes compiler crash - oliver12 - 17.08.2012

I know I forgot