SA-MP Forums Archive
spawn problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: spawn problem (/showthread.php?tid=595014)



spawn problem - SalmaN97 - 27.11.2015

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


Re: spawn problem - lucamsx - 27.11.2015

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


Re: spawn problem - PrO.GameR - 27.11.2015

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


Re: spawn problem - Sew_Sumi - 27.11.2015

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.


Re: spawn problem - SalmaN97 - 28.11.2015

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


Re: spawn problem - CmZxC - 28.11.2015

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


Re: spawn problem - SalmaN97 - 28.11.2015

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


Re: spawn problem - SalmaN97 - 29.11.2015

any help guys?


Re: spawn problem - ATGOggy - 29.11.2015

What do thr variable IsDied for?


Re: spawn problem - SalmaN97 - 29.11.2015

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