new dead[MAX_PLAYERS]; Top Of Script public OnPlayerConnect(playerid) { dead[playerid] = 0; ///Player Map Icons/// //Police Stations // SetPlayerMapIcon(playerid, 1, 1555.5007, -1675.7805, 16.1953, 30, 0, MAPICON_LOCAL);//Los Santos PD HQ SetPlayerMapIcon(playerid, 2, -2161.3547, -2384.7849, 30.8939, 30, 0, MAPICON_LOCAL);//AngelPine Sheriff PD HQ SetPlayerMapIcon(playerid, 3, 2290.1460, 2432.0879, 10.8203, 30, 0, MAPICON_LOCAL);//Las Venturas PD HQ 3LVLS PARKING LOT SetPlayerMapIcon(playerid, 4, -1388.7845, 2638.2061, 55.9844, 30, 0, MAPICON_LOCAL);//El Quedbrados Sheriff PD HQ SetPlayerMapIcon(playerid, 5, -217.8340, 979.1722, 19.5040, 30, 0, MAPICON_LOCAL);//Fort Carson Sheriff PD HQ SetPlayerMapIcon(playerid, 6, -1605.7604, 710.2723, 13.8672, 30, 0, MAPICON_LOCAL);//San Fierro Downtown PD HQ SetPlayerMapIcon(playerid, 7, 626.9676, -571.4230, 17.9207, 30, 0, MAPICON_LOCAL);//Dillimore PD HQ // Fire Stations // SetPlayerMapIcon(playerid, 8, -2026.9122, 67.5129, 28.6916, 20, 0, MAPICON_LOCAL);//San Fierro Fire Department SetPlayerMapIcon(playerid, 9, 1761.6390, 2081.5706, 10.8203, 20, 0, MAPICON_LOCAL);//Las Venturas Fire Department // Hospitals // SetPlayerMapIcon(playerid, 10, 1604.6643, 1815.2538, 10.8203, 22, 0, MAPICON_LOCAL);//Las Venturas Hospital SetPlayerMapIcon(playerid, 11, -1513.4323, 2518.9666, 56.0703, 22, 0, MAPICON_LOCAL);//El Quebrados Medical Centre SetPlayerMapIcon(playerid, 12, 2034.3083, -1401.6720, 17.2961, 22, 0, MAPICON_LOCAL);//County General Los Santos Hospital SetPlayerMapIcon(playerid, 13, 1172.0804, -1325.2925, 15.4073, 22, 0, MAPICON_LOCAL);//All Saints General Hospital SetPlayerMapIcon(playerid, 14, -319.7292, 1048.2355, 20.3403, 22, 0, MAPICON_LOCAL);//Fort Carson Medical Center SetPlayerMapIcon(playerid, 15, -2655.0598, 640.1436, 14.4545, 22, 0, MAPICON_LOCAL);//San Fierro Medical Centrum SetPlayerMapIcon(playerid, 16, -2203.9302, -2309.3950, 31.3750, 22, 0,MAPICON_LOCAL);//Angel Pine Medical Center return true; } public OnPlayerSpawn(playerid) { if(dead[playerid] == 1) { IsPlayerInRangeOfPoint(playerid,20000.0,1604.6643, 1815.2538,10.8203); SetPlayerPos(playerid,1604.6643,1815.2538,10.8203) ; //Las Venturas Hospital IsPlayerInRangeOfPoint(playerid,20000.0,-1513.4323,2518.9666,56.0703); SetPlayerPos(playerid,-1513.4323,2518.9666,56.0703);//El Quebrados Medical Centre } else { SetPlayerPos(playerid,1958.3783, 1343.1572, 15.3746); //Spawn1 return 1; } return 1; } public OnPlayerDeath(playerid, killerid, reason) { dead[playerid] = 1; return 1; } |
enum hospital_
{
Float:h_X,
Float:h_Y,
Float:h_Z
};
new Hospitals[][hospital_] =
{
{0.0, 0.0, 0.0}, // list of hospital coords
{123.0, 456.0, 789.0},
{500.0, 500.0, 500.0}
};
stock Float:PlayerDistanceToPoint(playerid, Float:_x, Float:_y, Float:_z)
{
new Float:Coo[3];
GetPlayerPos(playerid,Coo[0],Coo[1],Coo[2]);
return floatsqroot(((Coo[0] - _x) * (Coo[0] - _x)) + ((Coo[1] - _y) * (Coo[1] - _y)) + ((Coo[2] - _z) * (Coo[2] - _z)));
}
stock ClosestHospital(playerid)
{
new hospitalid, Float:closest = PlayerDistanceToPoint(playerid, Hospitals[0][h_X], Hospitals[0][h_Y], Hospitals[0][h_Z];
for(new i=1; i<sizeof(Hospitals); i++)
{
if(PlayerDistanceToPoint(playerid, Hospitals[i][h_X], Hospitals[i][h_Y], Hospitals[i][h_Z]) < closest)
{
closest = PlayerDistanceToPoint(playerid, Hospitals[i][h_X], Hospitals[i][h_Y], Hospitals[i][h_Z]);
hospitalid = i;
}
}
return hospitalid;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SetPVarInt(playerid, "Dead", 1);
SetPVarInt(playerid, "Hospital", ClosestHospital(playerid));
}
public OnPlayerSpawn(playerid)
{
if(GetPVarInt(playerid, "Dead"))
{
new hid = GetPVarInt(playerid, "Hospital");
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid, Hospitals[hid][h_X], Hospitals[hid][h_Y], Hospitals[hid][h_Z]);
SetPVarInt(playerid, "Dead", 0);
}
}