Slow response time when log-in
#1

Hi! So I just started learning PAWN like one week ago so if you notice any stupid things in my code just please go ahead and tell me how can I improve it, whats the better way to do that certain thing.

So, my problem is when I click "Login" it takes at least 3-4 seconds to spawn me. Okay, this is a long time but I feel like I just screwed up something in my code what causes this 3-4 second delay on each and every log-in.

So here is the textdraw where I click when I want to log-in:

PHP код:
if(playertextid == Login_Textdraw22[playerid])
    {
        new 
query[128];
        
mysql_format(g_sqlquerysizeof query"SELECT * FROM characters WHERE Name = '%e' LIMIT 1"PlayerName(playerid));
           
mysql_tquery(g_sqlquery"SetPlayerLogin""i"playerid);
    } 
Here is the SetPlayerLogin:

PHP код:
forward SetPlayerLogin(playerid);
public 
SetPlayerLogin(playerid)
{
    new 
query[128], password[129], string[128];
    if(!
cache_num_rows())
    {    
        
format(stringsizeof(string), "Account unregistered! Type a in a password and click register!");
        
ErrorTag(playeridstring);
    }
    else
    {
        
WP_Hash(password129DialogPassword);
        
cache_get_value_name(0"Password"pInfo[playerid][pPassword], 129);
        
cache_get_value_name_int(0"DBID"pInfo[playerid][pID]);
        if(!
strcmp(passwordpInfo[playerid][pPassword]))
        {
            
mysql_format(g_sqlquerysizeof(query), "SELECT * FROM `characters` WHERE `Name` = '%e' LIMIT 1"PlayerName(playerid));
            
mysql_tquery(g_sqlquery"OnPlayerLoad""i"playerid);
        }
        else
        {
            
format(stringsizeof(string), "Wrong password!");
            
ErrorTag(playeridstring);
        }
    }

Here is the OnPlayerLoad:

PHP код:
forward OnPlayerLoad(playerid);
public 
OnPlayerLoad(playerid)
{
    
cache_get_value_name_int(0"Skin"pInfo[playerid][pSkin]);
    
cache_get_value_name_int(0"Admin"pInfo[playerid][pAdmin]);
    
SetSpawnInfo(playerid0pInfo[playerid][pSkin], 1554.9028, -1621.744013.5469277.4472000000);
    
TogglePlayerSpectating(playeridfalse);
    
SpawnPlayer(playerid);
    
pInfo[playerid][pLoggedIn] = true;
    
DLoginTextdraw(playerid);
    
CancelSelectTextDraw(playerid);
    
ClearChat();
    return 
1;

Honestly I can take a 3-4 second delay but I want to learn, and correct my faults to not do them over and over. If anyone need any more code, or information about the login system to investigate this, just comment. Thank you!
Reply


Messages In This Thread
Slow response time when log-in - by polygxn - 08.02.2019, 14:28
Re: Slow response time when log-in - by Calisthenics - 08.02.2019, 14:49
Re: Slow response time when log-in - by polygxn - 13.02.2019, 06:22
Re: Slow response time when log-in - by polygxn - 13.02.2019, 20:11

Forum Jump:


Users browsing this thread: 2 Guest(s)