How to Make a nearest hospital spawn
#1

Can somebody help me with this?
Reply
#2

first step: find a hospital then use /save when you want to spawn

second step: goto Documents/Gta San Andreas User Files/SAMP/savedposition.txt copy the line save pos

third step: goto Pawn write in your gamemode

pawn Код:
public OnGameModeInt()
{
    //Paste that line in this
    return 1;
}
Reply
#3

Quote:
Originally Posted by xganyx
Посмотреть сообщение
first step: find a hospital then use /save when you want to spawn

second step: goto Documents/Gta San Andreas User Files/SAMP/savedposition.txt copy the line save pos

third step: goto Pawn write in your gamemode

pawn Код:
public OnGameModeInt()
{
    //Paste that line in this
    return 1;
}
No man i dont want them to spawn on the start what i want is when they die to spawn in the nearest hospital
Reply
#4

Its too much code , you can just make that when player dies he spawns at hospital , thats all
Reply
#5

Get the second, third and fourth number from what you have saved:
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, second number, third number, fourth number);
    return 1;
}
Reply
#6

Nah make it in use of VARIABLES! use variables dudes.

make it when connect

pawn Код:
new died[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    died[playerid] =0;
}

//OnPlayerDeath
 died[playerid] =1;

//OnPlayerSpawn
if(died[playerid] == 1)
{
  if(IsPlayerInRangeOfPoint(playerid, 100, x, y, z)) //I don't know the exact distance, it needs calculations, you do it. and change 100 to a good distance, close to two hospitals, so yeah, use this. //post LV axis for example
        {
           SetPlayerPos(playerid, x, y, z); //hospital spawn
           died =0;
           return 1;
        }
  if(IsPlayerInRangeOfPoint(playerid, 100, x, y, z)) //post SF axis for example
        {
           SetPlayerPos(playerid, x, y, z); //hospital spawn
           died =0;
           return 1;
        }
        //and so on
}
SetPlayerPos(playerid, x, y, z);  //normal spawns
Reply
#7

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
Get the second, third and fourth number from what you have saved:
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, second number, third number, fourth number);
    return 1;
}

facepalm* so everytime I want to spawn when i log in i will spawn at the hospital and i dont want just 1 hospital i want when the player Dies to detect the nearest hospital and spawn there
Reply
#8

You guys don't exactly get what he means, he means he will spawn in nearest hospital for example, I died in Vinewoods i will spawn near the hospital (Near the mall).

O-T:

You need to detect something like distance between players and all of the hospitals you created and if one of them are near in the player, spawn it there! I don't quite know what you want and i don't really actually know how to code this.
Reply
#9

I know how..
EDITED MY POST
Reply
#10

pawn Код:
new dead[MAX_PLAYERS];    // On top of the script.
public OnPlayerConnect(playerid)
{
    dead[playerid] = 0;
    return 1;
}
public OnPlayerspawn(playerid)
{
    if(dead[playerid] == 1) SpawnToHospital(playerid);
    return 1;
}

stock SpawnToHospital(playerid)
{
    dead[playerid] = 0;
    static const hspawns[][4] =
    {
        {x coord, y coord, z coord, angle},
        {x1 coord, y1 coord, z1 coord, angle1},
        // Other hospital spawns.
        // Last line must not have ",".
    };
    new Float:spawndist[2];  // Change to the number of hospital spawnpoints you use.
    new Float:distance = 10000.0, closestspawn;
    spawndist[0] = GetPlayerDistanceFromPoint(playerid, x, y, z); // 1st hospital spawn.
    spawndist[1] = GetPlayerDistanceFromPoint(playerid, x1, y1, z1); // 2nd hospital spawn.
    // Other Hospital Spawns like above.
    for(new i = 0; i < sizeof(spawndist); i++)
    {
        if(spawndist[i] < distance) distance = spawndist[i], closestspawn = i;
    }
    SetPlayerPos(playerid, hspawns[closestspawn][0], hspawns[closestspawn][1], hspawns[closestspawn][2]);
    SetPlayerFacingAngle(playerid, hspawns[closestspawn][3]);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)