Get number from string - 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)
+--- Thread: Get number from string (
/showthread.php?tid=657016)
Get number from string -
3417512908 - 30.07.2018
Код:
CMD:wdcs(playerid)
{
new pDialog[999];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid,PlayerName,MAX_PLAYER_NAME);
strcat(pDialog, "ID/名称\t命令\n", sizeof(pDialog));
for(new i = 1; i < MAX_TELEPORT; i++)
{
if(!strcmp(TeleportData[i][Owner], PlayerName, false) && !isnull(TeleportData[i][Owner]))
{
new string[60];
format(string, sizeof(string), "[ID%d]%s\t%s\n",TeleportData[i][ID],TeleportData[i][Name],TeleportData[i][CMD]);
strcat(pDialog, string, sizeof(pDialog));
}
}
strcat(pDialog, "{A9C4E4}创建一个传送", sizeof(pDialog));
ShowPlayerDialog(playerid, Dialog_MyTeleport, DIALOG_STYLE_TABLIST_HEADERS, "我的传送", pDialog, "选择","关闭");
return 1;
}
A dynamic dialog.I just want to get '%d'(TeleportData[i][ID]) from inputtext.Instead of all string
How to do it?
Re: Get number from string -
Rufio - 30.07.2018
https://sampwiki.blast.hk/wiki/Strval
Create a new string that only has the integer value and use strval. Something like this;
new string[20];
format(string, sizeof(string), "%d", TeleportData[i][ID]);
new integervalue = strval(string);
Change the string size to fit your needs.
integervalue will hold the number.
Re: Get number from string -
3417512908 - 30.07.2018
Quote:
Originally Posted by Rufio
|
No you understand it wrong.I want to remove string from "]" to end line,and remove "ID" and "[".Finally I can get the number.
HOW TO DO IT
Re: Get number from string -
Rufio - 30.07.2018
Quote:
Originally Posted by 3417512908
No you understand it wrong.I want to remove string from "]" to end line,and remove "ID" and "[".Finally I can get the number.
HOW TO DO IT
|
Yes I understood it wrong first, check my edit. It should give you an idea.