22.10.2013, 18:53
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
and another one this also under onplayerspawn. here is the /spawn
Whole code
EDIT: This is the grenade deathmatch
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]);
}
Код:
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]);
}
Код:
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;
}
Код:
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;
}

