Spawn messed up
#1

Guys really need your help with this. First I made a spawn command which saves a player current position and it loads on player spawn. So its like a save/autoload position. Its working nice when I do /spawn then after I died or get killed it spawned me back where I used /spawn.

But here is the problem, when I'm gone to a deathmatch area which also has an auto respawn in same area (this is different with /spawn command) After I got killed in that deathmatch area, after it spawned me back where I use /spawn Not where I was doing deathmatch. I should spawn in the deathmatch area.

Here is the code under onplayerspawn

Код:
public OnPlayerSpawn(playerid)
{
if(GetPVarInt(playerid,"GrenadeDM"))
{
     new Random = random(sizeof(RandomSpawnGrenadeDM));
     SetPlayerPos(playerid, RandomSpawnGrenadeDM[Random][0], RandomSpawnGrenadeDM[Random][1],       RandomSpawnGrenadeDM[Random][2]);
     SetPlayerFacingAngle(playerid, RandomSpawnGrenadeDM[Random][3]);
     SetPlayerHealth(playerid, 100);
     SetPlayerArmour(playerid, 0);
     SetPlayerInterior(playerid, 18);
     SetCameraBehindPlayer(playerid);
     SetPlayerVirtualWorld(playerid, 16);
     SaveWeapons(playerid);
     ResetPlayerWeapons(playerid);
     GivePlayerWeapon(playerid, 16, 50000);
}
else
{
     new Random = random(sizeof(RandomSpawns));
     SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
}
and another one this also under onplayerspawn. here is the /spawn
Код:
if ( PosX[ playerid ] != 0 && PosY[ playerid ] != 0 && PosZ[ playerid ] != 0 )
{
     SetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
     SetPlayerFacingAngle( playerid, Angle[ playerid ] );
     SetCameraBehindPlayer(playerid);
}
else
{
     new Random = random(sizeof(RandomSpawns));
     SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
}
Whole code

Код:
public OnPlayerSpawn(playerid)
{
     if(GetPVarInt(playerid,"GrenadeDM"))
{
     new Random = random(sizeof(RandomSpawnGrenadeDM));
     SetPlayerPos(playerid, RandomSpawnGrenadeDM[Random][0], RandomSpawnGrenadeDM[Random][1],       RandomSpawnGrenadeDM[Random][2]);
     SetPlayerFacingAngle(playerid, RandomSpawnGrenadeDM[Random][3]);
     SetPlayerHealth(playerid, 100);
     SetPlayerArmour(playerid, 0);
     SetPlayerInterior(playerid, 18);
     SetCameraBehindPlayer(playerid);
     SetPlayerVirtualWorld(playerid, 16);
     SaveWeapons(playerid);
     ResetPlayerWeapons(playerid);
     GivePlayerWeapon(playerid, 16, 50000);
}
else
{
     new Random = random(sizeof(RandomSpawns));
     SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
}
if ( PosX[ playerid ] != 0 && PosY[ playerid ] != 0 && PosZ[ playerid ] != 0 )
{
     SetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
     SetPlayerFacingAngle( playerid, Angle[ playerid ] );
     SetCameraBehindPlayer(playerid);
}
else
{
     new Random = random(sizeof(RandomSpawns));
     SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
}
	return 1;
}
EDIT: This is the grenade deathmatch

Код:
CMD:grenade(playerid, params[])
{
   	SetPlayerHealth(playerid, 100);
   	SetPlayerArmour(playerid, 0);
   	SetPlayerInterior(playerid, 18);
  	SaveWeapons(playerid);
   	ResetPlayerWeapons(playerid); //must be added before this
   	GivePlayerWeapon(playerid, 16, 50000);
	SetPlayerVirtualWorld(playerid, 8);
	SetCameraBehindPlayer(playerid);
 	DestroyVehicle(GetPlayerVehicleID(playerid));
  	new Random = random(sizeof(RandomSpawnGrenadeDM));
   	SetPlayerPos(playerid, RandomSpawnGrenadeDM[Random][0], RandomSpawnGrenadeDM[Random][1], RandomSpawnGrenadeDM[Random][2]);
   	SetPlayerFacingAngle(playerid, RandomSpawnGrenadeDM[Random][3]);
   	SetPVarInt(playerid,"GrenadeDM",true);
 	return 1;
}
Reply
#2

I fixed it now.

But I how do I make /rspawn - to reset spawn to normal spawn position?



This is the spawn command.

Код:
CMD:spawn(playerid,params[])
{
	GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
	GetPlayerFacingAngle( playerid, Angle[ playerid ] );
	return 1;
}
Reply
#3

Helppp please!
Reply
#4

pawn Код:
CMD:rspawn(playerid,params[])
{
        SpawnPlayer(playerid);
    return 1;
}
Reply
#5

First of all... You should detect if the players DM PVars Are 1 And you should put it in "else" statement... so that it does not spawn you on your saved position

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(GetPVarInt(playerid,"GrenadeDM"))
    {
         new Random = random(sizeof(RandomSpawnGrenadeDM));
         SetPlayerPos(playerid, RandomSpawnGrenadeDM[Random][0], RandomSpawnGrenadeDM[Random][1],       RandomSpawnGrenadeDM[Random][2]);
         SetPlayerFacingAngle(playerid, RandomSpawnGrenadeDM[Random][3]);
         SetPlayerHealth(playerid, 100);
         SetPlayerArmour(playerid, 0);
         SetPlayerInterior(playerid, 18);
         SetCameraBehindPlayer(playerid);
         SetPlayerVirtualWorld(playerid, 16);
         SaveWeapons(playerid);
         ResetPlayerWeapons(playerid);
         GivePlayerWeapon(playerid, 16, 50000);
    }
    else
    {
        if ( PosX[ playerid ] != 0 && PosY[ playerid ] != 0 && PosZ[ playerid ] != 0 )
        {
             SetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
             SetPlayerFacingAngle( playerid, Angle[ playerid ] );
             SetCameraBehindPlayer(playerid);
        }
        else
        {
             new Random = random(sizeof(RandomSpawns));
             SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        }
    }
    return 1;
}
Here Try this out

EDIT:

if you wont use a "else" statement it wont detect if the player in grenade dm or not it will forcefully spawn the player to the last saved position because you dont have "else" before you do "if" on your code to check if the Variables are not equal to 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)