Dialog help
#1

I'm using this for my RolePlay server and how do I make the player to enter a valid year for his character between 15 and 100?


pawn Код:
if(dialogid == godine)
    {
        if(response == 0)
        {
            ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"{FF0000}                 GREЉKA","{FF0000}_______________________________\n\n      Odustali ste od registracije pa\n\n          ste izbaceni sa servera!\n\n_______________________________","Izadi","");
            Kick(playerid); // kicks when player clicks cancel
            return 1;
        }
        if(response == 1)
        {
            if(!strlen(inputtext))
            {
                ShowPlayerDialog(playerid,godine,DIALOG_STYLE_INPUT,"{FF0000}                     Godine","{FF0000}Unesite kolko godina ћelite da ima Vaљ lik:","U redu","Odustani");
                SendClientMessage(playerid,CRVENA,"Godine ne smiju biti manje od 15 i vece od 100!");
                // when nothing is entered the dialog shows again and sends a message
                        }
            else
            {
                godinee(playerid,inputtext); // goes to stock which writes the years  enterd in the player file
                return 1;
            }
        }
Reply
#2

pawn Код:
if (!(15 <= inputtext <= 100))
{
//invalid year
}
else
{
//valid year
}
Reply
#3

It gives me this error:
error 033: array must be indexed (variable "inputtext")
Reply
#4

ahh im sorry
i forgot to convert it to a number.
pawn Код:
if (!(15 <= strval(inputtext) <= 100))
{
//invalid year
}
else
{
//valid year
}
Reply
#5

EDIT ok works now with,i posted before i saw your last post
Reply
#6

Can this work for letters?
Example if there was not a symbol like "@" entered?
Reply
#7

for letters youll have to compare it like a string using strcmp

or if its just one letter you can do
pawn Код:
if (inputtext[0] == '@')
{
//valid
}
else
{
//invalid
}
Reply
#8

What if it were 2 letters i need, it are "@" and "." ?

Like this?


pawn Код:
if (inputtext[0] == '@' && inputtext[0] == '.')
{
//valid
}
else
{
//invalid
}
Reply
#9

pawn Код:
if (!strcmp("@.",inputtext,true,2))     //the 2 is for 2 chars,
{
//valid
}
else
{
//invalid
}


youll need to use strcmp
Reply
#10

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
pawn Код:
if (!strcmp("@.",inputtext,true,2))     //the 2 is for 2 chars,
{
//valid
}
else
{
//invalid
}


youll need to use strcmp
Can you explain this to me?I have this my code but whatever i enter it continues to next dialog...

pawn Код:
if(dialogid==tut1)
    {
        if(response==0)
        {
            ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"{FF0000}                 GREЉKA","{FF0000}_______________________________\n\n      Odustali ste od registracije pa\n\n          ste izbaceni sa servera!\n\n_______________________________","Izadi","");
            new name[MAX_PLAYER_NAME],strPath[128];
            GetPlayerName(playerid,name,sizeof(name));
            format(strPath,sizeof(strPath), "/korisnici/%s.txt",name);
            fremove(strPath);
            Kick(playerid);///////// KICKS PLAYER AND DELETS THE FILE IF HE CLICKS CANCEL
            return 1;
        }
        if(response==1)
        {
            if (!strcmp("@.",inputtext,true,2))// IF THE MAIL IS ENTERED WRONG WITHOUT @ and . WRITE IT AGAIN..
            {
                for(new i = 0; i < 50; i++) SendClientMessageToAll(BIJELA," ");
                new string[128];
                strcat(string, "{FF0000}\nMolimo unesite vaљu e-mail adresu:");
                ShowPlayerDialog(playerid,tut1,DIALOG_STYLE_INPUT,"{FF0000}              E-Mail",string,"U redu","Odustani");
                SendClientMessage(playerid,CRVENA,"Morate unjeti valjanu E-mail adresu!");
            }
            else
            {
                mail(playerid,inputtext);//// WRITES HIS MAIL IN FILE AND GOES TO NEXT DIALOG
                for(new i = 0; i < 50; i++) SendClientMessageToAll(BIJELA," ");
                ShowPlayerDialog(playerid,tut2,DIALOG_STYLE_LIST,"{FF0000}            Odaberite spol Vaљeg lika:","Musko\nZensko","U redu","Odustani");
                SendClientMessage(playerid,CRVENA,"Odaberite spol vaљega lika!");
                return 1;
            }
        }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)