for() Causing my server to stop responding
#1

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
Reply
#2

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.
Reply
#3

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)