Advertisement
Guest User

help

a guest
Dec 4th, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.11 KB | None | 0 0
  1. public OnAccountCheck(playerid)
  2. {
  3.    new rows, fields, query[200]; //a variable that will be used to retrieve rows and fields in the database.
  4.     cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
  5.     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
  6.     mysql_tquery(mysql,query,"",""); //This is our query function to query the string
  7.     if(rows) //if there is row
  8.     {//then
  9.         cache_get_field_content(0, "IP", IP[playerid], mysql, 16);
  10.         new newIP[16];
  11.         GetPlayerIp(playerid, newIP, 16);
  12.        
  13.         if(strlen(IP[playerid]) != 0 && !strcmp(IP[playerid], newIP, true)) //Checks that the MySQL IP has a value and that they are the same.
  14.         {
  15.             OnPlayerAccountLoad(playerid);
  16.             SendClientMessage(playerid, -1, "AUTO IP LOGGED IN SUCCESS");
  17.         }
  18.         else
  19.         {
  20.             (!strlen(IP[playerid]) || strcmp(IP[playerid], newIP, true));
  21.             cache_get_field_content(0, "Password", pInfo[playerid][Password], mysql, 129);
  22.             //we will load player's password into pInfo[playerid][Password] to be used in logging in
  23.             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
  24.             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
  25.             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
  26.         }
  27.     }
  28.     else //if we didn't find any rows from the database, that means, no accounts were found
  29.     {
  30.         ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.", "Register", "Quit");
  31.         //So we show them a dialog register
  32.     }
  33.     return 1;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement