Problematic FOR function?
#1

Can someone explain why when this code so much as touches the OnGameModeInit, whether it be in a called public function or in the OnGameModeInit itself, it does not execute anything afterwards?

Код:
for(new i; i < SERVER_LINKCOUNT + 1; i++)
{
	new pickupid;
	sLink[i][outsidex] = Link_Outside[i][0];
	sLink[i][outsidey] = Link_Outside[i][1];
	sLink[i][outsidez] = Link_Outside[i][2];
	sLink[i][outsideid] = CreatePickup(1239,23,sLink[i][outsidex],sLink[i][outsidey],sLink[i][outsidez]);
	pickupid = sLink[i][outsideid];
	SERVER_LINKED_PICKUPS[pickupid] = i;
	sLink[i][insidex] = Link_Inside[i][0];
	sLink[i][insidey] = Link_Inside[i][1];
	sLink[i][insidez] = Link_Inside[i][2];
	sLink[i][insideid] = CreatePickup(1239,23,sLink[i][insidex],sLink[i][insidey],sLink[i][insidez]);
	pickupid = sLink[i][insideid];
	SERVER_LINKED_PICKUPS[pickupid] = i;
	sLink[i][interior] = Link_Interior[i];
	format(str, 128, "Link number %d created.",i);
	print(str);
}
Reply
#2

Anybody, Does nobody know why it is doing thing? If it can't be worked around should I place it at the end of the OnGameModeInit?
Reply
#3

Unless it needs to be there, it doesn't matter. The problem is 'i' is eventually becoming a number larger than an indexed variable's size.

ex:
pawn Код:
new LOLVariable[50];

LOLVariable[60] = 0; //reacts as 'return 0'
Reply
#4

"i" has a set amount.

determined at the beginning of the script using:

"#define SERVER_LINKCOUNT 11"

it runs until it reaches 11 and then it stops, so that can't be the problem as the indexed variable is equal to the above define as well, they are always linked.

enum SERVER_LINK_ARRAY
{
Floatutsidex,
Floatutsidey,
Floatutsidez,
outsideid,
Float:insidex,
Float:insidey,
Float:insidez,
insideid,
interior
}
new sLink[SERVER_LINKCOUNT][SERVER_LINK_ARRAY];


EDIT: All I had to do was remove the +1 from the FOR command
Reply
#5

When an index is made it counts 0 as a variable.

e.g.
new Variable[50]
makes
Variable[0] through Variable[49]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)