SA-MP Forums Archive
Fix me - 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: Fix me (/showthread.php?tid=356720)



Mysql Retrieval Issue - syruz - 04.07.2012

I have been working on this for weeks and cannot for the life of me figure out what the fuck is wrong with it:
pawn Код:
public OnPlayerLogin(playerid, password[])
{

    SetPVarInt(playerid,"Spectating",0);
    TogglePlayerSpectating(playerid, 0);
    SetPlayerInterior(playerid, 0);
    SetPlayerVirtualWorld(playerid, 0);
    new name[MAX_PLAYER_NAME], str[128],ip[20], query[1024], data[256];// cmdtext;
    GetPlayerName(playerid, name, sizeof name);
    GetPlayerIp(playerid,ip,sizeof ip);
  //  format(query, sizeof(query),"UPDATE Player_Data SET ip='%s' WHERE username='%s'", ip, PlayerName(playerid));
   // mysql_query(query);
    format(query, sizeof(query), "SELECT * FROM Player_Data WHERE username = '%s' AND password = '%s'", PlayerName(playerid), password);
    mysql_query(query);
    mysql_store_result();
    mysql_retrieve_row();
    {
            if(mysql_fetch_field_row (data, "password"))
            {
                {
                    mysql_fetch_field_row(data, "adminlvl");
                    UserInfo[playerid][Admin] = strval(data);

                    mysql_fetch_field_row(data, "registration_date");
                    UserInfo[playerid][Registration_Date] = strval(data);

                    mysql_fetch_field_row(data, "registration_time");
                    UserInfo[playerid][Registration_Time] = strval(data);

                    mysql_fetch_field_row(data, "last_seen");
                    UserInfo[playerid][LastSeen] = strval(data);

                    mysql_fetch_field_row(data, "ip");
                    UserInfo[playerid][IP] = strval(data);

                    mysql_fetch_field_row(data, "caradmin");
                    UserInfo[playerid][Caradmin] = strval(data);

                    mysql_fetch_field_row(data, "cash");
                    UserInfo[playerid][Cash] = strval(data);

                    mysql_fetch_field_row(data, "score");
                    UserInfo[playerid][Score] = strval(data);

                    mysql_fetch_field_row(data, "banned");
                    UserInfo[playerid][Banned] = strval(data);

                    mysql_fetch_field_row(data, "vehicleid");
                    UserInfo[playerid][Vehicle] = strval(data);

                    mysql_fetch_field_row(data, "warnings");
                    UserInfo[playerid][Warnings] = strval(data);

                    mysql_fetch_field_row(data, "kicks");
                    UserInfo[playerid][Kicks] = strval(data);

                    mysql_fetch_field_row(data, "tempbans");
                    UserInfo[playerid][Tempbans] = strval(data);

                    mysql_fetch_field_row(data, "punishments");
                    UserInfo[playerid][Punishments] = strval(data);

                    mysql_fetch_field_row(data,"totalpunishments");
                    UserInfo[playerid][tPunishments] = strval(data);
                }
                SetPVarInt(playerid, "Popup.Login", 0);
                UserInfo[playerid][Logged] = 1;
                GivePlayerMoney(playerid, UserInfo[playerid][Cash]);
                SetPlayerScore(playerid, UserInfo[playerid][Score]);
                DeletePVar(playerid, "Popup.Login");


            }
            else
            {
                PassFail[playerid]++;
                if(GetPVarInt(playerid, "PassAttempt") != 3)
                {
                    switch(PassFail[playerid])
                    {
                        case 1:
                        {
                            ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_INPUT, "Login", "Incorrect password, you have 2 attempts left out of 3", "Login", "Quit");
                        }
                        case 2:
                        {
                            ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_INPUT, "Login", "Incorrect password, you have 1 attempt left out of 3", "Login", "Quit");
                        }
                        case 3:
                        {
                            SendClientMessage(playerid, COLOR_CYAN,"You have failed to login, you are now kicked");
                            Kick(playerid);
                            return 1;
                        }
                    }
                    return 1;
                }
                mysql_free_result();
                return 1;
            }
        }
        SetPVarInt(playerid, "Admin", UserInfo[playerid][Admin]);
        GetPlayerIp(playerid, ip, 20);
        format(str, sizeof str, "You are logged in!", name);
        SendClientMessage(playerid, COLOR_GREEN, str);
        printf("[part] %s has logged in", name);


        if (UserInfo[playerid][Caradmin] == 1)
        {
            format(str, sizeof str, "Welcome back, Vehicle Administrator");
            SendClientMessage(playerid, COLOR_LIGHTYELLOW, str);
        }

        if (UserInfo[playerid][Admin] == 1)
        {
            format(str, sizeof str, "Welcome back, Moderator!");
            SendClientMessage(playerid, COLOR_LIGHTYELLOW, str);
        }

        if (UserInfo[playerid][Admin] == 2)
        {
            format(str, sizeof str, "Welcome back, Administrator!");
            SendClientMessage(playerid, COLOR_LIGHTYELLOW, str);
        }

        if (UserInfo[playerid][Admin] == 3)
        {
            format(str, sizeof str, "Welcome back, Manager!");
            SendClientMessage(playerid, COLOR_LIGHTYELLOW, str);
        }

        if (UserInfo[playerid][Admin] == 4)
        {
            format(str, sizeof str, "Welcome back, Developer!");
            SendClientMessage(playerid, COLOR_LIGHTYELLOW, str);
        }

        if (UserInfo[playerid][Admin] == 5)
        {
            format(str, sizeof str, "Welcome back, Leader!");
            SendClientMessage(playerid, COLOR_LIGHTYELLOW,str);
        }
        CreateRecordFile(playerid);

        if(strlen(dini_Get("aliases/alias.txt", ip)) == 0)
        {
            dini_Set("aliases/alias.txt", ip, name);
        }
        else
        {
            if( strfind( dini_Get("Aliases/alias.txt", ip), name, true) == -1 )
            {
                format(str,sizeof(str),"%s, %s", dini_Get("Aliases/alias.txt",ip), name);
                dini_Set("Aliases/alias.txt", ip, str);
            }
        }

    }
    StopAudioStreamForPlayer(playerid);
    return 1;

}
This is after trying to figure out how to swap from one old outdated mysql plugin to BlueG's One


Re: Fix me - syruz - 05.07.2012

As you can see the script compiles properly, the problem is with the MYSQL part, it for some reason in the debug tells me its working fine, but does not actually Collect any information from the server.


Re: Fix me - TheLazySloth - 05.07.2012

Get rid of mysql_retrieve_row() - Unless you have it there for some type of reason

Then afterwards edit,
if(mysql_fetch_field_row (data, "password"))
to,
if(mysql_fetch_field_row (query, "|"))


Re: Fix me - syruz - 05.07.2012

Still does not work, the login script does not even recognize there is a password, i know the mysql is working as it is prompting my account for a password, and registering an account does work.


Re: Fix me - syruz - 10.07.2012

Anyone have any idea, its been killing me trying to fix this thing, ive tried it just about every possible way except the right way.