Spectating Vehicles
#1

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);
Reply
#2

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

hummm how could i do that?
Reply
#4

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

Ill try that out.
Reply
#6

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

Still doing the exact same thing
Reply
#8

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

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


Forum Jump:


Users browsing this thread: 3 Guest(s)