Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void OnClientPostAdminCheck(int client)
- {
- Wczytaj(client);
- }
- public void Wczytaj(int client)
- {
- Ranga[client] = 0;
- Punkty[client] = 0;
- if (IsFakeClient(client))return;
- char sql[512], SteamID[64];
- GetClientAuthId(client, AuthId_SteamID64, SteamID, sizeof(SteamID));
- Format(sql, sizeof(sql), "SELECT * FROM rangi WHERE steamid='%s'", SteamID);
- Baza.Query(WstawGracza, sql, GetClientSerial(client), DBPrio_Normal);
- WyczyscTimer(client);
- Zapisywanie[client] = CreateTimer(300.0, ZapiszDane, GetClientUserId(client), TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
- }
- public void WstawGracza(Database db, DBResultSet results, const char[] error, any data)
- {
- int client = GetClientFromSerial(data);
- if (results == null)
- {
- if (client == 0)
- {
- LogError("[SS] Client is not valid. Reason: %s", error);
- }
- else
- {
- LogError("[SS] Cant use client data. Reason: %s", client, error);
- }
- return;
- }
- if(SQL_GetRowCount(results)<=0)
- {
- char query[256];
- char auth[64];
- char clientname[MAX_NAME_LENGTH];
- GetClientAuthId(client, AuthId_SteamID64, auth, sizeof(auth));
- GetClientName(client, clientname, sizeof(clientname));
- char[] nowy = new char[(strlen(clientname)) * 2 + 1];
- Baza.Escape(clientname, nowy, strlen(clientname) * 2 + 1);
- Format(query, sizeof(query), "INSERT INTO `rangi` (`id`, `steamid`, `nick`, `punkty`) VALUES (NULL, '%s', '%s', 0)", auth, nowy);
- Baza.Query(SQLT_Error, query);
- }
- else
- {
- SQL_FetchRow(results);
- int field;
- if(SQL_FieldNameToNum(results, "punkty", field))
- {
- Punkty[client] = SQL_FetchInt(results, field);
- ZaladujRange(client);
- }
- char sName[MAX_NAME_LENGTH];
- GetClientName(client, sName, sizeof(sName));
- char[] nowy = new char[(strlen(sName)) * 2 + 1];
- Baza.Escape(sName, nowy, strlen(sName) * 2 + 1);
- char query[512], SteamID[64];
- GetClientAuthId(client, AuthId_SteamID64, SteamID, sizeof(SteamID));
- Format(query, sizeof(query), "UPDATE `rangi` SET `nick`='%s' WHERE steamid='%s'", nowy, SteamID);
- Baza.Query(SQLT_Error, query);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment