/blindfold
#17

Quote:
Originally Posted by Saorp
Код:
//--------------------[BlindFold]------------------------------------------------------------------------
  if(strcmp(cmd, "/blindfold", true) == 0)
  {
    if(IsPlayerConnected(playerid))

	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp))
	  {
		SendClientMessage(playerid, COLOR_GRAD1, "USAGE: //blindfold [player name]");
		return 1;
        }
    SetPlayerCameraPos(playerid, -833.5241,-1358.8575,86.9054);
    SetPlayerCameraLookAt(playerid, -830.8118,-1360.3612,87.0289);
    return 1;
    }

  if(strcmp(cmd, "/unblindfold", true) == 0)
  {
	 if(IsPlayerConnected(playerid))

	 tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
	 {
        SendClientMessage(playerid, COLOR_GRAD1, "USAGE: //unblindfold [player name]");
		 return 1;
        }
  SetCameraBehindPlayer(playerid);
  return 1;
 }
Firstly, you are performing an unnecessary check, seeing if playerid is connected. If he/she just typed a command, of course they are connected. Secondly, your check doesn't act how you would like. If you do not place braces after the 'if()', it will only take the first single statement: "tmp = strtok(cmdtext, idx);"

Try this:
[pawn]
// Using
pawn Код:
tags!

if(strcmp(cmd, "/blindfold", true) == 0) // '/blindfold'
{
  tmp = strtok(cmdtext, idx); // Making 'tmp' hold the id. Remains as a string.
  if(!strlen(tmp)) // If the length of 'tmp' is 0:
    return SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /blindfold [player id]"); // Send the message AND end the command here (thus avoiding the 'SERVER: Unknown command.' message).
  new id = strval(tmp); // New integer which holds the value of 'tmp'. EG: /blindfold 6. 'id' would become 6.
  if(IsPlayerConnected(id)) // If the id is connected:
  { // We are using more than a single statement, so we use braces.
    SetPlayerCameraPos(id, -833.5241,-1358.8575,86.9054); // Setting the camera position for 'id'.
    return SetPlayerCameraLookAt(id, -830.8118,-1360.3612,87.0289); // Setting the camera to look at X for 'id' AND end the command here (thus avoiding the 'SERVER: Unknown command.' message).
  } // Closing brace for the id check.
}

if(strcmp(cmd, "/unblindfold", true) == 0) // '/unblindfold'
{
  tmp = strtok(cmdtext, idx); // Making 'tmp' hold the id. Remains as a string.
  if(!strlen(tmp)) // If the length of 'tmp' is 0:
    return SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /unblindfold [player id]"); // Send the message AND end the command here (thus avoiding the 'SERVER: Unknown command.' message).
  new id = strval(tmp); // New integer which holds the value of 'tmp'. EG: /blindfold 6. 'id' would become 6.
  if(IsPlayerConnected(id)) // If the id is connected:
    return SetCameraBehindPlayer(id); // Set the camera of 'id' behind them, as well as ending the command.
  return 1; // If the id was not connected, add an else statement here. This will just stop the 'SERVER: Unknown command.' message.
 }
This will work, and if you are still wanting names to work (EG: /blindfold Cueball), head on over to the Useful Functions topic (search for it), and then search for a name checker (EG: GetPlayerID() ). Then simply assign 'id' to the function:
pawn Код:
new id = GetPlayerID(tmp);
This should do the trick

~Cueball~
Reply


Messages In This Thread
/blindfold - by Pujan2008 - 03.04.2008, 07:21
Re: /blindfold - by MidoBan - 03.04.2008, 07:37
Re: /blindfold - by yom - 03.04.2008, 07:38
Re: /blindfold - by MidoBan - 03.04.2008, 07:42
Re: /blindfold - by swayam - 03.04.2008, 08:23
Re: /blindfold - by MidoBan - 03.04.2008, 08:29
Re: /blindfold - by swayam - 03.04.2008, 09:36
Re: /blindfold - by MidoBan - 03.04.2008, 09:48
Re: /blindfold - by cmg4life - 03.04.2008, 11:16
Re: /blindfold - by Exuro - 03.04.2008, 13:57
Re: /blindfold - by Sandra18[NL] - 03.04.2008, 14:08
Re: /blindfold - by Exuro - 03.04.2008, 14:28
Re: /blindfold - by Tr1viUm - 03.04.2008, 14:34
Re: /blindfold - by Carlos_Leone - 03.04.2008, 14:44
Re: /blindfold - by Saorp - 07.04.2008, 04:43
Re: /blindfold - by Joe Staff - 07.04.2008, 05:17
Re: /blindfold - by Cueball - 07.04.2008, 05:22
Re: /blindfold - by Joe Staff - 07.04.2008, 05:27
Re: /blindfold - by Giacomand - 07.04.2008, 06:20
Re: /blindfold - by Saorp - 08.04.2008, 04:54
Re: /blindfold - by Cueball - 08.04.2008, 05:42
Re: /blindfold - by Saorp - 08.04.2008, 19:15
Re: /blindfold - by kavkazian - 09.04.2008, 20:07
Re: /blindfold - by Pujan2008 - 09.04.2008, 21:08
Re: /blindfold - by Pghpunkid - 10.04.2008, 00:28
Re: /blindfold - by kavkazian - 10.04.2008, 09:19
Re: /blindfold - by yom - 10.04.2008, 09:22
Re: /blindfold - by kavkazian - 10.04.2008, 10:11
Re: /blindfold - by Cactus - 10.04.2008, 10:34
Re: /blindfold - by yom - 10.04.2008, 11:18
Re: /blindfold - by Joe Staff - 10.04.2008, 12:12
Re: /blindfold - by yom - 10.04.2008, 12:16
Re: /blindfold - by Joe Staff - 10.04.2008, 12:21
Re: /blindfold - by kavkazian - 10.04.2008, 15:28
Re: /blindfold - by Qeux - 11.04.2009, 16:01
Re: /blindfold - by MenaceX^ - 11.04.2009, 16:28

Forum Jump:


Users browsing this thread: 7 Guest(s)