spawn problem
#1

Hello i made a code comments will explain:

PHP код:
    if(PlayerInfo[playerid][pRegistred] == && IsDied[playerid] == 1//if player already registered and died
    
{
        new 
Random random(sizeof(RandomSpawns));
        
SetPlayerPos(playeridRandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        
SetPlayerFacingAngle(playeridRandomSpawns[Random][3]);
        
IsDied[playerid] = 0;
     }
    else if(
PlayerInfo[playerid][pRegistred] == && IsDied[playerid] == 0// if player already registred and just joined the game and spawned
    
{
        
SetPlayerPos(playeridPlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
        
SetPlayerFacingAngleplayeridPlayerInfo[playerid][pAngle]);
        
SetPlayerInterior(playeridPlayerInfo[playerid][pInterior]);
        
SetPlayerVirtualWorld(playeridPlayerInfo[playerid][pVirtualWorld]);
        
SetPlayerSkin(playeridPlayerInfo[playerid][pSkin]);
     }
    else if(
PlayerInfo[playerid][pRegistred] == && IsDied[playerid] == 0//if player first time registered and first time spawning
    
{
        new 
Random random(sizeof(RandomSpawns));
        
SetPlayerPos(playeridRandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        
SetPlayerFacingAngle(playeridRandomSpawns[Random][3]);
        
SetPlayerInterior(playerid0);
        
SetPlayerVirtualWorld(playerid0);
        
GivePlayerMoney(playerid15000);
        
GivePlayerWeapon(playerid41);
        
GivePlayerWeapon(playerid22150);
    } 
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)