#1

Hello there.. so i have this code, and every time i spawn in the fourth element in the array that Fort Carson medical center, How i can fix it?

Note: I already declared the variables and it spawns me there only in the cuz of death the dead[playerid] variable became 1 and i make it 0 when i call this stock, so it works well and the problem is in this code.

stock SpawnToHospital(playerid)
{
dead[playerid] = 0;
static const Float:hspawns[][] =
{
{1177.7263,-1323.5454,14.0849,270.4835},
{2031.2523,-1417.6346,16.9922,136.7121},
{1605.1945,1827.5796,10.8203,359.4712},
{-322.0239,1057.6073,19.7422,329.0772},
{-1515.3013,2530.9287,55.6918,0.4110},
{1244.1927,332.1204,19.5547,337.2003},
{-2655.3577,634.5221,14.4531,181.1825}
};
new Floatpawndist[7];
new Float:distance = 10000.0, closestspawn;
spawndist[0] = GetPlayerDistanceFromPoint(playerid, 1177.7263,-1323.5454,14.0849); // 1st hospital spawn.
spawndist[1] = GetPlayerDistanceFromPoint(playerid, 2031.2523,-1417.6346,16.9922); // 2nd hospital spawn.
spawndis[/LEFT]t[2] = GetPlayerDistanceFromPoint(playerid, 1605.1945,1827.5796,10.8203); // 3th hospital spawn.
spawndist[3] = GetPlayerDistanceFromPoint(playerid, -322.0239,1057.6073,19.7422); // 4th hospital spawn.
spawndist[4] = GetPlayerDistanceFromPoint(playerid, -1515.3013,2530.9287,55.691; // 5th hospital spawn.
spawndist[5] = GetPlayerDistanceFromPoint(playerid, 1244.1927,332.1204,19.5547); // 6th hospital spawn.
spawndist[6] = GetPlayerDistanceFromPoint(playerid, -2655.3577,634.5221,14.4531); // 7th hospital spawn.
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]);
return 1;
}

Reply
#2

Have you tried using Randoms?

PHP код:
        new rand random(7);
        switch(
rand)
        {
              Case 
0:
              {
                    
SetPlayerPos(playeridhspawns[closestspawn][0]);
               } 
for example..
Reply
#3

I don't want random respawn, i asked for the closest hospital.. i could do it random..
Reply
#4

Dam.. This happens every time i ask for help.. i just discovered out the problem.. lol thanks at all >_<.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)