GetPlayerName from inputtext (listitem) -
rOps - 02.12.2017
Hello my friends.
I have one question for you, as example I have dialog (DIALOG_STYLE_LIST):
1. Nick_Name (OFFLINE)
2. Name_Nick (ONLINE)
3. One_More (OFFLINE)
and when playerid responses 1 ID listitem (2. Name_Nick (ONLINE)) I want to get from that text only his name. I know, that I must use inputtext, but it only returns all the text. So if you can help me, do it. Thanks
P.S. Don't say anything about my English.
Re: GetPlayerName from inputtext (listitem) -
RageCraftLV - 02.12.2017
I didn't really understand what you are saying but as I understand you want the second listitem to show players name? Then you don't have to use inputtext, because inputtext is just from DIALOG_STYLE_INPUT. You want to get players name.
Re: GetPlayerName from inputtext (listitem) -
rOps - 02.12.2017
I want to get ONLY his name after player choose it in OnDialogResponse
Re: GetPlayerName from inputtext (listitem) -
Sabur - 02.12.2017
it's been years since i coded but i think this will work.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOGID)
{
if(response)
{
new id = listitem,
playername[MAX_PLAYER_NAME],
string[144];
GetPlayerName(id, playername, sizeof(playername));
format(string, sizeof(string), "%s", playername);
ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_MSGBOX, "Name", string, "Close", "");
}
return 1;
}
return 0;
}
Re: GetPlayerName from inputtext (listitem) -
rOps - 02.12.2017
Quote:
Originally Posted by Sabur
it's been years since i coded but i think this will work.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == DIALOGID) { if(response) { new id = listitem, playername[MAX_PLAYER_NAME], string[144]; GetPlayerName(id, playername, sizeof(playername)); format(string, sizeof(string), "%s", playername); ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_MSGBOX, "Name", string, "Close", ""); } return 1; }
return 0; }
|
No, I don't need this.
Re: GetPlayerName from inputtext (listitem) -
Lucases - 02.12.2017
Use sscanf2 and scan the inputtext
Re: GetPlayerName from inputtext (listitem) -
FuNkYTheGreat - 03.12.2017
Quote:
Originally Posted by RageCraftLV
I didn't really understand what you are saying but as I understand you want the second listitem to show players name? Then you don't have to use inputtext, because inputtext is just from DIALOG_STYLE_INPUT. You want to get players name.
|
Nope that's not correct, When i was a newb i thought the same.
Quote:
Originally Posted by Lucases
Use sscanf2 and scan the inputtext
|
It's useless,
Well firstly i thought that only DIALOG_STLYE_INPUT returns the inputtext but after examining scripts , creating those i find that not only DIALOG_STYLE_INPUT returns inputtext , but DIALOG_STYLE_LIST will also return it, e.g
If you have a code like..
ShowPlayerDialog(playerid,500,"LOL Dialog","Too Pro\nToo Noob\nHOBO".......
So when you'll be using dialog id 500 so in the first case inputtext will return Too Pro in next case Too Noob in third HOBO,
I've also used this technique to determine fonts in my latest script.
Re: GetPlayerName from inputtext (listitem) -
MEW273 - 03.12.2017
Quote:
Originally Posted by rOps
Hello my friends.
I have one question for you, as example I have dialog (DIALOG_STYLE_LIST):
1. Nick_Name (OFFLINE)
2. Name_Nick (ONLINE)
3. One_More (OFFLINE)
and when playerid responses 1 ID listitem (2. Name_Nick (ONLINE)) I want to get from that text only his name. I know, that I must use inputtext, but it only returns all the text. So if you can help me, do it. Thanks
P.S. Don't say anything about my English. 
|
When creating the dialog how do you insert the names? Can you show us the ShowPlayerDialog code?
Re: GetPlayerName from inputtext (listitem) -
Abagail - 03.12.2017
Why bother reading through a list, when you
know what your list will look like? You can simply set the list data, using PVars, GVars(?), arrays, etc.
Re: GetPlayerName from inputtext (listitem) -
RIDE2DAY - 03.12.2017
You could do something like this:
PHP код:
// OnDialogResponse
if(response)
{
ClearName(inputtext);
// Now "inputtext" contains the name only.
}
ClearName(inputtext[])
{
// Removes everything until the 1st found space.
for(new x = 0, len = strlen(inputtext); x < len; x++)
{
if(inputtext[x] == ' ')
{
strdel(inputtext, 0, x + 1);
break;
}
}
// Removes everything after the 2nd found space.
for(new x = 0, len = strlen(inputtext); x < len; x++)
{
if(inputtext[x] == ' ')
{
strdel(inputtext, x, len);
}
}
}
Watch out, if the name contains spaces or if there are more than two space characters the script above might not work!