06.08.2018, 09:18
I just made player spawn nearest hospital on death but doesn't work.
Full code:
Hospital coordinates:
OnPlayerSpawn:
OnPlayerDeath:
Instead of getting spawned at nearest hospital after death, i get spawned based on RandomSpawnsLosSantos coordinates.
What's wrong?
Full code:
pawn Код:
new bool:HospitalSpawn[MAX_PLAYERS];
pawn Код:
new Float:HospitalCoords[][4] =
{
{2027.4375,-1421.0703,16.9922,137.2809}, // Los Santos Hospital
{1177.9089,-1323.9611,14.0939,269.8222}, // Los Santos Hospital #2
{1579.6106,1769.0625,10.8203,90.7178}, // Las Venturas Hospital
{-321.8259,1056.7279,19.7422,316.0064}, // Fort Carson Hospital
{-1514.8807,2527.8003,55.7315,358.6234}, // El Quebrados Hospital
{-2662.0439,630.5056,14.4531,177.8114}, // San Fierro Hospital
{-2199.2495,-2311.0444,30.6250,321.2772}, // Angel Pine Hospital
{1244.1959,332.2817,19.5547,338.3063} // Montgomery Hospital
};
pawn Код:
if(HospitalSpawn[playerid])
{
HospitalSpawn[playerid] = false;
new closest, Float:distance = 99999.9;
for (new i, j = sizeof(HospitalCoords), Float:tmp_distance; i < j; i++)
{
tmp_distance = GetPlayerDistanceFromPoint(playerid, HospitalCoords[i][0], HospitalCoords[i][1], HospitalCoords[i][2]);
if (tmp_distance < distance)
{
distance = tmp_distance;
closest = i;
}
}
SetSpawnInfo(playerid, GetPlayerTeam(playerid), GetPlayerSkin(playerid), HospitalCoords[closest][0], HospitalCoords[closest][1], HospitalCoords[closest][2], HospitalCoords[closest][3], 0, 0, 0, 0, 0, 0);
}
else
{
if(gTeam[playerid] == TEAM_CIV)
{
SetPlayerTeam(playerid,0);
new rand = random(sizeof(RandomSpawnsLosSantos));
SetPlayerPos(playerid, RandomSpawnsLosSantos[rand][0],RandomSpawnsLosSantos[rand][1],RandomSpawnsLosSantos[rand][2]);
}
}
pawn Код:
HospitalSpawn[playerid] = true;
What's wrong?