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



Command Question - Zeromanster - 17.11.2009

How can i make so that i can have spaces like this:

pawn Код:
if(strcmp(food,"hamburger and fries",true) == 0)
The command would be /buyfood hamburger and fries

But it doesn't seem to work with spaces, please help thank you.


Re: Command Question - darkrider366 - 17.11.2009

You need to have it without the spaces.



Re: Command Question - (Jeff) - 17.11.2009

Quote:
Originally Posted by zєяσмαиѕтєя
How can i make so that i can have spaces like this:

pawn Код:
if(strcmp(food,"hamburger and fries",true) == 0)
The command would be /buyfood hamburger and fries

But it doesn't seem to work with spaces, please help thank you.
why not just use a dialog or a menu :P


Re: Command Question - LarzI - 17.11.2009

example:

pawn Код:
if(!strcmp(cmdtext, "/buyfood", true))
{
   new food[128];
   format(food, 128, "%s", cmdtext[9]);
   if(cmdtext[9] == 32 && cmdtext[8] != EOS)
     return SendClientMessage(playerid, 0xFF0000AA, "USAGE: \"/buyfood [food-name]\"");
   if(!strcmp(food, "hamburger and fries", true))
   {
      //Stuff
   }
   //more statements if you want, which you probally do.
   return true;
}



Re: Command Question - Zeromanster - 17.11.2009

Quote:
Originally Posted by lrZ^ aka LarzI
example:

pawn Код:
if(!strcmp(cmdtext, "/buyfood", true))
{
   new food[128];
   format(food, 128, "%s", cmdtext[9]);
   if(cmdtext[9] == 32 && cmdtext[8] != EOS)
     return SendClientMessage(playerid, 0xFF0000AA, "USAGE: \"/buyfood [food-name]\"");
   if(!strcmp(food, "hamburger and fries", true))
   {
      //Stuff
   }
   //more statements if you want, which you probally do.
   return true;
}
Could somebody show me how to this with sscanf to ? Thank you.


Re: Command Question - LarzI - 18.11.2009

Finally someone who uses dcmd : >

pawn Код:
dcmd_buyfood(playerid, params[])
{
   new food[128];
   if(sscanf(params, "s", food)
     return SendClientMessage(playerid, 0xFF0000AA, "USAGE: \"/buyfood [food-name]\"");
   if(!strcmp(params, "hamburger and fries", true))
   {
      //Stuff
   }
   //more statements if you want, which you probally do.
   return true;
}
There you go