SRL Archive - Discussions and Debates

Avioding the LogInPlayer; infinite loop.


Wanted

2007-10-13 17:03:14

Pretty self-explanatory, LogInPlayer contains an infinite loop that I believe is there to prevent beginner scripters from making fatal mistakes, unfortunately, in return, your script will repeat on a wait forever unless you find a way to only call it if you know for sure atleast one of your players is still active, so I created this simple piece of code to add to your main loop

if (LoggedIn) then LogOut;
PlayerChecks := 0;
while ((not (Players[CurrentPlayer].Active)) and (PlayerChecks <= GetArrayLength(Players))) do
begin
CurrentPlayer := CurrentPlayer + 1;
if (CurrentPlayer >= GetArrayLength(Players)) then CurrentPlayer := 0;
PlayerChecks := PlayerChecks + 1;
end;
if (PlayerChecks >= GetArrayLength(Players)) then Break else LogInPlayer;

Enjoy,

-IceFire.