01.02.2013, 19:34
when admin do /spec player id is okay but when they do /specoff so they get spawn on spawn place and i want they should be spawn on where they using /spec cmd. not on spawn place.
new Float:SpecPos[MAX_PLAYERS][4]; //At the top of your script, so we can have variables for everyone.
new IsSpectating[MAX_PLAYERS];
public OnPlayerConnect(playerid) //When a player connects
{
IsSpectating[playerid] = 0; //Player is not spectating a player
SpecPos[playerid][0] = 0; //X coordinate
SpecPos[playerid][1] = 0; //Y coordinate
SpecPos[playerid][2] = 0; //Z coordinate
SpecPos[playerid][3] = 0; //Facing angle
return 1;
}
CMD:spec(playerid, params);
{
//sscanf etc.
new Float:x, Float:y, Float:z, Float:angle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angle);
TogglePlayerSpectating(playerid, 1);
//Spectate player here...
IsSpectating[playerid] = 1; //Player is now spectating
SpecPos[playerid][0] = x;
SpecPos[playerid][1] = y;
SpecPos[playerid][2] = z;
SpecPos[playerid][3] = angle;
return 1;
}
public OnPlayerSpawn(playerid) //When a player spawns, or uses specoff by default
{
//All OnPlayerSpawn stuff here
//At the bottom of OnPlayerSpawn...
if(IsSpectating[playerid] == 1)
{
SetPlayerPos(playerid, SpecPos[playerid][0], SpecPos[playerid][1], SpecPos[playerid][2]);
SetPlayerFacingAngle(playerid, SpecPos[playerid][3]);
IsSpectating[playerid] = 0; //Player is not spectating a player
}
return 1;
}