It works fine by saving by file, but SQL, strtotime() formats the time incorrectly. iTimeLeft value is a lot higher on map change (leading to much longer time for gagged players to be ungagged on map changes).
Code:
new szDateGagged
[DATE_SIZE
];
while( SQL_MoreResults
(hQuery
) )
{
SQL_ReadResult
( hQuery, iFieldSteamID, data
[GAG_STEAMID
], charsmax
(data
[GAG_STEAMID
]) );
SQL_ReadResult
( hQuery, iFieldDateGagged, szDateGagged, charsmax
(szDateGagged
) );
data
[GAG_TIME
] = SQL_ReadResult
( hQuery, iFieldGagTime
);
SQL_ReadResult
( hQuery, iFieldGagFlags, szFlags, charsmax
(szFlags
) );
data[GAG_START] = strtotime( szDateGagged );
data
[GAG_FLAGS
] =
read_flags( szFlags
);
if( data
[GAG_TIME
] >
0 )
{
iTimeLeft = data
[GAG_START
] + data
[GAG_TIME
] - iSystime;
server_print("-- DEBUG: SteamID: %s | Date gagged: %s | length: %i", data
[GAG_STEAMID
], szDateGagged, iTimeLeft
);
if( iShortestTime > iTimeLeft
)
{
iShortestTime = iTimeLeft;
}
}
ArrayPushArray
( g_aGagData, data
);
TrieSetCell
( g_tArrayPos, data
[GAG_STEAMID
], g_iGagged
);
g_iGagged++;
SQL_NextRow
( hQuery
);
}
if( iShortestTime <
999999 )
{
entity_set_float
( g_iThinker, EV_FL_nextthink,
get_gametime() + iShortestTime
);
server_print("-- DEBUG: Shortest time: %i", iShortestTime
);
}
Code:
] say test
[AMXX GAG] 55 seconds left before your ungag!
] rcon changelevel stadium4
* Privileges set
Sven Co-op 5.25
Server Engine: 5.0.1.7 (build 8948)
Server Number: 193
- Rirre has joined the game.
Rirre has joined the game.
] say test
[AMXX GAG] 2 hours and 40 seconds left before your ungag!
EDIT: Found out it is timezone related as the SQL server is +2 hours.