/spec cmd
#1

Hi all,i've a problem with /spec cmd.

pawn Код:
if(strcmp(cmd, "/spec", true) == 0) {
    if (GetPlayerState(playerid)==9){
    whoIsHeSpectating[playerid]=-1;
    TogglePlayerSpectating(playerid, 0);
    SetCameraBehindPlayer(playerid);
    return 1;
  }
  new who;
  tmp = strtok(cmdtext,idx);
  if (!strlen(tmp)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /spec [playerid] - Use again /spec when u want stop spectating.");
  who = strval(tmp);
  if (!IsPlayerConnected(who)) return SendClientMessage(playerid,COLOR_RED,"Player is offline.");
  TogglePlayerSpectating(playerid, 1);
  whoIsHeSpectating[playerid]=who;
  SetCameraBehindPlayer(playerid);
  if (IsPlayerInAnyVehicle(who)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(who));
  else PlayerSpectatePlayer(playerid, who);
  return 1;
}
It's all okay,but when a player enter in a car,i see his face...how to add the normal camera to show whole vehicle?Thanks
Reply
#2

Use OnPlayerStateChange, same goes if the player changes the interior or the virtualworld
Use for that OnPlayerInteriorChange and OnPlayerVirtualWorldChange (the last isnt a native callback and only needed if you use different worlds)

pawn Код:
//OnPlayerStateChange
    switch(newstate) {
        case PLAYER_STATE_DRIVER, PLAYER_STATE_PASSENGER: {
            new
                i,
                vehicleid = GetPlayerVehicleID(playerid);
            for( ; i != MAX_PLAYERS; ++i) {
                if(whoIsHeSpectating[i] == playerid) {
                    PlayerSpectateVehicle(i, vehicleid);
                }
            }
        }
        case PLAYER_STATE_ONFOOT: {
            new
                i;
            for( ; i != MAX_PLAYERS; ++i) {
                if(whoIsHeSpectating[i] == playerid) {
                    PlayerSpectatePlayer(i, playerid);
                }
            }
        }
    }
Reply
#3

If you do /spec id again, it will show the car
Reply
#4

Quote:
Originally Posted by ColdIce
Посмотреть сообщение
If you do /spec id again, it will show the car
or just use what nero said -.-
Reply
#5

Thanks Nero,fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)