SA-MP Forums Archive
[HowTo?] Set a variable's value to the text entered at the 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: [HowTo?] Set a variable's value to the text entered at the command (/showthread.php?tid=108390)



[HowTo?] Set a variable's value to the text entered at the command - JonyAvati - 13.11.2009

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




Re: [HowTo?] Set a variable's value to the text entered at the command - Daren_Jacobson - 13.11.2009

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;
}



Re: [HowTo?] Set a variable's value to the text entered at the command - JonyAvati - 13.11.2009

Thank you