09.06.2012, 13:09
I don't remember how I did it exactly, but is was for a deathmatch map. It was something similar as this:
The goal of the script is to spawn all the players in the deathmatch, without them spawning too close to each other.
Of course, IsPlayerInRangeOfPoint could be used too, but who's says that one gets updated? But still, I'm not sure if this was actually the case. Although, I have changed the original script for this reason, I think. (The script I use nowadays isn't the same as this anymore.)
Код:
new Float: DeathmatchSpawns[][] = { {100.0, 100.0, 100.0, 100.0}, {more deathmatch spawns} }; stock SpawnPlayers() { for (new p; p != MAX_PLAYERS; p++) { new Float: pos[3]; for (new p; p != MAX_PLAYERS; p++) { new spawn = random(sizeof(DeathmatchSpawns)), bool: goodspawn; while (goodspawn == false) { new bool: someonenearby, Float: p2Pos[3]; for (new p2; p2 != MAX_PLAYERS; p2++) { GetPlayerPos(playerid, p2Pos[0], p2Pos[1], p2Pos[2]); if (InRangeOf(25.0, DeathmatchSpawns[spawn][0], DeathmatchSpawns[spawn][1], DeathmatchSpawns[spawn][2], p2Pos[0], p2Pos[1], p2Pos[2]) { someonenearby = true; } } if (someonenearby == false) {goodspawn = true;} else {spawn = random(sizeof(DeathmatchSpawns));} } SetPlayerPos(p, DeathmatchSpawns[s][0], DeathmatchSpawns[s][1], DeathmatchSpawns[s][2]); SetPlayerFacingAngle(p, DeathmatchSpawns[s][3]); SetCameraBehindPlayer(p); } } return 1; }
Of course, IsPlayerInRangeOfPoint could be used too, but who's says that one gets updated? But still, I'm not sure if this was actually the case. Although, I have changed the original script for this reason, I think. (The script I use nowadays isn't the same as this anymore.)