SA-MP Forums Archive
BlueG Mysql 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: BlueG Mysql help (/showthread.php?tid=435319)



BlueG Mysql help - Stefand - 06.05.2013

Hey There,

I started using Mysql for the first time today, I followed some tutorials but they turn out to be out-dated.
How do I change these things into a working BlueG mysql system?

pawn Код:
public OnPlayerConnect(playerid)
{
    new query[126];
    format(query, sizeof(query), "SELECT * FROM accounts WHERE name = '%s'", GetName(playerid));
    mysql_query(query);
    mysql_store_result();
   
    if(mysql_num_rows() == 1)
    {
        SendClientMessage(playerid, RED, "This account is already registered");
        ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, "Login", "Please login with your password", "Login", "Cancel");
    }
    else
    {
        SendClientMessage(playerid, GREEN, "This account does not exist yet");
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Please Register by entering a password", "Register", "Cancel");
    }
    return 1;
}
pawn Код:
stock LoginPlayer(playerid)
{
    new query[126];
    format(query, sizeof(query), "SELECT * FROM accounts WHERE name = '%s'", GetName(playerid));
    mysql_query(query);
    mysql_store_result();

    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(Player[playerid][Name], "Name");
        mysql_fetch_field_row(Player[playerid][Password], "Password");
        mysql_fetch_field_row(Player[playerid][Adminlevel], "Adminlevel");
    }
    SetSpawnInfo(playerid, 0, 240, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0);
    SpawnPlayer(playerid);
}

stock SavePlayer(playerid)
{
    new query[126];
    format(query, sizeof(query), "UPDATE accounts SET name = '%s', password = '%s', Adminlevel = '%s' WHERE name = '%s'", GetName(playerid), Player[playerid][Password], Player[playerid][Adminlevel], GetName(playerid));
    mysql_query(query);
   
    printf("Player %d (%s) has been saved because of disconecting", playerid, GetName(playerid));
}



Re: BlueG Mysql help - Scenario - 06.05.2013

That all depends on which version of BlueG's plugin you're using... so.. mind telling us?


Re: BlueG Mysql help - Stefand - 06.05.2013

The latest: R7


Re: BlueG Mysql help - Scenario - 06.05.2013

As the thread suggests, if you don't know the difference between a threaded and a non-threaded query, you shouldn't be using R7. Also, you may want to note that R7 is NOT the latest version. There are plenty more on the ****** Code download page (there's a link at the top of the plugin release thread).

Furthermore, there's a tutorial about using threaded queries (or, more accurately, the cache functions provided by the threaded queries part of the system) by AndreT. I'll suggest you check it out for yourself.

https://sampforum.blast.hk/showthread.php?tid=337810


Re: BlueG Mysql help - Stefand - 06.05.2013

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
As the thread suggests, if you don't know the difference between a threaded and a non-threaded query, you shouldn't be using R7. Also, you may want to note that R7 is NOT the latest version. There are plenty more on the ****** Code download page (there's a link at the top of the plugin release thread).

Furthermore, there's a tutorial about using threaded queries (or, more accurately, the cache functions provided by the threaded queries part of the system) by AndreT. I'll suggest you check it out for yourself.

https://sampforum.blast.hk/showthread.php?tid=337810
And what do I need to pick if I want to use non-threated query's ?


Re: BlueG Mysql help - Scenario - 06.05.2013

Obviously the version under R7. However, it would be utterly stupid of you to use non-threaded queries.


Re: BlueG Mysql help - Stefand - 06.05.2013

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Obviously the version under R7. However, it would be utterly stupid of you to use non-threaded queries.
Well I started to work with Mysql today for the first time so I dont understand a f*ck about it


Re: BlueG Mysql help - Scenario - 06.05.2013

That's why you learn how to do it the proper way; by using threaded queries.