/spec problem
#1

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.
Reply
#2

When an admin stops specing, OnPlayerSpawn is called.
Reply
#3

Disable Spawning OnSpawnPlace after /Specoff...

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

On the place before spEcing some player?
Reply
#4

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.
Reply
#5

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
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)