SA-MP Forums Archive
Command Help - 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: Command Help (/showthread.php?tid=205421)



Command Help - wilko1995 - 01.01.2011

Hi, my command doesnt work when i try it in the SAMP Server... it comes back "Error: Unknown command"

Код:
dcmd_land(playerid, params[])
{
	new ap, string[40], pName[MAX_PLAYER_NAME], lv, ls, sf;
	if(sscanf(params, "s", ap)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /land [ls/lv/sf]");
	{
	 sf = strval("sf");
	 ls = strval("ls");
	 lv = strval("lv");
	 GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	 if(ap == lv)
	 {
	        format(string, sizeof(string), "%d is landing at Las Venturas International Airport, Clear the Runway", pName);
		SendClientMessageToAll(0xFF00FFAA, string);
		return 1;
	 }
	 else if (ap == ls)
	{
		format(string, sizeof(string), "%d is landing at Los Santos Airport, Clear the Runway", pName);
		SendClientMessageToAll(0xFF00FFAA, string);
		return 1;
	}
	else if (ap == sf)
	{
		format(string, sizeof(string), "%d is landing at San Fierro/Easter Basin Airport, Clear the Runway", pName);
		SendClientMessageToAll(0xFF00FFAA, string);
		return 1;
	}
     }
     return 0;
}
Thats the code im haveing trouble with

Thanks
Wilko


Re: Command Help - Grim_ - 01.01.2011

Why would you use sscanf with just one parameter?
pawn Код:
dcmd_land(playerid, params[])
{
   new ap, name[ MAX_PLAYER_NAME ];
   if( isnull( params ) ) return SendClientMessage( playerid, 0xFF0000AA, "USAGE: /land [ls/lv/sf]" );
   GetPlayerName( playerid, name, MAX_PLAYER_NAME );
   if( !strcmp( params, "ls", true ) )
   {
      // Landing at los santos
   }
   else if( !strcmp( params, "lv", true ) )
   {
      // Landing at las venturas
   }
   else if( !strcmp( params, "sf", true ) )
   {
      // Landing as san fierror
   }
   return 1;
}
And the original problem is caused because you return 0 at the end of command. You only need to do that in OnPlayerCommandText callback.


Re: Command Help - wilko1995 - 01.01.2011

ok... im new at scripting commands but i see what your getting at... its all a learning experience right? Thanks for your help.

EDIT: I tried your code to see if it worked, but when i compiled it, it comes with an error: Undefined Symbol: isnull


Re: Command Help - Mean - 01.01.2011

You need to define Isnull
pawn Код:
#define isnull(%1) \
            ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))



Re: Command Help - wilko1995 - 01.01.2011

Ive finished it, thanks for everyones help