MySQL doesn't fetch account info.
#1

Hi!

A few days ago, I updated my MySQL plugin from R1 or R2 (Dunno. ) to R6.
But now I've got a little problem. Due to the mysql_strtok removal, MySQL doesn't fetch player info any more.

The code with strtok:
pawn Код:
public OnPlayerLogin(playerid,password[]) // by Luk0r v1.0
{
    MySQLCheckConnection();
    new tmp2[256];
    new string2[64];
    new str[128];
    new
    string[256]
    ;
    new playername2[MAX_PLAYER_NAME];
    new playernamesplit[3][MAX_PLAYER_NAME];
    GetRPName(playerid, playername2, sizeof(playername2));
    split(playername2, playernamesplit, '_');
    MySQLFetchAcctSingle(KasutajaInfo[playerid][pSQLID], "Password", KasutajaInfo[playerid][pKey]);
    if(!strcmp(KasutajaInfo[playerid][pKey],password, true ) )
    {
        new Data[1024];
        new Field[64];
        new rcnt = 1;
        MySQLFetchAcctRecord(KasutajaInfo[playerid][pSQLID], Data);
        mysql_strtok(Field, "|", Data);
        while (mysql_strtok(Field, "|", "")==1)
        {
            if (rcnt == 3) KasutajaInfo[playerid][pLevel] = strval(Field);
            if (rcnt == 4) KasutajaInfo[playerid][pAdmin] = strval(Field);
                        //A couple more lines...
            rcnt++;
        }
    }
Reply
#2

This is very old , you better can rescript your mysql functions with the new plugin instead of trying to fix them, go to the wiki and follow some tutorials and you will be able to fix those things.
Reply
#3

I want to rescript it, but I don't know, how. (I'm a MySQL newbie. )
Reply
#4

Fact is that I saw your topic yesterday and could not begin forming a reply good enough to conclude it all. But considering that I'm perhaps somewhat familiar with this script and how it operates (and how functions like MySQLFetchAcctSingle are created by Luk0r to behave as wrappers for the plugin Dj-Adrenaline made and last updated 4 years ago), I can say it will require a complete rescript of your gamemode, and I don't think it is a good idea for a "MySQL newbie" as you claim to be to take on rescripting such a huge gamemode.

You have a few options here:
1. Skim over the guides posted around these forums. And by this, I also mean the plugin tutorial I made for R7 although it may be a little bit irrelevant since you use an older version of the plugin and will probably have to resort to unthreaded queries at first.
2. Start using a newer gamemode that's actually designed for newer coders, but regardless, pack a lot of interesting features to make a server owner happy. And most importantly, use newer plugins and newer coding practices (and this actually makes a big difference, both user-enjoyability and server efficiency will be improved).
3. Keep on using this gamemode the way it is. Conversions like this are in most cases, very hard to take on (specially if you are a beginner). In the best case, when working on code that someone else wrote, and specially if it is written in a bit different style than I would love, it takes me a few hours to few days to understand what does what. If the code is not explained or commented, the task gets even harder. That's just how it is, but with time (hopefully you're young at the moment), you'll become more experienced in reading code that others wrote. I'm glad seeing you were already able to find out where the player logging in goes down in a script that's probably last modified by the original author 3-4 years ago.

Good luck!
Reply
#5

Isn't it possible to change the mysql_strtok to sscanf?
Everything else works fine.
Reply
#6

Bump!
Reply
#7

Nvm. I got it fixed already.
Studied a little bit of MySQL and replaced it with mysql_fetch_field_row (or something like this )

Thanks anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)