SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 25/02/2010, 08:12 PM   #1
Torran
High-roller
 
Join Date: Jan 2010
Posts: 1,782
Reputation: 1
Default Use command

pawn Code:
CMD:use(playerid, params[])
{
    if(strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /use [Item]");
    else
    {
        if(strcmp(params,"medikit",true) == 0)
        {
          if(PlayerInfo[playerid][Medikit] == 0) SendClientMessage(playerid, COLOR_RED, "You dont have a medikit, Buy one from a local shop");
          else
          {
                if(PlayerInfo[playerid][Medikit] == 1)
                {
                  new string[300];
                  PlayerInfo[playerid][Medikit] = 0;
                  format(string, sizeof(string), "Medikit set to %d", PlayerInfo[playerid][Medikit]);
                  SendClientMessage(playerid, COLOR_ORANGE, string);
                }
                else if(PlayerInfo[playerid][Medikit] == 2)
                {
                  new string[300];
                  PlayerInfo[playerid][Medikit] = 1;
                  format(string, sizeof(string), "Medikit set to %d", PlayerInfo[playerid][Medikit]);
                  SendClientMessage(playerid, COLOR_ORANGE, string);
            }
            }
        }
    }
    return 1;
}

Thats my code.. And
pawn Code:
if(strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /use [Item]");
That shows up as it should if i type /use, But if i type /use medikit, It says usage again but it shouldnt,
If i make it
pawn Code:
if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /use [Item]");
And type /use, No message appears, But if i type /use medikit, It works as it should,
Ive tried removing the return on the code but makes no difference,
Anyone know why?
Torran is offline  
Old 26/02/2010, 07:58 AM   #2
Keeboo13
Big Clucker
 
Join Date: Jan 2010
Posts: 145
Reputation: 0
Default Re: Use command

wat does the command supose to do because ill remake it...
Keeboo13 is offline  
Old 26/02/2010, 11:37 AM   #3
Torran
High-roller
 
Join Date: Jan 2010
Posts: 1,782
Reputation: 1
Default Re: Use command

No, I dont want it remaking, I just want that code fixing, So it works
Torran is offline  
Old 26/02/2010, 01:33 PM   #4
bajskorv123
Huge Clucker
 
Join Date: Sep 2009
Posts: 405
Reputation: 0
Default Re: Use command

Torran thought we already had discussed this

When using zcmd, use:
pawn Code:
if(isnull(params))
instead of
pawn Code:
if(strlen(params))
bajskorv123 is offline  
Old 26/02/2010, 01:44 PM   #5
Torran
High-roller
 
Join Date: Jan 2010
Posts: 1,782
Reputation: 1
Default Re: Use command

And how would i get it to say a message if a player types lets say /use lalala and it ses, invalid item?
Torran is offline  
Old 26/02/2010, 11:04 PM   #6
notime
Big Clucker
 
Join Date: Nov 2008
Posts: 198
Reputation: 18
Default Re: Use command

Code:
CMD:use(playerid, params[])
{
	if(strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /use [Item]");
	else
	{
		if(strcmp(params,"medikit",true) == 0)
		{
		  if(PlayerInfo[playerid][Medikit] == 0) SendClientMessage(playerid, COLOR_RED, "You dont have a medikit, Buy one from a local shop");
		  else
		  {
				if(PlayerInfo[playerid][Medikit] == 1)
				{
				  new string[300];
				  PlayerInfo[playerid][Medikit] = 0;
				  format(string, sizeof(string), "Medikit set to %d", PlayerInfo[playerid][Medikit]);
				  SendClientMessage(playerid, COLOR_ORANGE, string);
				}
				else if(PlayerInfo[playerid][Medikit] == 2)
				{
				  new string[300];
				  PlayerInfo[playerid][Medikit] = 1;
				  format(string, sizeof(string), "Medikit set to %d", PlayerInfo[playerid][Medikit]);
				  SendClientMessage(playerid, COLOR_ORANGE, string);
		    	}
			}
		}
		else return SendClientMessage(playerid, COLOR_RED,"[Error] Invalig item");
	}
	return 1;
}
that will give the message: [Error] Invalig item
__________________
notime is offline  
 

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
[Command Bugged] Each time i use /respawnallcars it says Unknown Command Rand_Omar Scripting Help 11 30/09/2012 12:35 AM
how i change wrong command (unknow command) OmarEco Help Archive 10 22/06/2010 04:09 PM
SERVER: Unknown Command when using a scripted command and it does execute! Moustafa Help Archive 6 11/06/2010 01:34 PM
Command that returns SERVER: Unknown Command. pagie1111 Help Archive 11 11/04/2010 09:55 AM
Command added but returns Unkown command hipy Help Archive 3 19/11/2009 05:11 PM


All times are GMT. The time now is 12:08 PM.


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