Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Very Simple Optimize Max Looping
#1
I just figured this out just then lol but im pretty sure this should work...

*currently
[code]
public const buffer = 3

do while z
Reply
#2
Well, it should be like this:

Code:
For i = 1 to MAX_PLAYERS
If Trim(Player(i).Name) = vbNullString then
  ' Next i kinda thing
Else
  HIGH_PLAYER_INDEX = i
End if
Next i
Im pretty sure that would work to the easiest part, but there are several things like this around. And I dont like this way, the MAX_ values aint that high anyway.
Reply
#3
Lol no the whole point of this was to remove the High_Index crap and all the other codes that tries to find high_index which is pointless because it wastes memory anyway.

this just exits the procedure once theres no players left and requires no extra procedures.

And high index wont work unless no one has logged out since logging in

actually it should be this

Code:
for i = 1 to max_players
    if player(index).name  vbnullstring and z < 3 then
         z = z + 1
    //procedure goes here
   else
         z = 0
   exit for
next i

that would give room for error if there are up to 3 indexs above the first cleared index that are cleared and havent been yet filled (which would probably never happen but you never know Tongue)
Reply
#4
Thats one messy code. You messed everything up in it.
Reply
#5
lol sorry *fixed

actually thanks for making me realise the error that alot has made in optimizing max_looping,

that if a player is cleared it will ruin the whole procedure until someone else fills its place, which gave me the idea of the 3 index buffer.
Reply
#6
Code:
for i = 1 to max_players
    if player(index).name  vbnullstring and z < 3 then
         z = z + 1
    //procedure goes here
   else
         z = 0
   exit for
next i
Is not yet fixed =/
Reply
#7
lol how not?
Reply
#8
You have a exit for, so it will only run once I =1. And there are no End if.
Reply
#9
*fixed

Lol no "exit for" only executes on the else after the buffer

Code:
for i = 1 to max_players
    if player(index).name  vbnullstring and z < 3 then
         z = z + 1
    //procedure goes here
   else
         z = 0
   exit for
   end if
next i
Reply
#10
But there was no end if before... therefore it ran each time and it exited the loop.
Reply
#11
lol thanks

I remake lol its late and im really tired from soccer no wonder theres so many mistakes

[code]
do while z
Reply
#12
Code:
player(index).name

should be:

Code:
player(i).name

Still I dont understand what you are trying to do with it.
Reply
#13
basically if there is a slot with no information it is a slot with no player.

afterwards if this is found three more times then it assumes the end and exits the loop thus saving time and RAM because it exited before getting to max_players.

the 3 player buffer is there in case up to three players have left without anyone filling the slots and they are in the middle of the index range.
Reply
#14
Sorry to bring up an old topic, but if you had 24 people online, and the first 4 log out without anyone logging in, you're screwed.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)