The plugin stores the time of expire as a timestamp.
You only need 1 sql command to get the remaining timestamp.
like this:
PHP Code:
public Action:Cmd_viptime(int client, int argc)
{
char query[255];
//get client accountid here
Format(query, sizeof(query), "select expires-UNIX_TIMESTAMP(NOW()) from vip_users where account_id='%d'",accountid);
SQL_TQuery(hDatabase, T_GetRemainingVipTime, query, client);
}
public void T_GetRemainingVipTime(Handle owner, Handle hndl, const String:error[], int client)
{
if (hndl == INVALID_HANDLE)
{
LogError("Query failed! %s", error);
}
if (SQL_FetchRowCount(hndl))
{
int timestamp=SQL_FetchInt(hndl,0);
int hours=timestamp/3600;
timestamp-=hours*3600;
int minutes=timestamp/60;
timestamp-=minutes*60;
int seconds=timestamp;
//use the variables as you want
}
}