Command
#1

Hello guys, I want Adding Parameters Within Parameters!

my code;
Код:
COMMAND:give(playerid, params[])
{
	new option[10];

	if(sscanf(params, "s[10]", option)) return SendClientMessage(playerid, 0xff0000ff, "USAGE: /give [money | weapon]");

	if(!strcmp(option, "money", true))
	{
 		new TargetID,
   			Cash;

	    if(sscanf(params, "ui", TargetID, Cash)) return SendClientMessage(playerid, 0xff0000ff, "USAGE: /give money [PlayerID] [Cash]");
	    {
	        if(TargetID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xff0000ff, "Invalid Player ID!");

			if(GetPlayerMoney(playerid) < Cash) return SendClientMessage(playerid, 0xff0000ff, "You do not have that much money!");

			new paystring[128],
				paidstring[128],
				player[MAX_PLAYER_NAME],
				target[MAX_PLAYER_NAME];

			GetPlayerName(playerid, player, sizeof(player));
			GetPlayerName(TargetID, target, sizeof(target));
			format(paystring, sizeof(paystring), "You have given $%i to %s.", Cash, target);
			format(paidstring, sizeof(paidstring), "%s has paid you %i.", player, Cash);
			SendClientMessage(playerid, 0xff0000ff, paystring);
			SendClientMessage(TargetID, 0xff0000ff, paidstring);
			GivePlayerMoney(playerid, -Cash);
			GivePlayerMoney(TargetID, Cash);
			return 1;
		}
	}

	if(!strcmp(option, "weapon", true))
	{
	    new TargetID;

	    if(sscanf(params, "u", TargetID)) return SendClientMessage(playerid, 0xff0000ff, "USAGE: /give weapon [PlayerID]");
	    {
	        if(TargetID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xff0000ff, "Invalid Player ID!");
	        // Your own weapon code here.
	    	return 1;
		}
	}
	return 1;
}
it provides no return
Reply
#2

Whats problem?
Reply
#3

code is doesn't working
Reply
#4

Please describe your problem more in detail. What is a use case example for your command? What do you expect the player to enter? What does the command fail to do right now?
Reply
#5

I write /give (playerid) (amount) it provides no return
Reply
#6

PHP код:
COMMAND:give(playeridparams[])
{
    new 
option[15];
    new 
TargetID,Cash;
    if(
sscanf(params"s[15]"option)) return SendClientMessage(playerid0xff0000ff"USAGE: /give [money | weapon]");
    if(
TargetID == INVALID_PLAYER_ID)
        return 
SendClientMessage(playerid,-1,"Player not connected.");
    if(!
strcmp(option"money"true))
    {
            if(
GetPlayerMoney(playerid) < Cash) return SendClientMessage(playerid0xff0000ff"You do not have that much money!");
            new 
paystring[128],
                
paidstring[128],
                
player[MAX_PLAYER_NAME],
                
target[MAX_PLAYER_NAME];
            
GetPlayerName(playeridplayersizeof(player));
            
GetPlayerName(TargetIDtargetsizeof(target));
            
format(paystringsizeof(paystring), "You have given $%i to %s."Cashtarget);
            
format(paidstringsizeof(paidstring), "%s has paid you %i."playerCash);
            
SendClientMessage(playerid0xff0000ffpaystring);
            
SendClientMessage(TargetID0xff0000ffpaidstring);
            
GivePlayerMoney(playerid, -Cash);
            
GivePlayerMoney(TargetIDCash);
            return 
1;
    }
    else if(!
strcmp(option"weapon"true))
    {
    
// Your own weapon code here.
       
return 1;
    }
    else
        
SendClientMessage(playerid0xff0000ff"USAGE: /give [money | weapon]");
    return 
1;

I dont know the solution, but test this.
Reply
#7

Basically you first check if they typed "money" or "wepon", then you check again the command params with "ui", which is always false, because there's "money" or "weapon after params
Reply
#8

Quote:
Originally Posted by dani18
Посмотреть сообщение
PHP код:
COMMAND:give(playeridparams[])
{
    new 
option[15];
    new 
TargetID,Cash;
    if(
sscanf(params"s[15]"option)) return SendClientMessage(playerid0xff0000ff"USAGE: /give [money | weapon]");
    if(
TargetID == INVALID_PLAYER_ID)
        return 
SendClientMessage(playerid,-1,"Player not connected.");
    if(!
strcmp(option"money"true))
    {
            if(
GetPlayerMoney(playerid) < Cash) return SendClientMessage(playerid0xff0000ff"You do not have that much money!");
            new 
paystring[128],
                
paidstring[128],
                
player[MAX_PLAYER_NAME],
                
target[MAX_PLAYER_NAME];
            
GetPlayerName(playeridplayersizeof(player));
            
GetPlayerName(TargetIDtargetsizeof(target));
            
format(paystringsizeof(paystring), "You have given $%i to %s."Cashtarget);
            
format(paidstringsizeof(paidstring), "%s has paid you %i."playerCash);
            
SendClientMessage(playerid0xff0000ffpaystring);
            
SendClientMessage(TargetID0xff0000ffpaidstring);
            
GivePlayerMoney(playerid, -Cash);
            
GivePlayerMoney(TargetIDCash);
            return 
1;
    }
    else if(!
strcmp(option"weapon"true))
    {
    
// Your own weapon code here.
       
return 1;
    }
    else
        
SendClientMessage(playerid0xff0000ff"USAGE: /give [money | weapon]");
    return 
1;

I dont know the solution, but test this.
yes, this is working but this is not what I want
Reply
#9

Guys, my problem this is;
I take parameter with !strcmp. If parameter = money after take new parameter.
this does not work
Reply
#10

do you have to help me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)