Making many commands in one command
#1

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

Код:
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;
}
Reply
#3

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)