SA-MP Forums Archive
mysql onplayerlogin - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: mysql onplayerlogin (/showthread.php?tid=69005)



mysql onplayerlogin - Think - 15.03.2009

i got an error in the code below i can't go on without this code please help me.

Код:
Error in mysql_query: Commands out of sync; you can't run this command now
in this code:

pawn Код:
public OnPlayerLogin(playerid,const string[])
{
    if (gdebug >= 1){printf("DEBUG OnPlayerLogin(%d) (%s)", playerid,string);}
    new string2[64];
    new string3[64];
    //new password[64];
    new tmp2[256];
    new query[128];
    new playername2[26];
    GetPlayerName(playerid, playername2, 26);
    format(query, sizeof(query), "SELECT * FROM users WHERE name='%s' AND password='%s' ", playername2, string);
    samp_mysql_query(query);
    if(samp_mysql_num_rows()>0)
    {
        format(query, sizeof(query), "SELECT * FROM players WHERE name='%s'", playername2);
        samp_mysql_query(query);
        samp_mysql_store_result();
        if(samp_mysql_num_rows()>0)
        {
        new Data[1024];
        new Field[64];
        new rcnt = 1;
        samp_mysql_strtok(Field, "|", Data);
        while (samp_mysql_strtok(Field, "|", "")==1)
        {
            if(rcnt == 2) PlayerInfo[playerid][pAdmin] = strval(Field);
            if(rcnt == 4) PlayerInfo[playerid][pLevel] = strval(Field);
            if(rcnt == 5) PlayerInfo[playerid][pExp] = strval(Field);
            if(rcnt == 6) PlayerInfo[playerid][pDrugs] = strval(Field);
            if(rcnt == 7) PlayerInfo[playerid][pCash] = strval(Field);
            if(rcnt == 8) PlayerInfo[playerid][pAccount] = strval(Field);
            if(rcnt == 9) PlayerInfo[playerid][pJRank] = strval(Field);
            if(rcnt == 10) PlayerInfo[playerid][pModel] = strval(Field);
            if(rcnt == 12) PlayerInfo[playerid][pRank] = strval(Field);
            if(rcnt == 13) PlayerInfo[playerid][pTeam] = strval(Field);
            if(rcnt == 14) PlayerInfo[playerid][gPupgrade] = strval(Field);
            if(rcnt == 15) PlayerInfo[playerid][pKills] = strval(Field);
            if(rcnt == 16) PlayerInfo[playerid][pCB] = strval(Field);
            if(rcnt == 17) PlayerInfo[playerid][pHW] = strval(Field);
            if(rcnt == 18) PlayerInfo[playerid][pSR] = strval(Field);
            if(rcnt == 19) PlayerInfo[playerid][pWA] = strval(Field);
            if(rcnt == 20) PlayerInfo[playerid][pPEN] = strval(Field);
            if(rcnt == 21) PlayerInfo[playerid][pGun1] = strval(Field);
            if(rcnt == 22) PlayerInfo[playerid][pGun2] = strval(Field);
            if(rcnt == 23) PlayerInfo[playerid][pGun3] = strval(Field);
            if(rcnt == 24) PlayerInfo[playerid][pGun4] = strval(Field);
            if(rcnt == 25) PlayerInfo[playerid][pGun5] = strval(Field);
            if(rcnt == 26) PlayerInfo[playerid][pGun6] = strval(Field);
            if(rcnt == 27) PlayerInfo[playerid][pGun7] = strval(Field);
            if(rcnt == 28) PlayerInfo[playerid][pAmmo1] = strval(Field);
            if(rcnt == 29) PlayerInfo[playerid][pAmmo2] = strval(Field);
            if(rcnt == 30) PlayerInfo[playerid][pAmmo3] = strval(Field);
            if(rcnt == 31) PlayerInfo[playerid][pAmmo4] = strval(Field);
            if(rcnt == 32) PlayerInfo[playerid][pAmmo5] = strval(Field);
            if(rcnt == 33) PlayerInfo[playerid][pAmmo6] = strval(Field);
            if(rcnt == 34) PlayerInfo[playerid][pAmmo7] = strval(Field);
            if(rcnt == 35) PlayerInfo[playerid][pPos_x] = strval(Field);
            if(rcnt == 36) PlayerInfo[playerid][pPos_y] = strval(Field);
            if(rcnt == 37) PlayerInfo[playerid][pPos_z] = strval(Field);
            if(rcnt == 38) PlayerInfo[playerid][pLicenseA] = strval(Field);
            if(rcnt == 39) PlayerInfo[playerid][pLicenseB] = strval(Field);
            if(rcnt == 40) PlayerInfo[playerid][pLicenseC] = strval(Field);
            if(rcnt == 41) PlayerInfo[playerid][pInt] = strval(Field);
            if(rcnt == 42) PlayerInfo[playerid][pLocal] = strval(Field);
            if(rcnt == 43) PlayerInfo[playerid][pPnumber] = strval(Field);
            if(rcnt == 44) PlayerInfo[playerid][pPhousekey] = strval(Field);
            if(rcnt == 45) PlayerInfo[playerid][pPbiskey] = strval(Field);
            if(rcnt == 46) PlayerInfo[playerid][pDuty] = strval(Field);
            if(rcnt == 48) PlayerInfo[playerid][pWarnL] = strval(Field);
            if(rcnt == 49) PlayerInfo[playerid][pSArmour] = strval(Field);
            if(rcnt == 50) PlayerInfo[playerid][pJailed] = strval(Field);
            if(rcnt == 51) PlayerInfo[playerid][pStored] = strval(Field);
            if(rcnt == 52) PlayerInfo[playerid][pIP] = strval(Field);
            rcnt++;
        }
            samp_mysql_free_result();
for people who say use pastebin:

http://pandabeer1337.pastebin.com/f7a2e1852


Re: mysql onplayerlogin - MenaceX^ - 15.03.2009

Didn't you make exactly the same topic yesterday?


Re: mysql onplayerlogin - Think - 15.03.2009

Quote:
Originally Posted by MenaceX^
Didn't you make exactly the same topic yesterday?
its 3 pages back now if i bump ya'll start crying and now help me or dont reply pls.


Re: mysql onplayerlogin - Think - 15.03.2009

bummp and cry


Re: mysql onplayerlogin - Marcel - 15.03.2009

Add a
pawn Код:
samp_mysql_store_result();
after the first
pawn Код:
samp_mysql_query(query);



Re: mysql onplayerlogin - MenaceX^ - 15.03.2009

I already tried to help you in PMs.