SA-MP Forums Archive
Use 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Use command (/showthread.php?tid=130211)



Use command - Torran - 25.02.2010

pawn Код:
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 Код:
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 Код:
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?


Re: Use command - Keeboo13 - 26.02.2010

wat does the command supose to do because ill remake it...


Re: Use command - Torran - 26.02.2010

No, I dont want it remaking, I just want that code fixing, So it works


Re: Use command - bajskorv123 - 26.02.2010

Torran thought we already had discussed this

When using zcmd, use:
pawn Код:
if(isnull(params))
instead of
pawn Код:
if(strlen(params))



Re: Use command - Torran - 26.02.2010

And how would i get it to say a message if a player types lets say /use lalala and it ses, invalid item?


Re: Use command - notime - 26.02.2010

Код:
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