SA-MP Forums Archive
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: Command (/showthread.php?tid=647944)



Command - kadirbnm - 13.01.2018

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


Re: Command - Osamakurdi - 13.01.2018

Whats problem?


Re: Command - kadirbnm - 13.01.2018

code is doesn't working


Re: Command - Manyula - 13.01.2018

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?


Re: Command - kadirbnm - 13.01.2018

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


Re: Command - dani18 - 13.01.2018

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.


Re: Command - Lucases - 13.01.2018

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


Re: Command - kadirbnm - 14.01.2018

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


Re: Command - kadirbnm - 16.01.2018

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


Re: Command - kadirbnm - 16.01.2018

do you have to help me