SA-MP Forums Archive
I cannot get my /spec working.. - 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: I cannot get my /spec working.. (/showthread.php?tid=96788)



I cannot get my /spec working.. - Lia - 11.09.2009

Im trying to add /spec... that i got.. and it wont work.. the server has a built in /spec... but.. it wont work..
So.?? Any one has a /spec command i can try?


Re: I cannot get my /spec working.. - Jason_Borne420 - 11.09.2009

if you use strval you can do it like this:

Code:
if(strcmp(cmd,"/spec",true)==0)
	{
  if(PlayerAdminLevel[playerid] != 1337) {
  SendClientMessage(playerid, COLOR_ERROR, "Only Admins can use this command");
  return 1;
  }
  tmp = strtok(cmdtext, idx);
  if(!strlen(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /spec (id)");
  return 1;
  }
  if(!IsNumeric(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /spec (id) ID Must be a number");
  return 1;
  }
  if(strval(tmp) == playerid) {
  SendClientMessage(playerid, COLOR_ERROR, "You cannot spec yourself!");
  return 1;
  }
  giveplayerid = strval(tmp);
  if(!IsPlayerConnected(giveplayerid)) {
  format(string, sizeof(string), "ID (%d) Is not an active player",giveplayerid);
  SendClientMessage(playerid, COLOR_ERROR, string);
  return 1;
  }
	IsSpawned[playerid] =1;
	TogglePlayerSpectating(playerid, 1);
  SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(giveplayerid));
  SetPlayerInterior(playerid,GetPlayerInterior(giveplayerid));
	if (IsPlayerInAnyVehicle(giveplayerid)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
	else PlayerSpectatePlayer(playerid, giveplayerid);
	IsSpawned[playerid] = 1;
	return 1;
	}



Re: I cannot get my /spec working.. - Lia - 11.09.2009

Quote:
Originally Posted by Jason_Borne420
if you use strval you can do it like this:

Code:
if(strcmp(cmd,"/spec",true)==0)
	{
  if(PlayerAdminLevel[playerid] != 1337) {
  SendClientMessage(playerid, COLOR_ERROR, "Only Admins can use this command");
  return 1;
  }
  tmp = strtok(cmdtext, idx);
  if(!strlen(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /spec (id)");
  return 1;
  }
  if(!IsNumeric(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /spec (id) ID Must be a number");
  return 1;
  }
  if(strval(tmp) == playerid) {
  SendClientMessage(playerid, COLOR_ERROR, "You cannot spec yourself!");
  return 1;
  }
  giveplayerid = strval(tmp);
  if(!IsPlayerConnected(giveplayerid)) {
  format(string, sizeof(string), "ID (%d) Is not an active player",giveplayerid);
  SendClientMessage(playerid, COLOR_ERROR, string);
  return 1;
  }
	IsSpawned[playerid] =1;
	TogglePlayerSpectating(playerid, 1);
  SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(giveplayerid));
  SetPlayerInterior(playerid,GetPlayerInterior(giveplayerid));
	if (IsPlayerInAnyVehicle(giveplayerid)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
	else PlayerSpectatePlayer(playerid, giveplayerid);
	IsSpawned[playerid] = 1;
	return 1;
	}
Tried. wont work............ Im using the gamemode.. West Coast Roleplay that is SOPOSE.. to have a spec.. but the spec does not work.. and thanks for help tho,


Re: I cannot get my /spec working.. - Anwix - 11.09.2009

Login to RCON, type /rcon loadfs adminspec, type /specplayer [playerid] and /specoff to stop.

All servers come with AdminSpec i think **


Re: I cannot get my /spec working.. - Jason_Borne420 - 19.10.2009

It does work fine. You just need to learn to edit the script. I figured you could figure it out but apparently not, even with the whole command given.

remove the if(playeradminlevel[playerid] != 1337)


and the other variable[playerid] that you dont use.


Re: I cannot get my /spec working.. - Lia - 20.10.2009

Confused :/


Re: I cannot get my /spec working.. - kman - 20.10.2009

/spec doesnt work on lvrcr gm and it probably doesnt work on westcoast roleplay either


Re: I cannot get my /spec working.. - Jason_Borne420 - 22.10.2009

Quote:
Originally Posted by kman
/spec doesnt work on lvrcr gm and it probably doesnt work on westcoast roleplay either
Wrong.


Here is one that works perfect for lvrcr gm - but does work for anyone.


Add this under OnPlayerCommandText

Code:
if(strcmp(cmd,"/spec",true)==0)
  tmp = strtok(cmdtext, idx);
  if(!strlen(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /spec (id)");
  return 1;
  }
  if(!IsNumeric(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /spec (id) ID Must be a number");
  return 1;
  }
  if(strval(tmp) == playerid) {
  SendClientMessage(playerid, COLOR_ERROR, "You cannot spec yourself!");
  return 1;
  }
  giveplayerid = strval(tmp);
  if(!IsPlayerConnected(giveplayerid)) {
  format(string, sizeof(string), "ID (%d) Is not an active player",giveplayerid);
  SendClientMessage(playerid, COLOR_ERROR, string);
  return 1;
  }
	TogglePlayerSpectating(playerid, 1);
  SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(giveplayerid));
  SetPlayerInterior(playerid,GetPlayerInterior(giveplayerid));
	if (IsPlayerInAnyVehicle(giveplayerid)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
	else PlayerSpectatePlayer(playerid, giveplayerid);
	return 1;
	}



Re: I cannot get my /spec working.. - Lia - 22.10.2009

Copied that, put it in pawno, Pawno Libary shut down


Re: I cannot get my /spec working.. - Jason_Borne420 - 22.10.2009

Im sorry, i forgot a bracket, try this


Code:
if(strcmp(cmd,"/spec",true)==0)
{
  tmp = strtok(cmdtext, idx);
  if(!strlen(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /spec (id)");
  return 1;
  }
  if(!IsNumeric(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /spec (id) ID Must be a number");
  return 1;
  }
  if(strval(tmp) == playerid) {
  SendClientMessage(playerid, COLOR_ERROR, "You cannot spec yourself!");
  return 1;
  }
  giveplayerid = strval(tmp);
  if(!IsPlayerConnected(giveplayerid)) {
  format(string, sizeof(string), "ID (%d) Is not an active player",giveplayerid);
  SendClientMessage(playerid, COLOR_ERROR, string);
  return 1;
  }
	TogglePlayerSpectating(playerid, 1);
  SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(giveplayerid));
  SetPlayerInterior(playerid,GetPlayerInterior(giveplayerid));
	if (IsPlayerInAnyVehicle(giveplayerid)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
	else PlayerSpectatePlayer(playerid, giveplayerid);
	return 1;
	}