28.05.2013, 15:03
So, my gamemode currently uses quite a few loops (as necessary) to find & use relations between arrays.
For example, I preload HomeInfo[MAX_HOMES][enum] during OnGameModeInit() from a database, and PlayerStats[MAX_PLAYERS][enum] on player's successful login. PlayerStats has an enum "charID"... HomeInfo has "ownerID".
I then loop through the HomeInfo array to find relationships:
Now I know this works, obviously, but I'm going to be using these loops fairly frequently.. Is this safe? Is it efficient? Should I be storing these relationships in some other way?
For example, I preload HomeInfo[MAX_HOMES][enum] during OnGameModeInit() from a database, and PlayerStats[MAX_PLAYERS][enum] on player's successful login. PlayerStats has an enum "charID"... HomeInfo has "ownerID".
I then loop through the HomeInfo array to find relationships:
Код:
for(new i=0;i<MAX_HOMES;i++) { if(HomeInfo[i][ownerID] == PlayerStats[playerid][charID) { DoSomething(); break; } }