Command Help
#1

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
Reply
#2

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.
Reply
#3

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
Reply
#4

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

Ive finished it, thanks for everyones help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)