spawn problem
#1

Hello i made a code comments will explain:

PHP код:
    if(PlayerInfo[playerid][pRegistred] == 1 && IsDied[playerid] == 1) //if player already registered and died
    
{
        new 
Random = random(sizeof(RandomSpawns));
        
SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        
SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);
        
IsDied[playerid] = 0;
     }
    else if(
PlayerInfo[playerid][pRegistred] == 1 && IsDied[playerid] == 0) // if player already registred and just joined the game and spawned
    
{
        
SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
        
SetPlayerFacingAngle( playerid, PlayerInfo[playerid][pAngle]);
        
SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]);
        
SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVirtualWorld]);
        
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
     }
    else if(
PlayerInfo[playerid][pRegistred] == 0 && IsDied[playerid] == 0) //if player first time registered and first time spawning
    
{
        new 
Random = random(sizeof(RandomSpawns));
        
SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        
SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);
        
SetPlayerInterior(playerid, 0);
        
SetPlayerVirtualWorld(playerid, 0);
        
GivePlayerMoney(playerid, 15000);
        
GivePlayerWeapon(playerid, 4, 1);
        
GivePlayerWeapon(playerid, 22, 150);
    } 
My problem is when player registred and died it spawns at the last position while it should be spawned in a random spawn point
Reply
#2

it's because youre checking if IsDied=0 right after setting it to 0.
Reply
#3

You probably don't set IsDied[playerid] to 1 under OnPlayerDeath
Reply
#4

Should add a new variable JustSpawned(playerid) and make that in among the checks.

Just so it's clearer rather than being hidden as such in the combo to activate it.
Reply
#5

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Should add a new variable JustSpawned(playerid) and make that in among the checks.

Just so it's clearer rather than being hidden as such in the combo to activate it.
i didnt got you can you explain please
Reply
#6

Just add IsDied[playerid] = 1; to OnPlayerDeath, your code should handle everything else.
Reply
#7

Quote:
Originally Posted by CmZxC
Посмотреть сообщение
Just add IsDied[playerid] = 1; to OnPlayerDeath, your code should handle everything else.
already done that IsDied[playerid] = 1;
Reply
#8

any help guys?
Reply
#9

What do thr variable IsDied for?
Reply
#10

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
What do thr variable IsDied for?
Its to check in onplayerspawn if player died or not
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)