SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/01/2018, 04:36 PM   #1
kadirbnm
Little Clucker
 
Join Date: Jan 2017
Posts: 17
Reputation: 0
Default Command

Hello guys, I want Adding Parameters Within Parameters!

my code;
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
kadirbnm is online now   Reply With Quote
Old 13/01/2018, 04:43 PM   #2
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 95
Reputation: 10
Default Re: Command

Whats problem?
Osamakurdi is offline   Reply With Quote
Old 13/01/2018, 04:47 PM   #3
kadirbnm
Little Clucker
 
Join Date: Jan 2017
Posts: 17
Reputation: 0
Default Re: Command

code is doesn't working
kadirbnm is online now   Reply With Quote
Old 13/01/2018, 05:31 PM   #4
Manyula
Huge Clucker
 
Join Date: Jan 2012
Location: Germany
Posts: 271
Reputation: 27
Default Re: Command

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?
Manyula is offline   Reply With Quote
Old 13/01/2018, 09:26 PM   #5
kadirbnm
Little Clucker
 
Join Date: Jan 2017
Posts: 17
Reputation: 0
Default Re: Command

I write /give (playerid) (amount) it provides no return
kadirbnm is online now   Reply With Quote
Old 13/01/2018, 10:39 PM   #6
dani18
Little Clucker
 
Join Date: Dec 2017
Posts: 14
Reputation: 1
Default Re: Command

PHP Code:
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.
dani18 is offline   Reply With Quote
Old 13/01/2018, 10:45 PM   #7
Lucases
Huge Clucker
 
Join Date: Jul 2017
Posts: 225
Reputation: 8
Default Re: Command

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
Lucases is offline   Reply With Quote
Old 14/01/2018, 06:03 PM   #8
kadirbnm
Little Clucker
 
Join Date: Jan 2017
Posts: 17
Reputation: 0
Default Re: Command

Quote:
Originally Posted by dani18 View Post
PHP Code:
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
kadirbnm is online now   Reply With Quote
Old 16/01/2018, 06:51 AM   #9
kadirbnm
Little Clucker
 
Join Date: Jan 2017
Posts: 17
Reputation: 0
Default Re: Command

Guys, my problem this is;
I take parameter with !strcmp. If parameter = money after take new parameter.
this does not work
kadirbnm is online now   Reply With Quote
Old 16/01/2018, 08:37 AM   #10
kadirbnm
Little Clucker
 
Join Date: Jan 2017
Posts: 17
Reputation: 0
Default Re: Command

do you have to help me
kadirbnm is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] mcmd Command Engine - Plugin based command processing Mellnik Plugin Development 108 08/05/2016 02:55 PM
Help with YCMD proces command and problem with "Server:Unknown command JoDe Scripting Help 0 10/06/2015 07:05 PM
i had this command in my gamemode, when i type this in game,it tells server unknow command? Chrisli520 Scripting Help 3 24/11/2013 11:02 AM
Executed ZCMD command returns SERVER: Unknown Command SexTourist Scripting Help 12 03/01/2012 04:38 PM
Slap command returns an Unknown Command when player is not connected HydraX Help Archive 16 01/08/2011 06:19 AM


All times are GMT. The time now is 12:34 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.