[Plugin] [REL] MySQL Plugin (Now on github!)

Been trying to use this plugin with the CWRP (the base plugin doesn't works at linux / is bugged) gamemode but the login bugs completely... This is my code, it doesn't even finishs, the server keeps running but the player just 'frozes', even though some sendclientmessage (example: you are not logged etc) will still be sent to the user after some time.

pawn Код:
stock loginPlayer(playerid, const senha[50])
{
    new field[120][1024];
    new query[256], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    format(query, sizeof(query), "SELECT * FROM players WHERE Name = '%s'", pname);
    mysql_query(query);
    mysql_store_result();
    if(mysql_fetch_row(data))
    {
        splith(data, field, '|');
        PlayerInfo[playerid][pLevel] = strval(field[3]);
        PlayerInfo[playerid][pAdmin] = strval(field[4]);
        PlayerInfo[playerid][pDonateRank] = strval(field[5]);
        PlayerInfo[playerid][gPupgrade] = strval(field[6]);
        PlayerInfo[playerid][pConnectTime] = strval(field[7]);
        PlayerInfo[playerid][pReg] = strval(field[8]);
        PlayerInfo[playerid][pSex] = strval(field[9]);
        PlayerInfo[playerid][pAge] = strval(field[10]);
        PlayerInfo[playerid][pOrigin] = strval(field[11]);
        PlayerInfo[playerid][pCK] = strval(field[12]);
        PlayerInfo[playerid][pMuted] = strval(field[13]);
        PlayerInfo[playerid][pExp] = strval(field[14]);
        PlayerInfo[playerid][pCash] = strval(field[15]);
        PlayerInfo[playerid][pAccount] = strval(field[16]);
        PlayerInfo[playerid][pCrimes] = strval(field[17]);
        PlayerInfo[playerid][pKills] = strval(field[18]);
        PlayerInfo[playerid][pDeaths] = strval(field[19]);
        PlayerInfo[playerid][pArrested] = strval(field[20]);
        PlayerInfo[playerid][pWantedDeaths] = strval(field[21]);
        PlayerInfo[playerid][pPhoneBook] = strval(field[22]);
        PlayerInfo[playerid][pLottoNr] = strval(field[23]);
        PlayerInfo[playerid][pFishes] = strval(field[24]);
        PlayerInfo[playerid][pBiggestFish] = strval(field[25]);
        PlayerInfo[playerid][pJob] = strval(field[26]);
        PlayerInfo[playerid][pPayCheck] = strval(field[27]);
        PlayerInfo[playerid][pHeadValue] = strval(field[28]);
        PlayerInfo[playerid][pJailed] = strval(field[29]);
        PlayerInfo[playerid][pJailTime] = strval(field[30]);
        PlayerInfo[playerid][pMats] = strval(field[31]);
        PlayerInfo[playerid][pDrugs] = strval(field[32]);
        PlayerInfo[playerid][pLeader] = strval(field[33]);
        PlayerInfo[playerid][pMember] = strval(field[34]);
        PlayerInfo[playerid][pFMember] = strval(field[35]);
        PlayerInfo[playerid][pRank] = strval(field[36]);
        PlayerInfo[playerid][pChar] = strval(field[37]);
        PlayerInfo[playerid][pContractTime] = strval(field[38]);
        PlayerInfo[playerid][pDetSkill] = strval(field[39]);
        PlayerInfo[playerid][pSexSkill] = strval(field[40]);
        PlayerInfo[playerid][pBoxSkill] = strval(field[41]);
        PlayerInfo[playerid][pLawSkill] = strval(field[42]);
        PlayerInfo[playerid][pMechSkill] = strval(field[43]);
        PlayerInfo[playerid][pJackSkill] = strval(field[44]);
        PlayerInfo[playerid][pCarSkill] = strval(field[45]);
        PlayerInfo[playerid][pNewsSkill] = strval(field[46]);
        PlayerInfo[playerid][pDrugsSkill] = strval(field[47]);
        PlayerInfo[playerid][pCookSkill] = strval(field[48]);
        PlayerInfo[playerid][pFishSkill] = strval(field[49]);
        PlayerInfo[playerid][pSHealth] = floatstr(field[50]);
        PlayerInfo[playerid][pHealth] = floatstr(field[51]);
        PlayerInfo[playerid][pInt] = strval(field[52]);
        PlayerInfo[playerid][pLocal] = strval(field[53]);
        PlayerInfo[playerid][pTeam] = strval(field[54]);
        PlayerInfo[playerid][pModel] = strval(field[55]);
        PlayerInfo[playerid][pPnumber] = strval(field[56]);
        PlayerInfo[playerid][pPhousekey] = strval(field[57]);
        PlayerInfo[playerid][pPcarkey] = strval(field[58]);
        PlayerInfo[playerid][pPapptkey] = strval(field[59]);
        PlayerInfo[playerid][pPbiskey] = strval(field[60]);
        PlayerInfo[playerid][pPos_x] = floatstr(field[61]);
        PlayerInfo[playerid][pPos_y] = floatstr(field[62]);
        PlayerInfo[playerid][pPos_z] = floatstr(field[63]);
        PlayerInfo[playerid][pCarLic] = strval(field[64]);
        PlayerInfo[playerid][pFlyLic] = strval(field[65]);
        PlayerInfo[playerid][pBoatLic] = strval(field[66]);
        PlayerInfo[playerid][pFishLic] = strval(field[67]);
        PlayerInfo[playerid][pGunLic] = strval(field[68]);
        PlayerInfo[playerid][pGun1] = strval(field[69]);
        PlayerInfo[playerid][pGun2] = strval(field[70]);
        PlayerInfo[playerid][pGun3] = strval(field[71]);
        PlayerInfo[playerid][pGun4] = strval(field[72]);
        PlayerInfo[playerid][pAmmo1] = strval(field[73]);
        PlayerInfo[playerid][pAmmo2] = strval(field[74]);
        PlayerInfo[playerid][pAmmo3] = strval(field[75]);
        PlayerInfo[playerid][pAmmo4] = strval(field[76]);
        PlayerInfo[playerid][pCarTime] = strval(field[77]);
        PlayerInfo[playerid][pPayDay] = strval(field[78]);
        PlayerInfo[playerid][pPayDayHad] = strval(field[79]);
        PlayerInfo[playerid][pCDPlayer] = strval(field[80]);
        PlayerInfo[playerid][pWins] = strval(field[81]);
        PlayerInfo[playerid][pLoses] = strval(field[82]);
        PlayerInfo[playerid][pAlcoholPerk] = strval(field[83]);
        PlayerInfo[playerid][pDrugPerk] = strval(field[84]);
        PlayerInfo[playerid][pMiserPerk] = strval(field[85]);
        PlayerInfo[playerid][pPainPerk] = strval(field[86]);
        PlayerInfo[playerid][pTraderPerk] = strval(field[87]);
        PlayerInfo[playerid][pTut] = strval(field[88]);
        PlayerInfo[playerid][pMissionNr] = strval(field[89]);
        PlayerInfo[playerid][pWarns] = strval(field[90]);
        PlayerInfo[playerid][pAdjustable] = strval(field[91]);
        PlayerInfo[playerid][pFuel] = strval(field[92]);
        PlayerInfo[playerid][pMarried] = strval(field[93]); // QUATRO \/
        PlayerInfo[playerid][pMarriedTo] = strmid(PlayerInfo[playerid][pMarriedTo], field[94], 0, strlen(field[94])-1, 255);
        PlayerInfo[playerid][pLinked] = strval(field[96]); // 96
        PlayerInfo[playerid][pDeagle] = strval(field[97]);
        PlayerInfo[playerid][pShotgun] = strval(field[98]);
        PlayerInfo[playerid][pRifle] = strval(field[99]);
        PlayerInfo[playerid][pSDPistol] = strval(field[100]);
        PlayerInfo[playerid][pMP5] = strval(field[101]);
        PlayerInfo[playerid][pM4] = strval(field[102]);
        PlayerInfo[playerid][pAK47] = strval(field[103]);
        format(PlayerInfo[playerid][pStartIP], 16, "%s", field[104]);
        format(PlayerInfo[playerid][pEndIP], 16, "%s", field[105]);
        PlayerInfo[playerid][pLocker] = strval(field[106]);
        PlayerInfo[playerid][pRadioFrequency] = strval(field[107]);
        PlayerInfo[playerid][pRadio] = strval(field[108]);
        PlayerInfo[playerid][pPecArm] = strval(field[109]);
        PlayerInfo[playerid][pMesa] = strval(field[110]);
        PlayerInfo[playerid][pLuvas] = strval(field[111]);
        drugInfo[playerid][dgCocaina] = strval(field[112]);
        drugInfo[playerid][dgMaconha] = strval(field[113]);
        drugInfo[playerid][dgOpio] = strval(field[114]);
        drugInfo[playerid][dgCrack] = strval(field[115]);
        drugInfo[playerid][dgMeth] = strval(field[116]);
        drugInfo[playerid][dgHeroina] = strval(field[117]);
        drugInfo[playerid][dgHaxixe] = strval(field[118]);
        PlayerInfo[playerid][pPcarkey2] = strval(field[119]);
        mysql_free_result();
        PlayerInfo[playerid][pAdjustable] = 0;
        ResetPlayerCash(playerid);
        GivePlayerCash(playerid,PlayerInfo[playerid][pCash]);
        if(PlayerInfo[playerid][pReg] == 0)
        {
            PlayerInfo[playerid][pLevel] = 1;
            PlayerInfo[playerid][pSHealth] = 0.0;
            PlayerInfo[playerid][pHealth] = 100.0;
            PlayerInfo[playerid][pPos_x] = NOOB_X;
            PlayerInfo[playerid][pPos_y] = NOOB_Y;
            PlayerInfo[playerid][pPos_z] = NOOB_Z;
            PlayerInfo[playerid][pInt] = 0;
            PlayerInfo[playerid][pLocal] = 1;
            PlayerInfo[playerid][pTeam] = 3;
            PlayerInfo[playerid][pModel] = 135;
            new randphone = 10000000 + random(89999999);
            PlayerInfo[playerid][pNumero] = randphone;
            PlayerInfo[playerid][pPhousekey] = 255;
            PlayerInfo[playerid][pPcarkey] = 999;
            PlayerInfo[playerid][pPcarkey2] = 999;
            PlayerInfo[playerid][pPcarkey3] = 999;
            PlayerInfo[playerid][pPapptkey] = 255;
            PlayerInfo[playerid][pPbiskey] = 255;
            PlayerInfo[playerid][pAccount] = 0;
            PlayerInfo[playerid][pReg] = 1;
            GivePlayerCash(playerid, 500);
        }
        if(PlayerInfo[playerid][pLevel] == -999) return Ban(playerid);
        gPlayerLogged[playerid] = 1;
        SpawnPlayer(playerid);
        if(PlayerInfo[playerid][pDonateRank]==0)
        {
            PlayerInfo[playerid][pMascara]=0;
        }
        SetPlayerSpawn(playerid);
        DateProp(playerid);
        load_peixes(playerid);
        load_celular(playerid);
        LoadNewProfile(playerid);
        SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin1]);
        SetPVarInt(playerid, "logouAgora", 1);
        print("Erro? carregardados4(playerid) 02");
        format(data, 3, " ");
        SetTimerEx("LoadArmas", 3000, false, "i", playerid);
        ClearChatbox(playerid, 10);
        return 1;
    }
}
PS: I know about the lack of password check. I'm just testing.
Reply

