AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Updating database when ban is over (https://forums.alliedmods.net/showthread.php?t=327505)

Devoti 09-23-2020 14:20

Updating database when ban is over
 
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.

Bugsy 09-23-2020 18:15

Re: Updating database when ban is over
 
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.


All times are GMT -4. The time now is 13:48.

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