CamerDisco

Untitled

Jul 20th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. public void OnClientPostAdminCheck(int client)
  2. {
  3. Wczytaj(client);
  4. }
  5. public void Wczytaj(int client)
  6. {
  7. Ranga[client] = 0;
  8. Punkty[client] = 0;
  9. if (IsFakeClient(client))return;
  10.  
  11. char sql[512], SteamID[64];
  12. GetClientAuthId(client, AuthId_SteamID64, SteamID, sizeof(SteamID));
  13. Format(sql, sizeof(sql), "SELECT * FROM rangi WHERE steamid='%s'", SteamID);
  14. Baza.Query(WstawGracza, sql, GetClientSerial(client), DBPrio_Normal);
  15.  
  16. WyczyscTimer(client);
  17. Zapisywanie[client] = CreateTimer(300.0, ZapiszDane, GetClientUserId(client), TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  18. }
  19. public void WstawGracza(Database db, DBResultSet results, const char[] error, any data)
  20. {
  21. int client = GetClientFromSerial(data);
  22. if (results == null)
  23. {
  24. if (client == 0)
  25. {
  26. LogError("[SS] Client is not valid. Reason: %s", error);
  27. }
  28. else
  29. {
  30. LogError("[SS] Cant use client data. Reason: %s", client, error);
  31. }
  32. return;
  33. }
  34.  
  35. if(SQL_GetRowCount(results)<=0)
  36. {
  37. char query[256];
  38. char auth[64];
  39. char clientname[MAX_NAME_LENGTH];
  40.  
  41. GetClientAuthId(client, AuthId_SteamID64, auth, sizeof(auth));
  42.  
  43. GetClientName(client, clientname, sizeof(clientname));
  44. char[] nowy = new char[(strlen(clientname)) * 2 + 1];
  45. Baza.Escape(clientname, nowy, strlen(clientname) * 2 + 1);
  46.  
  47. Format(query, sizeof(query), "INSERT INTO `rangi` (`id`, `steamid`, `nick`, `punkty`) VALUES (NULL, '%s', '%s', 0)", auth, nowy);
  48.  
  49. Baza.Query(SQLT_Error, query);
  50. }
  51. else
  52. {
  53. SQL_FetchRow(results);
  54. int field;
  55. if(SQL_FieldNameToNum(results, "punkty", field))
  56. {
  57. Punkty[client] = SQL_FetchInt(results, field);
  58. ZaladujRange(client);
  59. }
  60. char sName[MAX_NAME_LENGTH];
  61. GetClientName(client, sName, sizeof(sName));
  62. char[] nowy = new char[(strlen(sName)) * 2 + 1];
  63. Baza.Escape(sName, nowy, strlen(sName) * 2 + 1);
  64. char query[512], SteamID[64];
  65. GetClientAuthId(client, AuthId_SteamID64, SteamID, sizeof(SteamID));
  66. Format(query, sizeof(query), "UPDATE `rangi` SET `nick`='%s' WHERE steamid='%s'", nowy, SteamID);
  67. Baza.Query(SQLT_Error, query);
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment