Limit Account?
#1

Hello, if 2400+ accounts created in the SQL database, the command /factios no works. I say: "SERVER: Unknown Command."
Код HTML:
CMD:factions(playerid, params [])
{
    new id, tmp[270], string[1155];
    sscanf(params, "u", id);
    if(pInfo[playerid][pAdmin] < 6)
    {
        if (isnull(params))
        {
            format(tmp, sizeof(tmp), "Faction\tLocation\tLeader\n");
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "Police Department\tLos Santos\t%s\n", GetFactionLeader(1));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "Federal Bureau of Investigations\tLos Santos\t%s\n", GetFactionLeader(2));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "National Guard\tLas Venturas\t%s\n", GetFactionLeader(3));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "Paramedics Department\tLos Santos\t%s\n", GetFactionLeader(4));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "Taxi LS\tLos Santos\t%s\n", GetFactionLeader(5));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "News Reporter\tLas Venturas\t%s\n", GetFactionLeader(6));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "School Instructor\tLos Santos\t%s\n", GetFactionLeader(7));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "Hitman\tLos Santos\t%s\n", GetFactionLeader(8));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "Grove Street\tLos Santos\t%s\n", GetFactionLeader(9));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "The Ballas\tLos Santos\t%s\n", GetFactionLeader(10));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "agos\tLos Santos\t%s\n", GetFactionLeader(11));
            strcat(string, tmp);
            format(tmp, sizeof(tmp), "Russian Mafia\tLas Venturas\t%s\n", GetFactionLeader(12));
            strcat(string, tmp);
        }
    }
    return 1;
}
Код HTML:
GetFactionLeader(id)
{
    new query[200];
    mysql_format(MySQLCon, query, sizeof (query), "SELECT user, ID, LastLogin FROM `players` WHERE `Leader` = '%i'", id);
    new 
        name[MAX_PLAYER_NAME+15],
        idp,
        Cache:result = mysql_query(MySQLCon, query);

    if(cache_num_rows()) {
        cache_get_field_content(0, "user", name);
        idp = cache_get_field_content_int(0, "ID");
        cache_get_field_content(0, "LastLogin", sLeaderF), strmid(pInfo[idp][pLastLogin], sLeaderF, 0, 255, 255);
        if(IsPlayerConnected(ReturnUser(name))) { format(name, sizeof (name), "%s (Online)", name); }
        else { format(name, sizeof (name), "%s (Offline)", name); }
    }
    else { format(name, sizeof (name), "No Leader"); sLeaderF = "-"; }
    cache_delete(result);
    return name;
}
Reply
#2

Hmm, your datamodel is questionable at best. 'Leader' should be an attribute of Faction, not an attribute of Player. As a quick patch you can put an index on that 'leader' column to speed up table lookups, but in the long term you should probably restructure the datamodel.

Also run an explain query (within phpMyAdmin or other client) and put the output here:
PHP код:
EXPLAIN SELECT userIDLastLogin FROM `playersWHERE `Leader` = '1' 
If it says something like "table scan" or indicates the possible keys as NULL then that's bad.
Reply
#3

NULL!
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Hmm, your datamodel is questionable at best. 'Leader' should be an attribute of Faction, not an attribute of Player. As a quick patch you can put an index on that 'leader' column to speed up table lookups, but in the long term you should probably restructure the datamodel.

Also run an explain query (within phpMyAdmin or other client) and put the output here:
PHP код:
EXPLAIN SELECT userIDLastLogin FROM `playersWHERE `Leader` = '1' 
If it says something like "table scan" or indicates the possible keys as NULL then that's bad.
Reply
#5

I clearly said, and let me quote and emphasize myself:
Quote:
within phpMyAdmin or other client
This query is only meant for performance analysis. It is not meant to be put in code, nor did I hint that it should be.
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
I clearly said, and let me quote and emphasize myself:

This query is only meant for performance analysis. It is not meant to be put in code, nor did I hint that it should be.
Reply
#7

BUMP!
Reply
#8

Like I predicted, full table scan and no key. Put an index on the leader column. Go to structure tab and click 'index' button next to leader column. Then run the explain query again.
Reply
#9

Quote:
Originally Posted by Vince
Посмотреть сообщение
Like I predicted, full table scan and no key. Put an index on the leader column. Go to structure tab and click 'index' button next to leader column. Then run the explain query again.
Reply
#10

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)