SA-MP Forums Archive
y_ini or SQL? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: y_ini or SQL? (/showthread.php?tid=582400)



y_ini or SQL? - TheRaGeLord - 20.07.2015

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


Re: y_ini or SQL? - b3nz - 20.07.2015

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


Re: y_ini or SQL? - Glenn332 - 20.07.2015

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


Re: y_ini or SQL? - Mariciuc223 - 20.07.2015

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 ..


Re: y_ini or SQL? - TheRaGeLord - 20.07.2015

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


Re: y_ini or SQL? - Dan. - 20.07.2015

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