GetPlayerName from inputtext (listitem)
#1

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

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

I want to get ONLY his name after player choose it in OnDialogResponse
Reply
#4

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;
}
Reply
#5

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

Use sscanf2 and scan the inputtext
Reply
#7

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

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?
Reply
#9

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

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 0len strlen(inputtext); lenx++)
    {
        if(
inputtext[x] == ' ')
        {
            
strdel(inputtext01);
            break;
        }
    }
    
// Removes everything after the 2nd found space.
    
for(new 0len strlen(inputtext); lenx++)
    {
        if(
inputtext[x] == ' ')
        {
            
strdel(inputtextxlen);
        }
    }

Watch out, if the name contains spaces or if there are more than two space characters the script above might not work!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)