Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public OnAccountCheck(playerid)
- {
- new rows, fields, query[200]; //a variable that will be used to retrieve rows and fields in the database.
- cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
- mysql_format(mysql,query, sizeof(query), "SELECT * FROM `players` WHERE Username = '%e' LIMIT 1", Name[playerid]); //Formats the query, view above the code for a explanation
- mysql_tquery(mysql,query,"",""); //This is our query function to query the string
- if(rows) //if there is row
- {//then
- cache_get_field_content(0, "IP", IP[playerid], mysql, 16);
- new newIP[16];
- GetPlayerIp(playerid, newIP, 16);
- if(strlen(IP[playerid]) != 0 && !strcmp(IP[playerid], newIP, true)) //Checks that the MySQL IP has a value and that they are the same.
- {
- OnPlayerAccountLoad(playerid);
- SendClientMessage(playerid, -1, "AUTO IP LOGGED IN SUCCESS");
- }
- else
- {
- (!strlen(IP[playerid]) || strcmp(IP[playerid], newIP, true));
- cache_get_field_content(0, "Password", pInfo[playerid][Password], mysql, 129);
- //we will load player's password into pInfo[playerid][Password] to be used in logging in
- pInfo[playerid][ID] = cache_get_field_content_int(0, "ID"); //now let's load player's ID into pInfo[playerid][ID] so we can use it later
- printf("%s", pInfo[playerid][Password]); //OPTIONAL: Just for debugging. If it didn't show your password, then there must be something wrong while getting player's password
- ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login", "Login", "Quit"); //And since we found a result from the database, which means, there is an account; we will show a login dialog
- }
- }
- else //if we didn't find any rows from the database, that means, no accounts were found
- {
- ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.", "Register", "Quit");
- //So we show them a dialog register
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement