Sscanf cmd
#5

NVM, I fixed it on this way:

Код:
COMMAND:trunk(playerid, params[])
{
	new action[3][16],amount;
	sscanf(params,"s[16]s[16]s[16]d",action[0],action[1],action[2],amount);
	if(strlen(action[0]) && strcmp("store",action[0], true ) == 0)
	{
	    for(new slot = 0; slot < 5; slot++) if(slot == 0) break;
		if(strlen(action[1]) && strcmp("weapon",action[1], true ) == 0)
		{
	    }
	    if(strlen(action[1]) && strcmp("briefcase",action[1], true ) == 0)
		{
	    }
	    if(strlen(action[1]) && strcmp("materials",action[1], true ) == 0)
		{
		    if(strlen(action[2]) && strcmp("A",action[2], true ) == 0)
		    {
		        if(amount < 1 || amount > 50) return SendPlayerError(playerid,"Usage: /trunk store materials A (amount > 0 < 50)");
		        
		    }
		    else if(strlen(action[2]) && strcmp("B",action[2], true ) == 0)
		    {
                if(amount < 1 || amount > 50) return SendPlayerError(playerid,"Usage: /trunk store materials D (amount > 0 < 50)");
                
		    }
		    else if(strlen(action[2]) && strcmp("C",action[2], true ) == 0)
		    {
                if(amount < 1 || amount > 50) return SendPlayerError(playerid,"Usage: /trunk store materials C (amount > 0 < 50)");
                
		    }
		    else if(strlen(action[2]) && strcmp("D",action[2], true ) == 0)
		    {
                if(amount < 1 || amount > 50) return SendPlayerError(playerid,"Usage: /trunk store materials D (amount > 0 < 50)");
                
		    }
		    else return SendPlayerError(playerid,"Usage: /trunk store materials (A,B,C,D)");
	    }
	    if(strlen(action[1]) && strcmp("drugs",action[1], true ) == 0)
		{
		    if(strlen(action[2]) && strcmp("A",action[2], true ) == 0)
		    {
		        if(amount < 1 || amount > 50) return SendPlayerError(playerid,"Usage: /trunk store drugs A (amount > 0 < 50)");

		    }
		    else if(strlen(action[2]) && strcmp("B",action[2], true ) == 0)
		    {
                if(amount < 1 || amount > 50) return SendPlayerError(playerid,"Usage: /trunk store drugs D (amount > 0 < 50)");

		    }
		    else if(strlen(action[2]) && strcmp("C",action[2], true ) == 0)
		    {
                if(amount < 1 || amount > 50) return SendPlayerError(playerid,"Usage: /trunk store drugs C (amount > 0 < 50)");

		    }
		    else return SendPlayerError(playerid,"Usage: /trunk store drugs (A,B,C)");
	    }
	    else return SendPlayerError(playerid,"Usage: /trunk store (weapon,briefcase,materials,drugs).");
	}
 	if(strlen(action[0]) && strcmp("take",action[0], true ) == 0)
	{
	    new slot;
	  	if(sscanf(action[1],"%d",slot)) return SendPlayerError(playerid,"Usage: /trunk take (slot 0,1,2,3,4).");
	  	if(slot < 0 && slot > 4) return SendPlayerError(playerid,"Usage: /trunk take (slot 0,1,2,3,4).");
	}
	else if(strlen(action[0]) && strcmp("open",action[0], true ) == 0)
	{


	}
	else if(strlen(action[0]) && strcmp("close",action[0], true ) == 0)
	{



	}
	else return SendPlayerError(playerid,"Usage: /trunk (open - close - search - take - store)");
	return 1;
}
Reply


Messages In This Thread
Sscanf cmd - by Roel - 06.09.2012, 17:23
Re: Sscanf cmd - by MarkoN - 06.09.2012, 17:29
Re: Sscanf cmd - by HuSs3n - 06.09.2012, 17:31
Re: Sscanf cmd - by Roel - 06.09.2012, 17:43
Re: Sscanf cmd - by Roel - 06.09.2012, 17:54

Forum Jump:


Users browsing this thread: 1 Guest(s)