23.01.2016, 13:23
Quote:
If I could give negative rep for that, I certainly would.
To determine the closest hospital you will have to maintain a list (array) of their locations. PHP код:
Next create a function that determines the closest hospital to the player; PHP код:
PHP код:
|
PHP код:
new Float:gHospitalLocations[][4] = {
{x, y, z, a},
{x, y, z, a},
{x, y, z, a}
}
GetClosestHospital(playerid)
{
new closest = -1;
for(new i, Float:minDist = Float:0x7F800000; i < sizeof(gHospitalLocations); i++)
{
new Float:currentDist = GetPlayerDistanceFromPoint(playerid, gHospitalLocations[i][0], gHospitalLocations[i][1], gHospitalLocations[i][2]);
if(currentDist < minDist)
{
minDist = currentDist;
closest = i;
}
}
return closest;
}
public OnPlayerDeath(playerid, killerid, reason)
{
new
h_id = GetClosestHospital(playerid);
new
Float:x = gHospitalLocations[h_id][0],
Float:y = gHospitalLocations[h_id][1],
Float:z = gHospitalLocations[h_id][2],
Float:a = gHospitalLocations[h_id][3];
SetSpawnInfo(playerid, ..., x, y, z, a, ...);
return 1;
}
Код:
C:\Users\Omar Masri\Desktop\xTorMz Freeroam\gamemodes\xTorMzFreeroam.pwn(1231) : error 017: undefined symbol "x" C:\Users\Omar Masri\Desktop\xTorMz Freeroam\gamemodes\xTorMzFreeroam.pwn(1263) : error 029: invalid expression, assumed zero C:\Users\Omar Masri\Desktop\xTorMz Freeroam\gamemodes\xTorMzFreeroam.pwn(2262) : error 021: symbol already defined: "OnPlayerDeath" C:\Users\Omar Masri\Desktop\xTorMz Freeroam\gamemodes\xTorMzFreeroam.pwn(8752) : warning 203: symbol is never used: "" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 3 Errors.