Oblivion_UFF

set password

Oct 13th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. CMD:setpassword(playerid, params[])
  2. {
  3. if(!IsPlayerAdmin(playerid))
  4. return SendClientMessage(playerid, -1, "Insufficient permissions");
  5.  
  6. new name[21], tmp[200], str[200], query[500];
  7. if(sscanf(params, "s[21]s[20]", name, tmp))
  8. {
  9. SendClientMessage(playerid, -1, "/setpassword <name> <new password>");
  10. return true;
  11. }
  12. format(query, sizeof(query), "SELECT password FROM Users WHERE username='%s'", name);
  13. new Cache:grn_result = mysql_query(Database, query);
  14. if(cache_num_rows())
  15. {
  16. format(str, sizeof(str), "ERROR: The name '%s' doesn't exist in the database!", name);
  17. SendClientMessage(playerid, -1, str);
  18. cache_delete(grn_result);
  19. return 1;
  20. }
  21. //If name doesn't exist, Update the passowrd, I have used SHA1, use your hash.
  22. format(query, sizeof(query), "UPDATE Users SET password=SHA1('%s') WHERE username='%s'", tmp, name);
  23. mysql_query(Database, query);
  24. //
  25. format(str, sizeof(str), ">> Password for %s has been set to %s ", name, tmp);
  26. SendClientMessage(playerid, -1, str);
  27. return true;
  28. }
Add Comment
Please, Sign In to add comment