AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Giving bt flag before xredirect acts (https://forums.alliedmods.net/showthread.php?t=171034)

Schwabba 10-31-2011 17:35

Giving bt flag before xredirect acts
 
Hi, i got a bad problem here, i try to add bt flag before xredirects redirects the player to an other server.

PHP Code:

public client_authorized(id)
{
    
g_authed[id] = true
    Load_MySql
(id)
}

public 
Load_MySql(id)
{
    if(
g_sql_ready)
    {
        if(
g_SqlTuple == Empty_Handle)
        {
            
set_fail_state(g_Error)
        }

        new 
szSteamId[32], szTemp[512]
        
get_user_authid(idszSteamIdcharsmax(szSteamId))

        new 
Data[1]
        
Data[0] = id

        format
(szTemp,charsmax(szTemp),"SELECT * FROM `vips` WHERE (`vips`.`steamid` = '%s')"szSteamId)
        
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
    }
}

public 
register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
    {
        
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError)
    }
    else if(
FailState == TQUERY_QUERY_FAILED)
    {
        
log_amx("Load Query failed. [%d] %s"ErrcodeError)
    }
    new 
id
    id 
Data[0]
    if(
SQL_NumResults(Query) < 1
    {
        new 
szSteamId[32], szName[32], szQuotedName[64], szQuotedPass[64]
        
get_user_authid(idszSteamIdcharsmax(szSteamId))
        
get_user_name(idszName31)
        
SQL_QuoteString(g_SqlConnectionszQuotedName63szName)
        new 
szPass[MAXCHARS 1]
        for(new 
iMAXCHARSi++)
        {
            
szPass[i] = Characters[random(sizeof(Characters))]
        }
        
SQL_QuoteString(g_SqlConnectionszQuotedPass63szPass)

        if (
equal(szSteamId,"ID_PENDING"))
        {
            return 
PLUGIN_HANDLED
        
}
            
        new 
szTemp[512]

        
format(szTemp,charsmax(szTemp),"INSERT INTO `vips` ( `steamid` , `name` , `pass` , `login`) VALUES ('%s','%s','%s','%s');",szSteamIdszQuotedNameszQuotedPassszSteamId)
        
copy(iPass[id], 63szQuotedPass)
        
iStars[id] = 0
        iTime
[id] = 0
        copy
(iLogin[id], 63szSteamId)
        
iActive[id] = 0
        SQL_ThreadQuery
(g_SqlTuple,"IgnoreHandle",szTemp)
    } 
    else 
    {
        
iNummer[id]        = SQL_ReadResult(Query0)
        
SQL_ReadResult(Query3iPass[id], 63)
        
iStars[id]        = SQL_ReadResult(Query4)
        
iTime[id]        = SQL_ReadResult(Query5)
        
SQL_ReadResult(Query6iLogin[id], 63)
        
iActive[id]        = SQL_ReadResult(Query7)
        if(
iTime[id] > get_systime())
        {
            new 
flags read_flags("bt")
            
set_user_flags(id,flags)
        }
    }
    
g_loaded[id] = true
    
return PLUGIN_HANDLED


If the Server is not full, the player is vip (t flag defines vip-flag for other plugins), but he has no reserved slot, because xredirects switches him before it loads his flags. When i change the client_authorized to client_putinserver on the xredirect plugin, then it switches other players, but then i have the problem that when someone who's not vip joins the server, it does'nt switches him and there are 20/20 players.

This plugin is above the xredirect.amxx.

Someone know how to make it works?

Schwabba 11-03-2011 07:15

Re: Giving bt flag before xredirect acts
 
I made a function that creates an array with all VIP ID's and it checks now if the ID is in that array on client_authorized.

Now i can skip the MySQL part on connect and get it from the cache.




And it works.


All times are GMT -4. The time now is 14:26.

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