Quote:
Originally Posted by Starfire2001
I'm attempting to make a player counter for an events I'm making. It works fine up till the end, in which I want to display the winning players name. Instead of doing that it seems to be just picking a person at random from the server and saying they win. Anyways, I'm pretty much completely new to scripting, started like 5 days ago, and I can't figure out what the problem could be. Any and all help would be appreciated.
PHP Code:
function onPlayerDies(pl){ temp.cot = -1; for (temp.pl : players) { if (temp.pl.level.name == player.level.name){ if (pl.guild == "Events Team") { continue; } cot ++; } } if (cot == 1){ this.start = 0; setTimer(1); } else { message(cot SPC "players left!"); } } function onTimeout(){ for (temp.pl: allplayers) { if (temp.pl.level.name == player.level.name){ if (pl.guild == "Events Team") { continue; } message(temp.pl.communityname SPC "wins!"); } } }
|
First of all you have "pl" as the parameter of the onPlayerDies function aswell as within the for loop, I've never really used onPlayerDies as it's a default function but if that parameter is necessary and the player object is not that of the player which just died you'd need to be using the specified param name, which in this case would be a conflict.
Message serverside within the timeout is not something that needs to be done for every single player, calling it just once should work fine, the fact that you are looping through allplayers is why it would be selecting a random player from the server, you need to be checking the normal players array from that level again assuming that the player object is not valid, albeit it's not really necessary due to the previous point.