Spawn at nearest hospital script not working.
#6

Try this method.
pawn Код:
// TOP of the script
new RespawnLocation[MAX_PLAYERS];
Place this under OnPlayerSpawn
pawn Код:
if(RespawnLocation[playerid] == 1)
    {
        SetPlayerPos(playerid, 1177.3391,-1324.2300,14.0658);
        SetPlayerFacingAngle(playerid, 90);
        SetCameraBehindPlayer(playerid);
        print("hos 1 is closer");
    } else {
        SetPlayerPos(playerid, 2034.1670,-1406.0623,17.2181);
        SetPlayerFacingAngle(playerid, 125);
        SetCameraBehindPlayer(playerid);
        print("hos 0 is closer");
    }

pawn Код:
stock RespawnToHospital(playerid)
{
    new Float:hos[2];
    hos[0] = GetPlayerDistanceFromPoint(playerid, 2034.1670, -1406.0623, 17.2181);
    hos[1] = GetPlayerDistanceFromPoint(playerid, 1177.3391, -1324.2300, 14.0658);
    if (hos[0]<= hos[1])
    {
        RespawnLocation[playerid] = 0;
    }
    else
    {
        RespawnLocation[playerid] = 1;
    }
    return 1;
}
NOTE: since RespawnLocation isnt defined on OnPlayerConnect, the player will spawn in the second defined hospital, you might want to fix this.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)