Advertisement
Guest User

Untitled

a guest
Nov 11th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public OnPlayerLogin(playerid, type, password[])
  2. {
  3. mysql_store_result(mCon);
  4. if(!type)
  5. {
  6. if(!mysql_num_rows(mCon))
  7. {
  8. SendClientMessage(playerid,COLOR_ERROR,"Error, (/register) first."), mysql_free_result(mCon);
  9. ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Please register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
  10. return 1;
  11. }
  12. mysql_real_escape_string(password, password);
  13. new pass[129];
  14. WP_Hash(pass, 129, password);
  15.  
  16. new query[128+129];
  17. format(query, sizeof(query), "SELECT * FROM `users` WHERE `Name` = '%s' AND `Password` = '%s' LIMIT 1",PlayerInfo[playerid][pName], pass);
  18. mysql_function_query(mCon, query, false, "OnPlayerLogin", "dd", playerid, 1);
  19. }
  20. if(type)
  21. {
  22. if(!mysql_num_rows(mCon))
  23. {
  24. SendClientMessage(playerid,COLOR_ERROR,"Error, incorrect password");
  25. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
  26. return 1;
  27. }
  28. new result[256];
  29. mysql_fetch_row(result);
  30. sscanf(result, "p<|>{s[25]s[130]}i",PlayerInfo[playerid][pAdminLevel]);
  31.  
  32. PlayerInfo[playerid][pLogged] = 1;
  33. }
  34. mysql_free_result(mCon);
  35. return 1;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement