SA-MP Forums Archive
/spec problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /spec problem (/showthread.php?tid=412378)



/spec problem - pelani - 01.02.2013

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.


Re: /spec problem - tyler12 - 01.02.2013

When an admin stops specing, OnPlayerSpawn is called.


Re: /spec problem - NickHaudMTA - 01.02.2013

Disable Spawning OnSpawnPlace after /Specoff...

And can u tell me where u want to spawn after specing?

On the place before spEcing some player?


Re: /spec problem - Accord - 01.02.2013

Well, you had to except it because you simply forgot to add the function SetPlayerPos to your command.
If you didn't get me yet, all you have add the function and fill the parameters.


Re: /spec problem - Jewell - 02.02.2013

when you use TogglePlayerSpectating(playerid, 0); //spec off OnPlayerSpawn will automatically be called.

So you have to store player position, health ,armour and weapon ect ect before you start /spec
btw read this funtions,
https://sampwiki.blast.hk/wiki/GetPlayerPos
https://sampwiki.blast.hk/wiki/SetPVarFloat
https://sampwiki.blast.hk/wiki/GetPVarFloat


Re: /spec problem - Threshold - 02.02.2013

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.