27.11.2015, 00:53
Hello i made a code comments will explain:
My problem is when player registred and died it spawns at the last position while it should be spawned in a random spawn point
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);
}