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



Help with spec cmd - hab2ever - 11.07.2010

Hey guys

i need /spec command for rcon admin

please send code's

thanks.


Re: Help with spec cmd - [HUN]Jaki - 11.07.2010

I am using this code:

To the top: (must be a global variable)
Код:
new whoIsHeSpectating[MAX_PLAYERS];
OnPlayerCommandText:
Код:
if(strcmp(cmd, "/spec", true) == 0) {
  if(!IsPlayerAdmin(playerid)) return 0;
  if (GetPlayerState(playerid)==9){
    whoIsHeSpectating[playerid]=-1;
    TogglePlayerSpectating(playerid, 0);
    return 1;
  }
  new who,tmp[128];
  tmp = strtok(cmdtext,idx);
  if (!strlen(tmp)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /spec [playerid]");
  who = strval(tmp);
  if (!IsPlayerConnected(who)) return SendClientMessage(playerid,COLOR_RED,"Player is offline.");
  TogglePlayerSpectating(playerid, 1);
  whoIsHeSpectating[playerid]=who;
  if (IsPlayerInAnyVehicle(who)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(who));
  else PlayerSpectatePlayer(playerid, who);
  return 1;
}
OnPlayerStateChange:
Код:
for (new i=0;i<MAX_PLAYERS; i++){
  if (whoIsHeSpectating[i]==playerid){
    if (newstate==2 || newstate==3) PlayerSpectateVehicle(i, GetPlayerVehicleID(playerid));
    else PlayerSpectatePlayer(i, playerid);
  }
}
OnPlayerConnect, OnPlayerDisconnect:
Код:
whoIsHeSpectating[playerid]=-1;



Re: Help with spec cmd - hab2ever - 11.07.2010

Thanks.


Re: Help with spec cmd - Mr187 - 11.07.2010

Next time search.


Re: Help with spec cmd - [HUN]Jaki - 11.07.2010

Quote:
Originally Posted by Mr187
Посмотреть сообщение
Next time search.
Indeed.
Sorry, I am a n00b here.