The date of birth.
#1

Hi everybody.I wank to ask,how to make that thing,when player register,he get dialog,input,and there he have write his date of birth,but primarily is how to make format,i have mean player have write like that:"Day/Month/Year/

Код:
04/02/1997
Like that.And i want to do if day is more than 31, or less than 1,then he get this dialog again,or if he write month more than 12, or less than 1,then too he get this dialog again,and with years,if he write more than 2011, or less than 1950,then dialog he get again.
Reply
#2

pawn Код:
new Dates[3][11];
new DateString[11]="04/02/1997";
split(DateString,Dates,'/');

new day = strval(Dates[0]);
new month = strval(Dates[1]);
new year = strval(Dates[2]);

if(day<1||day>31) SendClientMessage(playerid,0xFFFFFFFF,"Day can only be from 1 to 31");
if(month<1||month>12) SendClientMessage(playerid,0xFFFFFFFF,"Month can only be from 1 to 12");
if(year<1) SendClientMessage(playerid,0xFFFFFFFF,"Year can be less than 1");
It's a example how you can do it with dialogs or whatever you need. Just make DateString variable equal to inputtext.
Not tested, but it should work.
Reply
#3

C:\Documents and Settings\Owner\Desktop\NAUJAUSIAS SAMP SERVERIS\gamemodes\freeroam.pwn(221) : error 017: undefined symbol "split"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

pawn Код:
stock split(const strsrc[], strdest[][], delimiter)
{
    new i, li;
    new aNum;
    new len;
    while(i <= strlen(strsrc))
    {
        if(strsrc[i] == delimiter || i == strlen(strsrc))
        {
            len = strmid(strdest[aNum], strsrc, li, i, 128);
            strdest[aNum][len] = 0;
            li = i+1;
            aNum++;
        }
        i++;
    }
    return 1;
sorry, i forgot.
Reply
#5

Or you could use sscanf, which is faster and much better than this split function.
pawn Код:
new day, month, year,
    DateString[11] = "04/02/1997";
sscanf(DateString, "p</>ddd", day, month, year);
 
//...
Code untested.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)