@russ0, you should consider using sscanf as a data parser. It has a built in delimiter so you don't need split. And the Linux build is buggy iirc.
Reply

Can you give me an example on how to use the sscanf on my situation? I've seen it before but I've never used it, but I'll be testing some ways to do it. I'm not using the linux build now though.
Reply

Works perfect!

Just one question:
Can i enable logging for errors only?
Reply

Quote:
Originally Posted by Blowfish
Посмотреть сообщение
The first one is that this MySQL plugin does not seem to be able to fetch multiline strings.
i did a decent workaround by using mysql replace() function.
Reply

The plugin has been updated after almost one year once again due to a threading bug which was discovered by xxmitsu. I have added mutexes to make sure shared variables don't get accessed twice by different threads at the same time. (which causes random crashes) Besides that I have made some code improvements and fixed some small bugs.

I advice everyone who uses the threading capabilities to update to R6, the files are as usual in the first post.

Great thanks for this release goes to xxmitsu for testing and compiling the plugin on Debian5 and CentOS.
Reply

Can you make one for GLIBCXX_4.3.8? I don't really got how to do that...
Reply

Quote:
Originally Posted by G-sTyLeZzZ
Посмотреть сообщение
The plugin has been updated after almost one year once again due to a threading bug which was discovered by xxmitsu. I have added mutexes to make sure shared variables don't get accessed twice by different threads at the same time. (which causes random crashes) Besides that I have made some code improvements and fixed some small bugs.

