Originally Posted by Kaliber
Ok dude, first...write this function like this if you want DD/MM/YYYY
PHP код:
//Write it at the end of your script
stock const g_days_m[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
stock GetPlayerAge(input[])
{
new date[12];
strcat(date, input);
if(date[1] == '/') strins(date, "0", 0, 12);
if(date[4] == '/') strins(date, "0", 3, 12);
if(!date[9] || date[10]) return -1;
new day = 10*(date[0]-48)+(date[1]-48);
new month = 10*(date[3]-48)+(date[4]-48);
new year = 1000*(date[6]-48)+100*(date[7]-48)+10*(date[8]-48)+(date[9]-48);
if(year < 1000 || year > 9999 || month < 1 || month > 12 || day < 1) return -1;
if(month == 2)
{
if(day > 28 && (year % 4 != 0 || (year % 100 == 0 && year % 400 != 0))) return -1;
}
else if(day > g_days_m[month-1]) return -1;
new d, m, y;
getdate(y, m, d);
new age = y - year;
if(m < month) age--;
else if(m == month && d < day) age--;
return (age < 0) ? (-1) : (age);
}
//Then in dialog response:
new age = GetPlayerAge(inputtext);
if(age == -1) return ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age:[6-35]", "When were you born? ?\n[DD/MM/YYYY]", "Next", "");
//Otherwise the age is good :)
1. Use a timer:
PHP код:
//OnGameModeInit
SetTimer("@checkPlayer",999,0);
//Then outside
@checkPlayer();@checkPlayer() {
for(new i,l=GetPlayerPoolSize()+1; i<l; i++)
{
if(!IsPlayerInRangeOfPoint(i,3.0,x,y,z)) continue; //replace x,y,z with your coords
GameTextForPlayer(i, ...);
}
return 1;
}
2. You can use a TextDraw that you draw over it
3. Yes it's obviously a string because of the /
|