SA-MP Forums Archive
need a bit help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: need a bit help (/showthread.php?tid=382183)



need a bit help - mineralo - 02.10.2012

well, I'm started to work in mysql database and players have a lot stuff to save and to load, how to do more faster to load players' stuff?
pawn Код:
forward onTHREAD_CompleteLoadPlayer(playerid);
public onTHREAD_CompleteLoadPlayer(playerid)
{
    new temp[2][129];
    new months,days,years,rows,fields,year,month,day;
    cache_get_data(rows, fields);
    for(new i = 0; i < rows; i++)
    {
        cache_get_row(i, 0, temp[0]);
        cache_get_row(i, 1, temp[1]);
        //this can be switched to something much faster
        if(!strcmp(temp[0], "Score", true))
        {
            PlayerInfo[playerid][pScore] = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "Admin", true))
        {
            PlayerInfo[playerid][pAdmin] = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "Job", true))
        {
            PlayerInfo[playerid][pJob] = strval(temp[1]);
            SetJob(playerid, PlayerInfo[playerid][pJob]);
        }
        else if(!strcmp(temp[0], "GCash", true))
        {
            PlayerInfo[playerid][pGCash] = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "Kills", true))
        {
            PlayerInfo[playerid][pKills] = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "Deaths", true))
        {
            PlayerInfo[playerid][pDeaths] = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "health", true))
        {
            healthP[playerid] = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "x", true))
        {
             PosX[playerid]  = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "y", true))
        {
             PosY[playerid]  = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "z", true))
        {
             PosZ[playerid]  = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "Interior", true))
        {
             Inter[playerid]  = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "Last_Log_Day", true))
        {
            days = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "Last_Log_Month", true))
        {
            months = strval(temp[1]);
        }
        else if(!strcmp(temp[0], "Last_Log_Year", true))
        {
            years = strval(temp[1]);
        }
    }
    LoadWeaponsFromDatabase(playerid);
    Logged[playerid] = true;
    return 1;
}
this is my loading system, I deleted from it to make it short


Re: need a bit help - Vince - 02.10.2012

Wait what? Let me see your table structure.


Re: need a bit help - mineralo - 02.10.2012

I can't show you the table structure


Re: need a bit help - doreto - 02.10.2012

Quote:
Originally Posted by mineralo
Посмотреть сообщение
I can't show you the table structure
Then what did you expect , to help you wichout see your code