25.12.2009, 12:23
yes. you are first looping through the boxslots. i presume there are more than 1, so the check for being online is done twice.
due to the fact the player is checked twice, and his boxslot will match twice too, you only need to swap the first 2 conditions checked:
first "is player connected?", then "check all boxslots":
the variable "i" is assigned to IsPlayerConnected(i) and used in the loop (BOXSLOTS), so the "i" will be resetted to 0 anyways, and should cause a warning like:
warning 219: local variable "i" shadows a variable at a preceding level
...try another variable like "playerid" in IsPlayerConnected()...
maybe this helps you fixing the problem too...
you also could print out a small string just for repeat-checking at each loopstart...
due to the fact the player is checked twice, and his boxslot will match twice too, you only need to swap the first 2 conditions checked:
first "is player connected?", then "check all boxslots":
Код:
if(IsPlayerConnected(i)) { for(new i = 0;i < BOXSLOTS; i++) { if(PlayersInBoxRing[i] == 0) { PlayersInBoxRing[i]++; format(string,sizeof(string),"%s joined the Boxring!",name); SendClientMessageToAll(COLOR_GREEN,string); return 1; } else if(PlayersInBoxRing[i] == 1) { PlayersInBoxRing[i]++; format(string,sizeof(string),"%s joined the Boxring as Challenger!",name); SendClientMessageToAll(COLOR_GREEN,string); return 1; } else if(PlayersInBoxRing[i] <= 2) { SendClientMessage(playerid,COLOR_RED,"Their are already 2 Guys Boxing!"); return 1; } } }
warning 219: local variable "i" shadows a variable at a preceding level
...try another variable like "playerid" in IsPlayerConnected()...
Код:
if(IsPlayerConnected(playerid)) {
you also could print out a small string just for repeat-checking at each loopstart...