Get number from string
#1

Код:
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?
Reply
#2

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

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)