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

Description
I wanna make a "moto" system, for example someone does /setmoto [TEXT], and he will have a 3D text label with that text attached to him, so I need a /setmoto command, that sets the "moto[MAX_PLAYERS];" variable to the text entered, how to do that?

I apreciate every help

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

Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)