Thats for spawning at the same point after death.
i created a code using GetPlayerDistanceFromPoint
Код:
enum spawn_
{
Float:s_X,
Float:s_Y,
Float:s_Z
};
new Spawns[][spawn_] = // List of spawns
{
{0.0, 0.0, 0.0},
{123.0, 456.0, 789.0},
{500.0, 500.0, 500.0}
};
stock ClosestSpawnPoint(playerid) // Get closest spawn
{
new SpawnPointid, Float:closest = GetPlayerDistanceFromPoint(playerid, Spawns[0][s_X], Spawns[0][s_Y], Spawns[0][s_Z]);
for(new i=1; i<sizeof(Spawns); i++)
{
if(GetPlayerDistanceFromPoint(playerid, Spawns[i][s_X], Spawns[i][s_Y], Spawns[i][s_Z]) < closest)
{
closest = GetPlayerDistanceFromPoint(playerid, Spawns[i][s_X], Spawns[i][s_Y], Spawns[i][s_Z]);
SpawnPointid = i;
}
}
return SpawnPointid;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SetPVarInt(playerid, "Dead", 1);
SetPVarInt(playerid, "SpawnPoint", ClosestSpawnPoint(playerid));
}
public OnPlayerSpawn(playerid)
{
if(GetPVarInt(playerid, "Dead"))
{
new sp = GetPVarInt(playerid, "SpawnPoint");
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid, Spawns[sp][s_X], Spawns[sp][s_Y], Spawns[sp][s_Z]);
SetPVarInt(playerid, "Dead", 0);
}
}
I posted this so it might be usefull for other players looking for this