Advertisement
rickvocam

Untitled

Apr 4th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1.  
  2. public onSocketReceiveData(Socket:id, remote_clientid, data[], data_len)
  3. {
  4. new type[32], response[128];
  5. sscanf(data, "p<|>s[32]s[128]", type, response);
  6. printf("data : %s", data);
  7. if (!strcmp(type, "login")) {
  8. printf("Login : %s", response);
  9. new pname[MAX_PLAYER_NAME], ppassword[32];
  10. sscanf(response, "p<,>s[32]s[32]", pname, ppassword);
  11. new query[256], hashed_pass[65];
  12. printf("Login : %s %s", pname, ppassword);
  13. SHA256_PassHash(ppassword, "rgame", hashed_pass, 65);
  14. mysql_format(g_SQL, query, sizeof query, "SELECT * FROM accounts where username = '%e' and password = '%s' LIMIT 1", pname, hashed_pass);
  15. inline CheckAccount_Result()
  16. {
  17. if(cache_num_rows())
  18. {
  19. socket_sendto_remote_client(id, remote_clientid, "login_ok|Encrypt String");
  20. printf("Login success : %s %s", pname, ppassword);
  21. }
  22. else {
  23. socket_sendto_remote_client(id, remote_clientid, "login_failed|failed");
  24.  
  25. printf("Login failed : %s %s", pname, ppassword);
  26. }
  27. }
  28. mysql_tquery_inline(g_SQL, query, using inline CheckAccount_Result, "");
  29. }
  30. else if(!strcmp(type, "connect"))
  31. {
  32. new pname[MAX_PLAYER_NAME], ptime;
  33. sscanf(response, "p<,>s[32]i", pname, ptime);
  34. printf("Connect : %s %d", pname, ptime);
  35. }
  36. return 1;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement