Command Question
#1

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.
Reply
#2

You need to have it without the spaces.
Reply
#3

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
Reply
#4

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;
}
Reply
#5

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.
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)