SA-MP Forums Archive
Making many commands in one 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)
+--- Thread: Making many commands in one command (/showthread.php?tid=581967)



Making many commands in one command - Pawnify - 16.07.2015

Hi, I'm trying to turn these commands /takecrate, /deploycrate. Into /crate take/deploy/others

I know it's something to do with sscanf maybe. I just can't put my finger on it. Would you use the params to check if thats the ending of the command they are typing?
Код:
COMMAND:crate(playerid, params[])
{
	if(SpawnedIn[playerid] == 1 && LoggedIn[playerid] == 1)
	{
	    if(params == "take")
	    {

	    }
	    
	    if(params == "deploy")
	    {

	    }
	}
	return 1;
}



Re: Making many commands in one command - rymax99 - 16.07.2015

Код:
CMD:crate(playerid, params[])
{
	if(isnull(params))
	{
		return SendClientMessage(playerid, -1, "/crate [deploy, take, others]");
	}
	if(!strcmp(params, "take", true))
	{
	
	}
	else if(!strcmp(params, "deploy", true))
	{
		
	}
	else if(!strcmp(params, "others", true))
	{
	
	}
	return 1;
}



Re: Making many commands in one command - Pawnify - 16.07.2015

Quote:
Originally Posted by rymax99
Посмотреть сообщение
Код:
CMD:crate(playerid, params[])
{
	if(isnull(params))
	{
		return SendClientMessage(playerid, -1, "/crate [deploy, take, others]");
	}
	if(!strcmp(params, "take", true))
	{
	
	}
	else if(!strcmp(params, "deploy", true))
	{
		
	}
	else if(!strcmp(params, "others", true))
	{
	
	}
	return 1;
}
Is this the most efficient way of doing this? I want the most efficient way.


Re: Making many commands in one command - rymax99 - 16.07.2015

Quote:
Originally Posted by Pawnify
Посмотреть сообщение
Is this the most efficient way of doing this? I want the most efficient way.
The parameters of the command is a string, you're going to have to search in the string, so yes. To make it the most efficient, make sure to utilize 'else if' statements so that when one if statement is met it doesn't continue onto the ones that follow that.


Re: Making many commands in one command - Pawnify - 16.07.2015

Quote:
Originally Posted by rymax99
Посмотреть сообщение
The parameters of the command is a string, you're going to have to search in the string, so yes. To make it the most efficient, make sure to utilize 'else if' statements so that when one if statement is met it doesn't continue onto the ones that follow that.
Thank you very much for your help +rep