jeudi 21 juillet 2016

Alternating Spawn Locations?

When people connect to my server and spawn, I want them to spawn at their last position.

PHP Code:

    if(PlayerInfo[playerid][pXPos] == 0.0 && PlayerInfo[playerid][pYPos] == 0.0 && PlayerInfo[playerid][pZPos] == 0.0)
    {
        
SetSpawnInfo(playeridNO_TEAMGetPlayerSkin(playerid),-1968.9745,137.8568,27.6875,88.8534000000);
    }
    else
    {
        if(
USE_EXISTING_POSITION == true)
        {
              
SetPlayerPos(playeridPlayerInfo[playerid][pXPos], PlayerInfo[playerid][pYPos], PlayerInfo[playerid][pZPos]);
            
SetPlayerFacingAngle(playeridPlayerInfo[playerid][pAPos]);
        }
        if(
USE_EXISTING_MONEY == true)
        {
               
ResetPlayerMoney(playerid);
            
GivePlayerMoney(playeridPlayerInfo[playerid][pCash]);
        }
    } 

This is under the callback OnPlayerSpawn.
However when a player dies, I want them to spawn at the nearest hospital.

PHP Code:

    new Float:distance 99999.0,
    
Float:tmp_distance,
      
closest = -1;
    for(new 
0MAX_HOSPITALSi++)
    {
        
tmp_distance GetPlayerDistanceFromPoint(playeridhspawns[i][0], hspawns[i][1], hspawns[i][2]);
        if (
tmp_distance distance)
        {
            
distance tmp_distance;
            
closest i;
        }
    }
    
SetSpawnInfo(playeridNO_TEAMGetPlayerSkin(playerid), hspawns[closest][0],hspawns[closest][1],hspawns[closest][2],hspawns[closest][3], 000000); 

This code is under the callback OnPlayerDeath

Currently what happens is that when a player connects they spawn at their previous position, however once they die. They spawn at the position they spawned at.

How should I go about this?

So that when a player connects they spawn at their previous position. Once they die they then spawn to the nearest hospital.

Let's block ads! (Why?)



Alternating Spawn Locations?

Aucun commentaire:

Enregistrer un commentaire