Nu cred ca a inteles ce are de facut :)))
Hai sa-ti explic.
1. Adaugi la pInfo, variabila
pPaydayTime
2. Cand se inregistreaza un jucator, ii setezi o valoare si o salvezi in baza de date.
// bla bla bla
PlayerInfo[playerid][pPaydayTime] = 60 * 60;
new gQuery[128];
mysql_format(SQL, gQuery, sizeof gQuery, "UPDATE `tabelUsers` SET `PaydayTime` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPaydayTime], PlayerInfo[playerid][pSQLID]);
mysql_tquery(SQL, gQuery, "", "");
3. Creezi un timer cu y_timers pentru o optimizare mai buna
ptask oneSecondTimer[1000](playerid)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pPaydayTime] > 0)
{
-- PlayerInfo[playerid][pPaydayTime];
// aici faci un textdraw pe care-l formatezi
if(PlayerInfo[playerid][pPaydayTime] <= 0)
{
PlayerInfo[playerid][pPaydayTime] = 60 * 60;
// salvezi
new gQuery[128];
mysql_format(SQL, gQuery, sizeof gQuery, "UPDATE `tabelUsers` SET `PaydayTime` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPaydayTime], PlayerInfo[playerid][pSQLID]);
mysql_tquery(SQL, gQuery, "", "");
// aici ii dai paydayul
}
}
}
return 1;
}
4. Faci o functie ca sa salvezi paydaytime-ul in caz ca se deconecteaza:
function savePaydayTime(playerid)
{
new gQuery[128];
mysql_format(SQL, gQuery, sizeof gQuery, "UPDATE `tabelUsers` SET `PaydayTime` = '%d' WHERE `id` = '%d'", PlayerInfo[playerid][pPaydayTime], PlayerInfo[playerid][pSQLID]);
mysql_tquery(SQL, gQuery, "", "");
return 1;
}
5. Aplici functia creata mai sus la public-ul OnPlayerDisconect
public OnPlayerDisconnect(playerid, reason)
{
// codurile tale
if(IsPlayerConnected(playerid))
{
savePaydayTime(playerid);
}
return 1;
}
6. Incarci paydaytime la functia care extrage datele unui jucator din baza de date la conectare
PlayerInfo[playerid][pPaydaytime] = cache_get_field_content_int(0, "PaydayTime");
Si la final, adaugi in baza ta de date, "PaydayTime de INT"
?