y_ini or SQL?
#1

Hey! I would like to ask that Can I create a V.I.P System that will expire on a particular date. Foreg, Suppose I'm having a command /setvip [id] [date] Here date means the date on whcih V.I.P Subscription will expire. So, Can i create such thing with y_ini Or I would have to switch to SQL.

Regards.
TRL
Reply
#2

You can easily do this with the file system. Take a look at this.
Reply
#3

Quote:
Originally Posted by b3nz
Посмотреть сообщение
You can easily do this with the file system. Take a look at this.
This was actually really helpfull to me thanks
Reply
#4

You can make that with both of them ..

There we are :

Код:
stock const MonthDays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

stock DateTimeGet(Plus)
{
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);

    Day += Plus;

    if(Day >= MonthDays[Month])
    {
	Month++;
	Day -= MonthDays[Month-1];
    }

    if(Month >= 12)
    {
        Year++;
        Month -= 12;
    }
}
Get actual time and add X days ... DateTimeGet(30) will mean 30 days of valability ... you can stock it so ..

Код:
public SetPlayerDriverLicense(playerid)
{
    DateTimeGet(30);

    pLicense[playerid][pDriver] = 1;
    pLicense[playerid][pDriverLY] = Year;
    pLicense[playerid][pDriverLM] = Month;
    pLicense[playerid][pDriverLD] = Day;
    pLicense[playerid][pDriverLH] = Hour;
    pLicense[playerid][pDriverLMIN] = Minute;
    pLicense[playerid][pDriverLS] = Second;

    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "Licenses");

    INI_WriteInt(File, "DriverLicense", 1);
    INI_WriteInt(File, "DriverLicense_Year", Year);
    INI_WriteInt(File, "DriverLicense_Month", Month);
    INI_WriteInt(File, "DriverLicense_Day", Day);
    INI_WriteInt(File, "DriverLicense_Hour", Hour);
    INI_WriteInt(File, "DriverLicense_Minute", Minute);
    INI_WriteInt(File, "DriverLicense_Second", Second);
	
    INI_Close(File);
}
Add at the beginning of the script right under #defines

Код:
new Year, Month, Day, Hour, Minute, Second
P.S that exemple it's from my License Script ..

EDIT: When player connect you need to check (Put a timer) if actual date (getdate & gettime) = your array .. In my case

Код:
    pLicense[playerid][pDriverLY] = Year;
    pLicense[playerid][pDriverLM] = Month;
    pLicense[playerid][pDriverLD] = Day;
    pLicense[playerid][pDriverLH] = Hour;
    pLicense[playerid][pDriverLMIN] = Minute;
    pLicense[playerid][pDriverLS] = Second;
to set Vip to value 0 (No vip - or how it's at you) ... if(actual date >= my old date) pLicense[playerid][pDriver] = 0; // ... actual date and my old date dosen't exist it's just so

I hope you understand what i said to you ..
Reply
#5

Quote:
Originally Posted by b3nz
Посмотреть сообщение
You can easily do this with the file system. Take a look at this.
Quote:
Originally Posted by Mariciuc223
Посмотреть сообщение
You can make that with both of them ..

There we are :

Код:
stock const MonthDays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

stock DateTimeGet(Plus)
{
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);

    Day += Plus;

    if(Day >= MonthDays[Month])
    {
	Month++;
	Day -= MonthDays[Month-1];
    }

    if(Month >= 12)
    {
        Year++;
        Month -= 12;
    }
}
Get actual time and add X days ... DateTimeGet(30) will mean 30 days of valability ... you can stock it so ..

Код:
public SetPlayerDriverLicense(playerid)
{
    DateTimeGet(30);

    pLicense[playerid][pDriver] = 1;
    pLicense[playerid][pDriverLY] = Year;
    pLicense[playerid][pDriverLM] = Month;
    pLicense[playerid][pDriverLD] = Day;
    pLicense[playerid][pDriverLH] = Hour;
    pLicense[playerid][pDriverLMIN] = Minute;
    pLicense[playerid][pDriverLS] = Second;

    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "Licenses");

    INI_WriteInt(File, "DriverLicense", 1);
    INI_WriteInt(File, "DriverLicense_Year", Year);
    INI_WriteInt(File, "DriverLicense_Month", Month);
    INI_WriteInt(File, "DriverLicense_Day", Day);
    INI_WriteInt(File, "DriverLicense_Hour", Hour);
    INI_WriteInt(File, "DriverLicense_Minute", Minute);
    INI_WriteInt(File, "DriverLicense_Second", Second);
	
    INI_Close(File);
}
Add at the beginning of the script right under #defines

Код:
new Year, Month, Day, Hour, Minute, Second
P.S that exemple it's from my License Script ..

EDIT: When player connect you need to check (Put a timer) if actual date (getdate & gettime) = your array .. In my case

Код:
    pLicense[playerid][pDriverLY] = Year;
    pLicense[playerid][pDriverLM] = Month;
    pLicense[playerid][pDriverLD] = Day;
    pLicense[playerid][pDriverLH] = Hour;
    pLicense[playerid][pDriverLMIN] = Minute;
    pLicense[playerid][pDriverLS] = Second;
to set Vip to value 0 (No vip - or how it's at you) ... if(actual date >= my old date) pLicense[playerid][pDriver] = 0; // ... actual date and my old date dosen't exist it's just so

I hope you understand what i said to you ..
Thanks
Reply
#6

Use UNIX timestamps.. it's really easy. You can do /makevip [id] [duration]. Doesen't need any includes or stuff.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)