PDA

View Full Version : deathmatch spawn


kbalor
10/10/2013, 02:55 PM
Hello guys. I just wonder how come its not spawning in deathmatch after I died/killed (e.g GrenadeDM) even If I already set them where to spawn and made a Pvar to define if player is in a DM. It should spawn back in the same place.

Edit: I don't know why but when I got died/killed I spawn to normal not where I was in a DM.

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);
IsPlayerInDM[playerid] = 1;
pInEvent[playerid] = 1;
SetPVarInt(playerid, "CMDDisabled", 3);
}


new str[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(str, sizeof(str), "{09F7DF}(/grenade) {ffd700}%s {09F7DF}has Teleported to Grenade Fight Deathmatch",pName);
SendClientMessageToAll(0xFFFFFFFF, str);
GameTextForPlayer(playerid,"~y~Welcome to ~n~~b~Grenade Fight",2000,3);
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]);
IsPlayerInDM[playerid] = 1;
SetPVarInt(playerid,"GrenadeDM",true);
pInEvent[playerid] = 1;
SetPVarInt(playerid, "CMDDisabled", 3);
return 1;
}

Konstantinos
10/10/2013, 03:06 PM
You set to 1 and then you should check if GetPVarInt(playerid,"GrenadeDM") returns 1 to continue.

Although, it's better not to use PVars. I'd use it like that.


new
bool: GrenadeDM[ MAX_PLAYERS char ]
;

// OnPlayerConnect:
GrenadeDM{ playerid } = false;

// OnPlayerSpawn:
public OnPlayerSpawn(playerid)
{
if( GrenadeDM{ playerid } )
{
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);
IsPlayerInDM[playerid] = 1;
pInEvent[playerid] = 1;
SetPVarInt(playerid, "CMDDisabled", 3);
}
// rest


// When they join the grenade DM
new str[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(str, sizeof(str), "{09F7DF}(/grenade) {ffd700}%s {09F7DF}has Teleported to Grenade Fight Deathmatch",pName);
SendClientMessageToAll(0xFFFFFFFF, str);
GameTextForPlayer(playerid,"~y~Welcome to ~n~~b~Grenade Fight",2000,3);
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]);
IsPlayerInDM[playerid] = 1;
GrenadeDM{ playerid } = true;
pInEvent[playerid] = 1;
SetPVarInt(playerid, "CMDDisabled", 3);

// Whey they leave grenade DM:
GrenadeDM{ playerid } = false;

kbalor
10/10/2013, 03:58 PM
You set to 1 and then you should check if GetPVarInt(playerid,"GrenadeDM") returns 1 to continue.

Although, it's better not to use PVars. I'd use it like that.


new
bool: GrenadeDM[ MAX_PLAYERS char ]
;

// OnPlayerConnect:
GrenadeDM{ playerid } = false;

// OnPlayerSpawn:
public OnPlayerSpawn(playerid)
{
if( GrenadeDM{ playerid } )
{
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);
IsPlayerInDM[playerid] = 1;
pInEvent[playerid] = 1;
SetPVarInt(playerid, "CMDDisabled", 3);
}
// rest


// When they join the grenade DM
new str[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(str, sizeof(str), "{09F7DF}(/grenade) {ffd700}%s {09F7DF}has Teleported to Grenade Fight Deathmatch",pName);
SendClientMessageToAll(0xFFFFFFFF, str);
GameTextForPlayer(playerid,"~y~Welcome to ~n~~b~Grenade Fight",2000,3);
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]);
IsPlayerInDM[playerid] = 1;
GrenadeDM{ playerid } = true;
pInEvent[playerid] = 1;
SetPVarInt(playerid, "CMDDisabled", 3);

// Whey they leave grenade DM:
GrenadeDM{ playerid } = false;


Still won't spawn back to deathmatch grenadedm map. I've another gamemode which were I took the script and on that gamemode it worked. Maybe I missed again something. But I know its all in onplayerspawn.

EDIT:

Omg maybe because of this??

if ( PosX[ playerid ] != 0 && PosY[ playerid ] != 0 && PosZ[ playerid ] != 0 )
{
SetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
SetPlayerFacingAngle( playerid, Angle[ playerid ] );
SetPlayerInterior( playerid, Interior[ playerid ] );
SetPlayerVirtualWorld( playerid, VirtualWorld[ playerid ] );
SetCameraBehindPlayer(playerid);
}
else
{
new Random = random(sizeof(RandomSpawns));
SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
// set the position for those who has not saved
}