SA-MP Forums Archive
for() Causing my server to stop responding - 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: for() Causing my server to stop responding (/showthread.php?tid=504962)



for() Causing my server to stop responding - NewCityRoleplay - 06.04.2014

pawn Код:
stock SetBizToPlayer(playerid, idx)
{
    new freespot;
    for(new b=0;b<MAX_PLAYERBIZ;idx++)
    {
        if(PlayerInfo[playerid][pBiz][b] < 1)
        {
            freespot = b;
        }
    }
    PlayerInfo[playerid][pBiz][freespot] = idx;
    return 1;
}
I use this in a command like /buybiz, It works for the first business slot. Then anything after that it crashes the server. The server stops responding and no commands work. Any help?

MAX_PLAYERBIZ = 3
idx = BizID Number


Re: for() Causing my server to stop responding - Konstantinos - 06.04.2014

Most likely a run time error 4: Array index out of bounds.

What's the size of pBiz in the enum? Any value higher than 3 would cause that.


Re: for() Causing my server to stop responding - Vince - 06.04.2014

You never actually increment b, resulting in an endless loop.


Re: for() Causing my server to stop responding - NewCityRoleplay - 06.04.2014

Yeah Vince's solution worked. Thank you.. I didn't even notice.