I advice everyone who uses the threading capabilities to update to R6, the files are as usual in the first post.

Great thanks for this release goes to xxmitsu for testing and compiling the plugin on Debian5 and CentOS.
this is the cause of a thread loading then another thread loading causing the first thread to like.. stop?

great update.

i don't think i did anything wrong but, it still says Mysql Plugin R5 successfully loaded
Reply

Код:
[17:50:40] 

  > MySQL plugin R5 successfully loaded.

[17:50:40]   Loaded.
What da..
Reply

Quote:
Originally Posted by kacper55331
Посмотреть сообщение
Код:
[17:50:40] 

  > MySQL plugin R5 successfully loaded.

[17:50:40]   Loaded.
What da..

Yeah, I guess he forgot to change...
Reply

If you compiled it from source, the version string isn't updated/changed with the string "R6" (if that annoys you, you can change that yourself).

But if you compare the source code with the previous version(R5), you'll see that there's a mutex implementation.
Код:
	while(true) {
		Mutex::getInstance()->_lockMutex();
And yes, It's just something that was forgot to be changed in the source code. The compiled binaries are just fine.
Reply

Hmm, it may just be me but I have downloaded the R6 version but it still loads R5, I find it very weird.
Reply

Read what is said above, Luis.
Reply

Quote:
Originally Posted by -Luis
Посмотреть сообщение
Hmm, it may just be me but I have downloaded the R6 version but it still loads R5, I find it very weird.
has your "mysql log" changed to "Debug"? if it has.. then its changed
Reply

R6 works fine for me.

Nice update btw!
Reply

I appreciate the fixes, thank you.
Reply

Thanks for the update.
Reply

The new plugin versions crashes my server (100% CPU usage) when i try to reload an FS that uses MySQL

I am using mysql_close() in OnFilterScriptExit, and it works perfectly fine in R5 (switched back to R5, made no changes in the script)

Running Linux (ServerFFS) with the CentOS plugin versions
Reply

If there are display succefully ,then yes.
Reply

But the current version is R6, and he shows R5..
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)