[HowTo?] Set a variable's value to the text entered at the command
#2

it is spelled motto, but use sscanf
(traditional)
pawn Код:
OnPlayerCommandText(playerid, cmdtext[])
{
  if (!strcmp(cmdtext, "/setmotto", true, 9))
  {
    new com[34], motto[24];
    if (sscanf(cmdtext, "ss", com, motto)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /setmotto [motto]");
    else
    {
//3d text label stuff here, the motto they want is stored in the variable motto
    }
    return 1;
  }
  return 0;
}
(uncommon)
pawn Код:
OnPlayerCommandText(playerid, cmdtext[])
{
  new com[128], params[128];
  sscanf(cmdtext, "sz", com, params);
  if (!strcmp(com, "/setmotto", true, 9))
  {
    new motto[24];
    if (sscanf(params, "s", motto)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /setmotto [motto]");
    else
    {
//3d text label stuff here, the motto they want is stored in the variable motto
    }
    return 1;
  }
  return 0;
}
(dcmd)
pawn Код:
dcmd_setmotto(playerid, params[])
{
  new motto[24];
  if (sscanf(params, "s", motto)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /setmotto [motto]");
  else
  {
//3d text label stuff here, the motto they want is stored in the variable motto
  }
  return 1;
}
(zcmd)
pawn Код:
CMD:setmotto(playerid, params[])
{
  new motto[24];
  if (sscanf(params, "s", motto)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /setmotto [motto]"); //(this goes for all of the sscanf's) if you want the motto to be forced as 1 word only put a space after the s ("s ")
  else
  {
//3d text label stuff here, the motto they want is stored in the variable motto
  }
  return 1;
}
Reply


Messages In This Thread
[HowTo?] Set a variable's value to the text entered at the command - by JonyAvati - 13.11.2009, 21:18
Re: [HowTo?] Set a variable's value to the text entered at the command - by Daren_Jacobson - 13.11.2009, 22:50
Re: [HowTo?] Set a variable's value to the text entered at the command - by JonyAvati - 13.11.2009, 23:01

Forum Jump:


Users browsing this thread: 1 Guest(s)