Raised This Month: $32 Target: $400
 8% 

Updating database when ban is over


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Devoti
New Member
Join Date: Nov 2013
Old 09-23-2020 , 14:20   Updating database when ban is over
Reply With Quote #1

Hi!

I'm quite new to this, so I need help )

Code:
		if( !id )
		{
			formatex( szQuery, charsmax( szQuery ), "UPDATE `bans` SET `unbanned` = '1' WHERE `id` = '%i' LIMIT 1;", SQL_ReadResult( hQuery, 0 ) );

			SQL_ThreadQuery( g_hTuple, "SQL_QueryHandle", szQuery );

			console_print( id, "SteamID %s is unbanned from ****.", szTargetAuthid );
			return PLUGIN_HANDLED;
		}
The problem is that it wont update when the ban time is over in the database, BUT.. It will be removed on the server side. So people cant join before it's over.
I can provide more information if needed.
Devoti is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-23-2020 , 18:15   Re: Updating database when ban is over
Reply With Quote #2

Instead of using a boolean value, you should instead set the ban duration using a unix timestamp. For a permanent ban set it to 2,000,000,000 or something way in the future, or the max value of a signed 32-bit long, 2,147,483,647 (01/19/2038 @ 3:14am)

Suppose the below for a 1 day ban, this is accurate down to the second in time:
  • Now = 1600899052
  • Ban expiration = 1600985452‬ (Now + 1 day (86400 seconds))
The ban will automatically lift after the current time reaches the ban expiration time:
PHP Code:
if ( PlayersBanTimeValue get_systime() ) 
    
//Sorry, you're banned , it will expire in (PlayersBanTimeValue  - get_systime()) seconds
else
    
//Ban has expired, player can join 
You could always lift the ban by setting the ban expiration to 0, or by deleting the record.
__________________

Last edited by Bugsy; 09-23-2020 at 20:56.
Bugsy is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode