SA-MP Forums Archive
/spec cmd - 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: /spec cmd (/showthread.php?tid=260947)



/spec cmd - Face9000 - 11.06.2011

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


AW: /spec cmd - Nero_3D - 11.06.2011

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);
                }
            }
        }
    }



Re: /spec cmd - ColdIce - 11.06.2011

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


Re: /spec cmd - Sascha - 11.06.2011

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


Re: /spec cmd - Face9000 - 11.06.2011

Thanks Nero,fixed.