SA-MP Forums Archive
Spectating Vehicles - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Spectating Vehicles (/showthread.php?tid=100767)



Spectating Vehicles - V1ceC1ty - 06.10.2009

Ive got this so when you press space it spectates a Shamal when your in the range of it. That works fine, its just getting out that doesnt work. When i try to exit with space it looks like it turns spec off and sets the players pos alittle bit away but then straight after it respawns you. How can this be fixed?

pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

new InShamal[MAX_PLAYERS];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  new Float:X, Float:Y, Float:Z;
    if (PRESSED(KEY_SPRINT))
    {
        if(InShamal[playerid] == 0)
        {
          GetVehiclePos(Shamal, X, Y, Z);
          if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z))
          {
            InShamal[playerid] = 1;
                TogglePlayerSpectating(playerid, 1);
                PlayerSpectateVehicle(playerid, Shamal, 1);
            }
        }
        else if(InShamal[playerid] == 1)
        {
          GetVehiclePos(Shamal, X, Y, Z);
          TogglePlayerSpectating(playerid, 0);
            InShamal[playerid] = 0;
          SetPlayerPos(playerid, X, Y+3, Z);
        }
    }
    return 1;
}
ive tried swapping these around but seems to do the same thing.
pawn Код:
GetVehiclePos(Shamal, X, Y, Z);
          TogglePlayerSpectating(playerid, 0);
            InShamal[playerid] = 0;
          SetPlayerPos(playerid, X, Y+3, Z);



Re: Spectating Vehicles - oncedead - 06.10.2009

Well this is the most help I can give but, I've had the same crap with turning spectate off the thing I realized was when spectate is toggled off it completely resets you and triggers OnPlayerSpawn. What I did was triggered a variable when the spectate goes off then in OnPlayerSpawn using the variable set their position and such.

With love,
The Reymon


Re: Spectating Vehicles - V1ceC1ty - 06.10.2009

hummm how could i do that?


Re: Spectating Vehicles - oncedead - 06.10.2009

Top of script
pawn Код:
new Shamaloff[MAX_PLAYERS];

New Shamal exit code
pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

new InShamal[MAX_PLAYERS];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  new Float:X, Float:Y, Float:Z;
    if (PRESSED(KEY_SPRINT))
    {
        if(InShamal[playerid] == 0)
        {
          GetVehiclePos(Shamal, X, Y, Z);
          if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z))
          {
            InShamal[playerid] = 1;
                TogglePlayerSpectating(playerid, 1);
                PlayerSpectateVehicle(playerid, Shamal, 1);
            }
        }
        else if(InShamal[playerid] == 1)
        {
          Shamaloff[playerid] = 1;
          TogglePlayerSpectating(playerid, 0);
          InShamal[playerid] = 0;
        }
    }
    return 1;
}
OnPlayerSpawn
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(Shamaloff[playerid]==1)
    {
        Shamaloff[playerid] = 0;
        GetVehiclePos(Shamal, X, Y, Z);
        SetPlayerPos(playerid, X, Y+3, Z);
        return 1;

//Big problem you need to give them their skin and weapons back thats up to you...

    }
Thats about it I think and yes I know spec sucks :\

With love,
The Reymon.


Re: Spectating Vehicles - V1ceC1ty - 06.10.2009

Ill try that out.



Re: Spectating Vehicles - oncedead - 06.10.2009

Tell me how the test run goes I'd like to know if that system works for more then just me and my ability to duct-tape workarounds XD

With love,
The Reymon


Re: Spectating Vehicles - V1ceC1ty - 06.10.2009

Still doing the exact same thing


Re: Spectating Vehicles - oncedead - 06.10.2009

Either you didn't put in the new keypress code or maybe you didn't put the onplayerspawn code on the very top of onplayerspawn otherwise I'm not quite sure I'll take your snippet and see if it works.


Re: Spectating Vehicles - oncedead - 06.10.2009

Tested, couldn't work better. You didn't copy paste something right oh and make sure your
new Float:X,Float:Y,Float:Z; is only at the top.