I know in C# you can get exception messages which occur when you try to change the contents of a list, while iterating through each member of the list.
Its something like - Cannot change contents of list while inside it or something or other...
However, I was wondering, does a similar issue exist with Changing the contents of a player list, while cycling though them?
eg
I made modifications to my local copy of nwnx_funcs to use the BootPCWithMessage function, allowing for me to boot players with a customized message. (from the tlk file)
Ok, that works, however, I want to impliment it in my reboot system for the server, so instead of booting the players 3 seconds before the boot occurs, we boot them with a non-invasive message.
Whats nicer, a message that says 'You were booted from the server' or one that says
'Farewell, and may you die well' etc....
Anyhow...
I was wondering, does the following work?
object oPC =GetFirstPC();
while(oPC != OBJECT_INVALID)
{
BootPC(oPC); //Note - this is where my customized function goes.
oPC = GetNextPC();
}
The issue I seem to have had with this, is that yes, the system did boot me, the first player in the server, however, it did not boot the person after me in the server. (was 2 of us on testing it)
Im wondering if the reason it failed, was because I left, and player 2, suddenly became player 1, and the loop tried to get the 'Next' person, which of course, didnt exist, because the next player, would have been player 2 still.
Im thinking that possible ways around this, would be to assign the boot command, to the players themselves, after a time delay.
Eg -
DelayCommand(0.10,AssignCommand(oPC,BootPCWithMessage()));
Has anyone else had to contend with iterating through the player list, and kicking players at the same time?