/spec problem
#6

Example:
pawn Код:
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;
}
A bit rough and messy in my opinion, but it will work.
Reply


Messages In This Thread
/spec problem - by pelani - 01.02.2013, 19:34
Re: /spec problem - by tyler12 - 01.02.2013, 19:41
Re: /spec problem - by NickHaudMTA - 01.02.2013, 19:45
Re: /spec problem - by Accord - 01.02.2013, 19:46
Re: /spec problem - by Jewell - 02.02.2013, 05:36
Re: /spec problem - by Threshold - 02.02.2013, 05:57

Forum Jump:


Users browsing this thread: 1 Guest(s)