08.02.2019, 14:28
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:
Here is the SetPlayerLogin:
Here is the OnPlayerLoad:
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!
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_sql, query, sizeof query, "SELECT * FROM characters WHERE Name = '%e' LIMIT 1", PlayerName(playerid));
mysql_tquery(g_sql, query, "SetPlayerLogin", "i", playerid);
}
PHP код:
forward SetPlayerLogin(playerid);
public SetPlayerLogin(playerid)
{
new query[128], password[129], string[128];
if(!cache_num_rows())
{
format(string, sizeof(string), "Account unregistered! Type a in a password and click register!");
ErrorTag(playerid, string);
}
else
{
WP_Hash(password, 129, DialogPassword);
cache_get_value_name(0, "Password", pInfo[playerid][pPassword], 129);
cache_get_value_name_int(0, "DBID", pInfo[playerid][pID]);
if(!strcmp(password, pInfo[playerid][pPassword]))
{
mysql_format(g_sql, query, sizeof(query), "SELECT * FROM `characters` WHERE `Name` = '%e' LIMIT 1", PlayerName(playerid));
mysql_tquery(g_sql, query, "OnPlayerLoad", "i", playerid);
}
else
{
format(string, sizeof(string), "Wrong password!");
ErrorTag(playerid, string);
}
}
}
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(playerid, 0, pInfo[playerid][pSkin], 1554.9028, -1621.7440, 13.5469, 277.4472, 0, 0, 0, 0, 0, 0);
TogglePlayerSpectating(playerid, false);
SpawnPlayer(playerid);
pInfo[playerid][pLoggedIn] = true;
DLoginTextdraw(playerid);
CancelSelectTextDraw(playerid);
ClearChat();
return 1;
}