Help Spectate
#1

I have this command and is works 100%

pawn Код:
dcmd_spectate(playerid,params[])
{
  if(PlayerData[playerid][AdminLevel] >= 1)
  {
  new tmp[256], idx;
  tmp = strtok(params,idx);
  if(!strlen(tmp))
  {
    SendClientMessage(playerid, COLOUR_WHITE, "Use: /spectate [playerid]");
    return true;
  }
  new pid = strval(tmp);
  if(!IsPlayerConnected(pid))
  {
    SendClientMessage(playerid, COLOUR_RED, "Error: Incorrect playerid.");
    return true;
  }
  new string[256], pname[MAX_PLAYER_NAME];
  GetPlayerName(pid, pname, sizeof(pname));
  format(string, sizeof(string), "You are spectating one player", pname);
  SendClientMessage(playerid, COLOUR_RED, string);
  format(string, sizeof(string), "Type /spectateoff for leave spectating", pname);
  SendClientMessage(playerid, COLOUR_WHITE, string);
  TogglePlayerSpectating(playerid, 1);
  PlayerSpectatePlayer(playerid, pid);
  PlayerSpectateVehicle(playerid, pid);
  return true;
  }
  else return false;
}
But is only spectate the player... when the player get in car, the camare is spectate the player, and look him face.

I want make when the player enter in the car, this spectate the car...

This is possible?

Help me with this please, i dont know how make it.
Reply
#2

pawn Код:
public OnPlayerStateChange

if(newstate == 2 || newstate ==3)//driver or passanger

  TogglePlayerSpectating(playerid, 1);
  PlayerSpectateVehicle(playerid, GetPlayerVehicleID(playerid));
Reply
#3

emm... where put it?
Reply
#4

Quote:
Originally Posted by [CN
ERO ]
emm... where put it?
OnPlayerStateChange
Reply
#5

Quote:
Originally Posted by SpiderPork
Quote:
Originally Posted by [CN
ERO ]
emm... where put it?
OnPlayerStateChange
This...?

pawn Код:
public OnPlayerStateChange
{

    if(newstate == 2 || newstate ==3);//driver or passanger

  TogglePlayerSpectating(playerid, 1);
  PlayerSpectateVehicle(playerid, GetPlayerVehicleID(playerid));
  return 1;
}
I no understant good where put it lol
Reply
#6

Put it under the OnPlayerStateChange callback:
https://sampwiki.blast.hk/wiki/OnPlayerStateChange

Add a check to see if the player is being spectated, if so, use the two functions on the spectating player.
Make this when player exits the vehicle (continue spectating the player instead of the vehicle)
Add brackets and ident the code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)