Nearest Hospital Respawn
#7

I'd use sth like this:

PHP код:
enum hospital_
{
    
Float:h_X,
    
Float:h_Y,
    
Float:h_Z
};
new 
Hospitals[][hospital_] =
{
    {
0.00.00.0}, // list of hospital coords
    
{123.0456.0789.0},
    {
500.0500.0500.0}
};
stock Float:PlayerDistanceToPoint(playeridFloat:_xFloat:_yFloat:_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 
hospitalidFloat:closest PlayerDistanceToPoint(playeridHospitals[0][h_X], Hospitals[0][h_Y], Hospitals[0][h_Z];
    for(new 
i=1i<sizeof(Hospitals); i++)
    {
        if(
PlayerDistanceToPoint(playeridHospitals[i][h_X], Hospitals[i][h_Y], Hospitals[i][h_Z]) < closest)
        {
            
closest PlayerDistanceToPoint(playeridHospitals[i][h_X], Hospitals[i][h_Y], Hospitals[i][h_Z]);
            
hospitalid i;
        }
    }
    return 
hospitalid;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    
SetPVarInt(playerid"Dead"1);
    
SetPVarInt(playerid"Hospital"ClosestHospital(playerid));
}
public 
OnPlayerSpawn(playerid)
{
    if(
GetPVarInt(playerid"Dead"))
    {
        new 
hid GetPVarInt(playerid"Hospital");
        
SetPlayerInterior(playerid0);
        
SetPlayerVirtualWorld(playerid0);
        
SetPlayerPos(playeridHospitals[hid][h_X], Hospitals[hid][h_Y], Hospitals[hid][h_Z]);
        
SetPVarInt(playerid"Dead"0);
    }

Not sure if it works..
Reply


Messages In This Thread
Nearest Hospital Respawn - by Pillhead2007 - 22.08.2012, 16:17
Re: Nearest Hospital Respawn - by TaLhA XIV - 22.08.2012, 16:19
Re: Nearest Hospital Respawn - by Pillhead2007 - 22.08.2012, 18:36
Re: Nearest Hospital Respawn - by Pillhead2007 - 26.08.2012, 18:33
Re: Nearest Hospital Respawn - by fadhilkab - 26.08.2012, 18:34
Re: Nearest Hospital Respawn - by TaLhA XIV - 26.08.2012, 18:35
AW: Nearest Hospital Respawn - by w84m3 - 26.08.2012, 20:04

Forum Jump:


Users browsing this thread: 3 Guest(s)