Player spawn
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
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 код:
new Float:gHospitalLocations[][4] = {
    {
xyza},
    {
xyza},
    {
xyza}
}; 
Obviously replace 'x', 'y' and 'z' with the actual coordinates and replace 'a' with the facing angle you want the player to have when they spawn there.

Next create a function that determines the closest hospital to the player;
PHP код:
GetClosestHospital(playerid)
{
    new 
closest = -1;
    
    for(new 
iFloat:minDist Float:0x7F800000sizeof(gHospitalLocations); i++)
    {
        new 
Float:currentDist GetPlayerDistanceFromPoint(playeridgHospitalLocations[i][0], gHospitalLocations[i][1], gHospitalLocations[i][2]);
        
        if(
currentDist minDist)
        {
            
minDist currentDist;
            
closest i;
        }
    }
    
    return 
closest;

When they die, get the closest hospital and then set the spawn info:
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    new 
        
h_id GetClosestHospital(playerid);
    new
        
Float:gHospitalLocations[h_id][0],
        
Float:gHospitalLocations[h_id][1],
        
Float:gHospitalLocations[h_id][2],
        
Float:gHospitalLocations[h_id][3];
    
    
SetSpawnInfo(playerid, ..., xyza, ...);
    return 
1;

Alright, i put it like that

PHP код:
new Float:gHospitalLocations[][4] = {
    {
xyza},
    {
xyza},
    {
xyza}
}
GetClosestHospital(playerid)
{
    new 
closest = -1;
    for(new 
iFloat:minDist Float:0x7F800000sizeof(gHospitalLocations); i++)
    {
        new 
Float:currentDist GetPlayerDistanceFromPoint(playeridgHospitalLocations[i][0], gHospitalLocations[i][1], gHospitalLocations[i][2]);
        if(
currentDist minDist)
        {
            
minDist currentDist;
            
closest i;
        }
    }
    return 
closest;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    new
        
h_id GetClosestHospital(playerid);
    new
        
Float:gHospitalLocations[h_id][0],
        
Float:gHospitalLocations[h_id][1],
        
Float:gHospitalLocations[h_id][2],
        
Float:gHospitalLocations[h_id][3];
    
SetSpawnInfo(playerid, ..., xyza, ...);
    return 
1;

But it show this errors ..

Код:
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.
Reply


Messages In This Thread
Player spawn - by TwiiKzz - 23.01.2016, 10:15
Re: Player spawn - by Arshman - 23.01.2016, 11:48
Re: Player spawn - by Vince - 23.01.2016, 12:15
Re: Player spawn - by Arshman - 23.01.2016, 12:20
Re: Player spawn - by TwiiKzz - 23.01.2016, 13:23
Re: Player spawn - by TwiiKzz - 23.01.2016, 13:34
Re: Player spawn - by Riddy - 23.01.2016, 14:23
Re: Player spawn - by PrO.GameR - 23.01.2016, 17:06
Re: Player spawn - by TwiiKzz - 24.01.2016, 13:49
Re: Player spawn - by TwiiKzz - 25.01.2016, 12:38

Forum Jump:


Users browsing this thread: 1 Guest(s)