Getting a wierd delay when trying to open a dialog..
#1

-- DELETED --
Reply
#2

I'm just going to guess that your GetFactionLeader function is shit. Also I hope you do realize that you're hanging the entire server at that point and NOTHING gets done, not even player sync.
Reply
#3

How does your GetFactionLeader function look like?

#e: Got ninja'd by Vince
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
I'm just going to guess that your GetFactionLeader function is shit. Also I hope you do realize that you're hanging the entire server at that point and NOTHING gets done, not even player sync.
This is my GetFactionLeader function

Код:
GetFactionLeader(id)
{
	new pNa[60];
    new Cache:r = mysql_query(dbHandle, sprintf("SELECT user, ID, LastLogin FROM `players` WHERE `Member` = '%d' AND `Rank` = 7", id), true);
    format(pNa, sizeof(pNa), "No Leader"), sLeaderF = "-";
    if(cache_num_rows()) cache_get_field_content(0, "user", pNa), cache_get_field_content(0, "LastLogin", sLeaderF),
        format(pNa, sizeof(pNa), "%s (%s{FFFFFF})", pNa, GetAccountStatus(pNa) > 0 ? ("{00BA19}Online") : ("{C90000}Offline"));
    cache_delete®;
    return pNa;
}
Reply
#5

I assume your GetAccountStatus also performs cached MySQL query which is probably why it takes some time. Use threaded query instead.
Reply
#6

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
I assume your GetAccountStatus also performs cached MySQL query which is probably why it takes some time. Use threaded query instead.
Yes, the query isn't threaded. I recommend you look into mysql_pquery and mysql_tquery.

https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_tquery

I would however try to do this another way if I were you. 15 queries every time someone wants to open this dialog for information seems extremely inefficient to me. Perhaps you could fetch this information and then load them into memory, and then only query if you can't find it? You could for instance do this when the server starts, with a timer, when the server start but a command to manually update, there's quite a few ways. I would REALLY just refrain from sending 15 queries just for a simple dialog with information.
Reply
#7

You can rather have an array to store faction information. Store the array with your faction details upon the initiation of your game mode. It doesn't required to be varied until there are changes made to your faction or the leader of any department changes. You could simply update the table and array upon change. This can allow you to use arrays than fetching from database every time someone wants to view this dialog.

EDIT : Your other topic reminded me about using GROUP BY clause here. Simply retrieve data using GROUP BY, it'll require only a single query. Then you can use the retrieved data to format your string. Check your other topic for further information. I'm not bumping this topic since it's the same topic author for the other topic too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)