random spectate player ( must be in vehicle ) how?
#1

Hi i need some help

I need a spec system that can be excecuted on any moment( on playerstate change on playerdeath etc )

then you will spec a person in a vehicle( you spec vehicle but a person is driving it ) and if that player dies or what ever, the spec user must be able to auto/press a key to switch to an other random person

i already have this

Код:
new playa = GetRandomPlayer();
KillTimer(timer5[playerid]);
new vehicleid = GetPlayerVehicleID(playa);
	

TogglePlayerSpectating(playerid, 1);
PlayerSpectateVehicle(playerid,vehicleid);

stock GetRandomPlayer()
{
  new yplayer[MAX_SLOTS];
  for (new y = 0; y != MAX_PLAYERS; y ++) {
    if (IsPlayerConnected(y)) {
      yplayer[0] ++;
      yplayer[yplayer[0]] = y;
    }
  }
  return yplayer[random(yplayer[0])+1];
}
Only this isnt fail proof, sometimes you dont spec( see the bridge to sf ) and sometimes you see your self hanging in the air.
Can sombody help me with this?

thanks in advance!
Reply
#2

anybody?
Reply
#3

pawn Код:
//top
new spec[MAX_PLAYERS];

//where they fist start specing players
new playa = GetRandomPlayer();

spec[playa] = playerid; // < added

KillTimer(timer5[playerid]);
new vehicleid = GetPlayerVehicleID(playa);

TogglePlayerSpectating(playerid, 1);
PlayerSpectateVehicle(playerid,vehicleid);

//on player death
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(spec[i] = playerid)
    {
        new playa = GetRandomPlayer();

        spec[playa] = playerid;

        KillTimer(timer5[playerid]);
        new vehicleid = GetPlayerVehicleID(playa);

        TogglePlayerSpectating(playerid, 1);
        PlayerSpectateVehicle(playerid,vehicleid);
    }
}
Untested.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)