Well that break at the end of your for loop should be removed. Breaks break out of for and while loops and jump to the end of the for loop. So with your script, you're only going through that loop for player.
I'm not sure what you're trying to do with the array though, the array isn't used anywhere after you initialize it and give it two elements.
array = ;
array[array.size] = self.clientid = 0;
array[array.size] = self.clientid = 1;
I don't know whether you can or cannot do this with CoD's scripting language, but you have two declaration statements on the same lines (array[array.size] =
0;). If it is supported though, who is self
in this scope and why are you setting the same self
's clientid to 0, then immediately afterwards to 1?
You also shouldn't be trying to print like this. That function doesn't have support to be called on a player in CoD2 AFAIK.
player iprintlnbold("Give Item");
This is for CoD4, it's probably supported in CoD2, but you should use ClientPrint(player, message)
You also don't need to do this, you can just use player[i
] instead of player for the rest of the loop and it will behave the same.
player = players[i];
But lastly, I don't see anything generating random numbers for players. I don't even see a random number generator being used in your function there. I'm not entirely sure what you're trying to do though, I wouldn't rely on random numbers to distinguish players between each other if you'd be using that id to print something to their screen.
If you want to print "Give Item" to their screen after they give or are given an item, you should print it in your script soon after the actual action is being done so you can reference the player who was given or gave an item and print it to their screen without any random numbers or looping involved.