SA-MP Forums Archive
[HELP] Problem with a small Command - 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] Problem with a small Command (/showthread.php?tid=111907)



[HELP] Problem with a small Command - FreddeN - 04.12.2009

Код:
	if (strcmp(cmd, "/advert", true) ==0 || strcmp(cmd, "/ad", true) ==0)
	{
	  if(PlayerToPoint(15.0,playerid,1788.4279,-1297.8048,13.3750))
	  {
		  new name1[256];
		  GetPlayerName(playerid,name1,sizeof(name1));
		  if ((strlen(cmdtext) >= 3)&&(strlen(cmdtext) <= 7))
			{
			SendClientMessage(playerid,0xC0C0C0FF, "	USAGE: /ad(vert) [text]"); return 1;
			}
			format(string,sizeof(string),"Advertisement: %s, contact %s.",cmdtext[3],name1);
			SendClientMessageToAll(0x00FF00FF,string);
			return 1;
		}
	}
It would be great if you could help me with "else" so it send a warning message if I'm in wrong position.

Thanks


Re: [HELP] Problem with a small Command - Zamaroht - 04.12.2009

You mean this?

Код:
	if (strcmp(cmd, "/advert", true) ==0 || strcmp(cmd, "/ad", true) ==0)
	{
	  if(PlayerToPoint(15.0,playerid,1788.4279,-1297.8048,13.3750))
	  {
		  new name1[256];
		  GetPlayerName(playerid,name1,sizeof(name1));
		  if ((strlen(cmdtext) >= 3)&&(strlen(cmdtext) <= 7))
			{
			SendClientMessage(playerid,0xC0C0C0FF, "	USAGE: /ad(vert) [text]"); return 1;
			}
			format(string,sizeof(string),"Advertisement: %s, contact %s.",cmdtext[3],name1);
			SendClientMessageToAll(0x00FF00FF,string);
			return 1;
		}
		else
		{
			SendClientMessage(playerid,0xC0C0C0FF, "	You aren't in the advert place!"); 
			return 1;
		}
	}



Re: [HELP] Problem with a small Command - FreddeN - 04.12.2009

Quote:
Originally Posted by Zamaroht
You mean this?

Код:
	if (strcmp(cmd, "/advert", true) ==0 || strcmp(cmd, "/ad", true) ==0)
	{
	  if(PlayerToPoint(15.0,playerid,1788.4279,-1297.8048,13.3750))
	  {
		  new name1[256];
		  GetPlayerName(playerid,name1,sizeof(name1));
		  if ((strlen(cmdtext) >= 3)&&(strlen(cmdtext) <= 7))
			{
			SendClientMessage(playerid,0xC0C0C0FF, "	USAGE: /ad(vert) [text]"); return 1;
			}
			format(string,sizeof(string),"Advertisement: %s, contact %s.",cmdtext[3],name1);
			SendClientMessageToAll(0x00FF00FF,string);
			return 1;
		}
		else
		{
			SendClientMessage(playerid,0xC0C0C0FF, "	You aren't in the advert place!"); 
			return 1;
		}
	}
Yepp, that is what I was looking for but, when I try it out it just tells me Unknown Command...

Here is how the command looks like:

Код:
	if (strcmp(cmd, "/advert", true) ==0 || strcmp(cmd, "/ad", true) ==0)
	{
	  if(PlayerToPoint(15.0,playerid,1788.4279,-1297.8048,13.3750))
	  {
		  new name1[256];
		  GetPlayerName(playerid,name1,sizeof(name1));
		  if ((strlen(cmdtext) >= 3)&&(strlen(cmdtext) <= 7))
			{
			SendClientMessage(playerid,0xC0C0C0FF, "	USAGE: /ad(vert) [text]"); return 1;
			}
			format(string,sizeof(string),"Advertisement: %s, contact %s.",cmdtext[3],name1);
			SendClientMessageToAll(0x00FF00FF,string);
			return 1;
		}
	}
	else
	{
	  SendClientMessage(playerid,0xFFFFFFFF, "You are not at the San Andreas News building.");
	  SendClientMessage(playerid,0x00FF00FF, "	HINT: A marker has been placed on your map.");
	  return 1;
	}
}



Re: [HELP] Problem with a small Command - Zamaroht - 04.12.2009

I'm guessing that's inside OnPlayerCommandText right? Could you show me the full callback?


Re: [HELP] Problem with a small Command - FreddeN - 04.12.2009

Quote:
Originally Posted by Zamaroht
I'm guessing that's inside OnPlayerCommandText right? Could you show me the full callback?
Never mind, thanks, I forgot to delete a bracket, now it works

Thanks