Gender Saving
#1

I'm trying to save the gender of my character with inputtext. I'm completely lost. If you would care to help. That would be great.

I have this dialog

pawn Код:
ShowPlayerDialog(playerid, 130, DIALOG_STYLE_INPUT, "Gender","Male or Female?","Choose","Cancel");
And I want to make sure if what they enter is "Male" or "Female" it sets it as their gender in stats.

Also, if they put random words into the box. It'll prompt them with the dialog again.
Reply
#2

On top
Код:
#define DIALOG_GENDER 103
Where you want it to show up
Код:
ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Please choose your Gender!", "Boy", "Girl");
How the dialog works
Код:
case DIALOG_GENDER:
        {
            if(response)
            {
                new INI:File = INI_Open(PData(playerid));

                INI_WriteString(File, "Gender","Boy");
                INI_Close(File);
                INI_ParseFile(PData(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
			}
			else
			{
                new INI:File = INI_Open(PData(playerid));
                INI_WriteString(File, "Gender","Girl");
                INI_Close(File);
                INI_ParseFile(PData(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
			}
        }
Reply
#3

Thanks for the reply my friend. It seems what you have given me isn't what I'm looking for. You see my script runs on MySQL. If you can find a solution with that. I'd appreciate it.
Reply
#4

pawn Код:
#define DIALOG_GENDER 130

ShowPlayerDialog( playerid, DIALOG_GENDER, DIALOG_STYLE_INPUT, "Choosing your gender", "Please enter your sex (Male or Female)", "Accept", "Cancel" );

public OnDialogResponse( playerid .... )
{
      switch( dialogid )
      {
           case DIALOG_GENDER:
           {
                 if( ! strcmp(inputtext, "Male", true ) ) // Male
                 {                          }
                 if( !strcmp( inputtext, "Female", true ) ) // Female
                 {                          }
                 else
                        return ShowPlayerDialog( playerid, DIALOG_GENDER, DIALOG_STYLE_INPUT, "Choosing your          gender", "Please enter your sex (Male or Female)", "Accept", "Cancel" );
          }
      }
      return 1;
}
Reply
#5

I can't seem to get it to work correctly. Can I do this with DIALOG_STYLE_LIST?
Reply
#6

Of course you can. Infact, that would be a preference, what most people would use! (I gave the above since you insisted on it)

Just change the content to "Male\nFemale", then use if(listitem == 0) // male, if( listitem == 1) //female and so on!
Reply
#7

Any chance someone could show me? I have this.

pawn Код:
if(dialogid == 130)
    {
        if(!response) return ShowPlayerDialog(playerid, 130, DIALOG_STYLE_LIST, "Gender","Male\nFemale?","Choose","Cancel");
        else if(response)
        {
            if(listitem == 0)
            {
                new text[10];
                text = "Male";
                Player[playerid][Gender] = text;
            }
            if(listitem == 1)
            {
                new text[10];
                text = "Female";
                Player[playerid][Gender] = text;
            }
        }
    }
When I choose the list item. The box disappears and nothing happens.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)