Propozycja to: top 15 lub top 10 buntów i życzeń
Treść: fajne urozmaicenie rozgrywki można też jakiś konkurs z tym zrobić, na innych serwerach było to chyba pod /topg
Propozycja to: top 15 lub top 10 buntów i życzeń
Treść: fajne urozmaicenie rozgrywki można też jakiś konkurs z tym zrobić, na innych serwerach było to chyba pod /topg
10 osob to moze lacznie na ten serwer wbije a ty chcesz top 10 robic? nie, po co
14 minut temu, rutek napisał:Wczoraj było 16
no rzeczywiscie 16 osob gra, szczegolnie, ze 1 raz przekroczylo 10 osob.
Nope
nie
41 minut temu, Mikrus napisał:10 osob to moze lacznie na ten serwer wbije a ty chcesz top 10 robic? nie, po co
Wczoraj było 16, po co ty się WGL odzywasz skoro tu nie grasz.
Nie
@ rutekbo wystarczy spojrzeć na statystyki serwera, więc nie trzeba grać, aby się sensownie udzielić w takiej kwestii. :v
Nie.
Nawet jeśli A dlaczego to ma być niby problem może przyciągnie to większa ilość osób ja was nie rozumiem xd
Nie
nie
nope
Nie
Niespodzianka!
Mojej odpowiedzi w tym temacie raczej nikt się nie spodziewał 😂.
Nudziło mi się, a miałem akurat chwilę wolnego czasu, a propka nie jest taka głupia.
Napisałem owy plugin, nie testowałem go i nie gwarantuję, że będzie on działać. Bazowałem na .inc z sm_hosties.
Kodzik do wglądu:
/*********** [ ChangeLog ] ********** 1.0 - Pierwsze wydanie pluginu. *********** [ ChangeLog ] **********/ /* [ Includes ] */ #include <sourcemod> #include <sdktools> #include <lastrequest> #include <multicolors> /* [ Compiler Options ] */ #pragma newdecls required #pragma semicolon 1 /* [ Defines ] */ #define Plugin_Author "Yamakashi" #define Plugin_Description "Topka buntów i życzeń." #define Plugin_Url "https://steamcommunity.com/id/yamakashisteam" #define PluginTag_Info "★ {lightred}[ JailTop{darkred} -> {lightred} Informacja ]{default}" #define PluginTag_Error "★ {lightred}[ JailTop{darkred} -> {lightred} Błąd ]{default}" #define Table_Main "JailTop_Main" #define LoopClients(%1) for(int %1 = 1; %1 < MaxClients; %1++) if(IsValidClient(%1)) /* [ Integers ] */ int g_iLastRequests[MAXPLAYERS + 1]; int g_iRebels[MAXPLAYERS + 1]; int g_iDatabase = 0; /* [ Booleans ] */ bool g_bIsRebel[MAXPLAYERS + 1]; bool g_bHasLastRequest[MAXPLAYERS + 1]; bool g_bIsDataLoaded[MAXPLAYERS + 1]; /* [ Handles ] */ Handle Databases; /* [ Chars ] */ char g_sLogFile[256]; /* [ Plugin Author and Informations ] */ public Plugin myinfo = { name = "[CS:GO] Yamakashi - [ JailTop ]", author = Plugin_Author, description = Plugin_Description, version = "1.0", url = Plugin_Url }; /* [ Plugin Startup ] */ public void OnPluginStart() { /* [ Commands ] */ RegConsoleCmd("sm_topg", JailTop_Command, "Menu główne"); RegConsoleCmd("sm_jailtop", JailTop_Command, "Menu główne"); RegConsoleCmd("sm_staty", Stats_Command, "Statystyki"); RegConsoleCmd("sm_stats", Stats_Command, "Statystyki"); /* [ Hooks ] */ HookEvent("round_start", Event_RoundStart); HookEvent("round_end", Event_RoundEnd); /* [ Database Connect ] */ DatabaseConnect(); /* [ Check Player ] */ LoopClients(i) OnClientPutInServer(i); /* [ Log File ] */ char sDate[16]; FormatTime(sDate, sizeof(sDate), "%Y-%m-%d", GetTime()); BuildPath(Path_SM, g_sLogFile, sizeof(g_sLogFile), "logs/yRanks/%s.log", sDate); } /* [ Standart Actions ] */ public void OnClientPutInServer(int client) { Reset(client, 1); PrepareLoadData(client); } public void OnClientDisconnect(int client) { if(IsValidClient(client)) { char sAuthId[64]; GetClientAuthId(client, AuthId_Steam2, sAuthId, sizeof(sAuthId)); LogToFileEx(g_sLogFile, "[ JailTop ] - [ WYJŚCIE ] | %N (%s) przy wyjściu posiadał %d buntów oraz %d ostatnich życzeń", g_iRebels[client], g_iLastRequests[client]); Update(client); } } public void OnMapStart() { CreateTimer(1.0, CheckStatus, _, TIMER_FLAG_NO_MAPCHANGE); } public void OnMapEnd() { LoopClients(i) OnClientDisconnect(i); } public void OnPluginEnd() { LoopClients(i) OnClientDisconnect(i); } /* [ Events ] */ public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast) { LoopClients(i) Reset(i, 2); } public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast) { LoopClients(i) Update(i); } /* [ Timers ] */ public Action CheckStatus(Handle timer) { LoopClients(i) { if(!IsPlayerAlive(i)) continue; if(IsClientRebel(i) && !g_bIsRebel[i]) { g_bIsRebel[i] = true; g_iRebels[i]++; } if(IsClientInLastRequest(i) && !g_bHasLastRequest[i] && !g_bIsRebel[i]) { g_bHasLastRequest[i] = true; g_iLastRequests[i]++; } } } /* [ Commands ] */ public Action JailTop_Command(int client, int args) { char sBuffer[256]; Format(sBuffer, sizeof(sBuffer), "[ # Jailbreak :: JailTop # ]\n "); Format(sBuffer, sizeof(sBuffer), "%s\n# Witaj %N!", sBuffer, client); Format(sBuffer, sizeof(sBuffer), "%s\n# Liczba buntów: [ %d ]", sBuffer, g_iRebels[client]); Format(sBuffer, sizeof(sBuffer), "%s\n# Liczba ostatnich życzeń: [ %d ]", sBuffer, g_iLastRequests[client]); Format(sBuffer, sizeof(sBuffer), "%s\n# Wybierz rodzaj topki, która cię interesuje.\n ", sBuffer); Menu jailtop = new Menu(JailTop_Handler); jailtop.SetTitle(sBuffer); jailtop.AddItem("", "# Bunty"); jailtop.AddItem("", "# Ostatnie życzenia\n "); jailtop.Display(client, MENU_TIME_FOREVER); } public int JailTop_Handler(Menu menu, MenuAction action, int client, int position) { if(action == MenuAction_Select) { switch(position) { case 0: ShowRebels(client, 0); case 1: ShowLastRequests(client, 0); } } else if(action == MenuAction_End) delete menu; } public void ShowRebels(int client, int at) { if(!IsValidClient(client)) return; DataPack Datapack = new DataPack(); Datapack.WriteCell(client); if(at > 0) Datapack.WriteCell(at - 1); else { Datapack.WriteCell(0); at = 1; } char sQuery_JailTop[1024]; Format(sQuery_JailTop, sizeof(sQuery_JailTop), "SELECT `Nick`, `Rebels` `SteamID` FROM `%s` WHERE `Rebels` > 0 ORDER BY `Rebels` DESC LIMIT %d, 10", Table_Main, at - 1); SQL_TQuery(Databases, SQL_JailTop_Rebels, sQuery_JailTop, Datapack); } public void SQL_JailTop_Rebels(Handle owner, Handle query, const char[] error, DataPack Datapack) { if(query == INVALID_HANDLE) { LogError("[ X JailTop X ] Error podczas wyswietlania topki buntów: %s", error); return; } Datapack.Reset(); int i = 0; int TotalPlayers = SQL_GetRowCount(query); int client = Datapack.ReadCell(); if(!IsValidClient(client)) return; int at = Datapack.ReadCell(); delete Datapack; if(!SQL_HasResultSet(query) || SQL_GetRowCount(query) == 0) { ShowRebels(client, TotalPlayers - 9); return; } char sItem[512], sName[MAX_NAME_LENGTH], sBuffer[512]; Menu rebelstop = new Menu(RebelsTop_Handler); rebelstop.SetTitle("[ # Jailbreak :: Najlepsi Buntownicy # ]\n "); Format(sItem, sizeof(sItem), "Pokazuj od %d do %d z %d \n", at + 1, at + 10, TotalPlayers); while(SQL_HasResultSet(query) && SQL_FetchRow(query)) { i++; SQL_FetchString(query, 0, sName, sizeof(sName)); int rebels; if(SQL_FetchInt(query, 1) == 0) rebels = 1; else rebels = SQL_FetchInt(query, 1); Format(sBuffer, sizeof(sBuffer), "#%d %s - [ %d ] buntów.\n ", i + at, sName, rebels); if(strlen(sItem) + strlen(sBuffer) < 470) { Format(sItem, sizeof(sItem), "%s%s", sItem, sBuffer); sBuffer = "\0"; } } Format(sItem, sizeof(sItem), "%s\n ", sItem); rebelstop.AddItem(sItem, sItem); IntToString(at + i, sItem, sizeof(sItem)); if(i > 9) rebelstop.AddItem(sItem, "Dalej"); IntToString(at - i, sItem, sizeof(sItem)); if(at + i - 1 > 9) rebelstop.AddItem(sItem, "Cofnij"); rebelstop.ExitButton = true; rebelstop.DisplayAt(client, at, 120); } public int RebelsTop_Handler(Menu menu, MenuAction action, int client, int position) { if(action == MenuAction_Select) { char sItem[32]; menu.GetItem(position, sItem, sizeof(sItem)); if(StringToInt(sItem) >= 0) ShowRebels(client, StringToInt(sItem) + 1); else ShowRebels(client, 0); } else if(action == MenuAction_End) delete menu; } public void ShowLastRequests(int client, int at) { if(!IsValidClient(client)) return; DataPack Datapack = new DataPack(); Datapack.WriteCell(client); if(at > 0) Datapack.WriteCell(at - 1); else { Datapack.WriteCell(0); at = 1; } char sQuery_JailTop[1024]; Format(sQuery_JailTop, sizeof(sQuery_JailTop), "SELECT `Nick`, `Last_Requests` `SteamID` FROM `%s` WHERE `Last_Requests` > 0 ORDER BY `Last_Requests` DESC LIMIT %d, 10", Table_Main, at - 1); SQL_TQuery(Databases, SQL_JailTop_LastRequests , sQuery_JailTop, Datapack); } public void SQL_JailTop_LastRequests(Handle owner, Handle query, const char[] error, DataPack Datapack) { if(query == INVALID_HANDLE) { LogError("[ X JailTop X ] Error podczas wyswietlania topki buntów: %s", error); return; } Datapack.Reset(); int i = 0; int TotalPlayers = SQL_GetRowCount(query); int client = Datapack.ReadCell(); if(!IsValidClient(client)) return; int at = Datapack.ReadCell(); delete Datapack; if(!SQL_HasResultSet(query) || SQL_GetRowCount(query) == 0) { ShowLastRequests(client, TotalPlayers - 9); return; } char sItem[512], sName[MAX_NAME_LENGTH], sBuffer[512]; Menu lrtop = new Menu(LastRequestsTop_Handler); lrtop.SetTitle("[ # Jailbreak :: Najlepsi Gracze # ]\n "); Format(sItem, sizeof(sItem), "Pokazuj od %d do %d z %d \n", at + 1, at + 10, TotalPlayers); while(SQL_HasResultSet(query) && SQL_FetchRow(query)) { i++; SQL_FetchString(query, 0, sName, sizeof(sName)); int rebels; if(SQL_FetchInt(query, 1) == 0) rebels = 1; else rebels = SQL_FetchInt(query, 1); Format(sBuffer, sizeof(sBuffer), "#%d %s - [ %d ] ostatnich życzeń.\n ", i + at, sName, rebels); if(strlen(sItem) + strlen(sBuffer) < 470) { Format(sItem, sizeof(sItem), "%s%s", sItem, sBuffer); sBuffer = "\0"; } } Format(sItem, sizeof(sItem), "%s\n ", sItem); lrtop.AddItem(sItem, sItem); IntToString(at + i, sItem, sizeof(sItem)); if(i > 9) lrtop.AddItem(sItem, "Dalej"); IntToString(at - i, sItem, sizeof(sItem)); if(at + i - 1 > 9) lrtop.AddItem(sItem, "Cofnij"); lrtop.ExitButton = true; lrtop.DisplayAt(client, at, 120); } public int LastRequestsTop_Handler(Menu menu, MenuAction action, int client, int position) { if(action == MenuAction_Select) { char sItem[32]; menu.GetItem(position, sItem, sizeof(sItem)); if(StringToInt(sItem) >= 0) ShowLastRequests(client, StringToInt(sItem) + 1); else ShowLastRequests(client, 0); } else if(action == MenuAction_End) delete menu; } public Action Stats_Command(int client, int args) { if(IsValidClient(client)) { for (int i = 0; i < 5; i++) PrintToChat(client, ""); CPrintToChat(client, "%s Liczba buntów: {lightred}%d%%", PluginTag_Info, g_iRebels[client]); CPrintToChat(client, "%s Liczba ostatnich życzeń: {lightred}%d%%", PluginTag_Info, g_iLastRequests[client]); } } /* [ Database Actions ] */ public Action DatabaseConnect() { char error[512]; Databases = SQL_Connect("Yamakashi_JailTop", true, error, sizeof(error)); if(Databases == INVALID_HANDLE) { LogError("[ X JailTop X ] Error podczas polaczenia z baza: %s", error); g_iDatabase = 0; } else if(g_iDatabase < 1) { g_iDatabase++; char sQuery_JailTop[1024]; Format(sQuery_JailTop, sizeof(sQuery_JailTop), "CREATE TABLE IF NOT EXISTS `%s` (`SteamID` VARCHAR(64) NOT NULL, `Nick` VARCHAR(64) NOT NULL, `Rebels` INT NOT NULL, `Last_Requests` INT NOT NULL, UNIQUE KEY `SteamID` (`SteamID`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;", Table_Main); SQL_LockDatabase(Databases); SQL_FastQuery(Databases, sQuery_JailTop); SQL_UnlockDatabase(Databases); DatabaseConnect(); } } public void PrepareLoadData(int client) { if(!IsValidClient(client)) return; if (!g_iDatabase) PrintToChat(client, "%s Wystapil blad!", PluginTag_Error); else { char sQuery_JailTop[1024], sAuthId[64]; GetClientAuthId(client, AuthId_Steam2, sAuthId, sizeof(sAuthId)); Format(sQuery_JailTop, sizeof(sQuery_JailTop), "SELECT `Rebels`, `Last_Requests` FROM `%s` WHERE `SteamID` LIKE '%s';", Table_Main, sAuthId); SQL_TQuery(Databases, SQL_LoadData, sQuery_JailTop, client); } return; } public void SQL_LoadData(Handle owner, Handle query, const char[] error, any client) { if(query == INVALID_HANDLE) { LogError("[ X JailTop X ] Error podczas wczytywania: %s", error); return; } if(SQL_GetRowCount(query)) { while(SQL_MoreRows(query)) { while(SQL_FetchRow(query)) { g_iRebels[client] = SQL_FetchInt(query, 0); g_iLastRequests[client] = SQL_FetchInt(query, 1); } } g_bIsDataLoaded[client] = true; } else InsertPlayer(client); if(IsClientConnected(client)) { char sAuthId[64]; GetClientAuthId(client, AuthId_Steam2, sAuthId, sizeof(sAuthId)); LogToFileEx(g_sLogFile, "[ JailTop ] - [ WEJŚCIE ] | %N (%s) przy wejściu posiadał %d buntów oraz %d ostatnich życzeń", g_iRebels[client], g_iLastRequests[client]); } } public void InsertPlayer(int client) { if(!g_iDatabase || !IsValidClient(client)) return; char sQuery_JailTop[1024], sAuthId[64], sNick[MAX_NAME_LENGTH], szSafe_Nick[MAX_NAME_LENGTH * 2]; GetClientName(client, sNick, MAX_NAME_LENGTH); SQL_EscapeString(Databases, sNick, szSafe_Nick, sizeof(szSafe_Nick)); GetClientAuthId(client, AuthId_Steam2, sAuthId, sizeof(sAuthId)); Format(sQuery_JailTop, sizeof(sQuery_JailTop), "INSERT INTO `%s` (`SteamID`, `Nick`, `Rebels`, `Last_Requests`) VALUES ('%s', N'%s', '%d', '%d') ON DUPLICATE KEY UPDATE `Rebels`=VALUES(`Rebels`), `Last_Requests`=VALUES(`Last_Requests`);", Table_Main, sAuthId, szSafe_Nick, g_iRebels[client], g_iLastRequests[client]); SQL_TQuery(Databases, SQL_JailTop_Handler, sQuery_JailTop, client); return; } public void SQL_JailTop_Handler(Handle owner, Handle query, const char[] error, any client) { if(query == INVALID_HANDLE) { LogError("[ X JailTop X ] Error podczas zapisywania danych: %s", error); return; } else g_bIsDataLoaded[client] = true; } public void Update(int client) { if(!g_iDatabase || !g_bIsDataLoaded[client] || !IsValidClient(client)) return; char sQuery_JailTop[1024], sAuthId[64]; GetClientAuthId(client, AuthId_Steam2, sAuthId, sizeof(sAuthId)); Format(sQuery_JailTop, sizeof(sQuery_JailTop), "UPDATE `%s` SET `Rebels`='%d', `Last_Requests`='%d' WHERE `SteamID`='%s';", Table_Main, g_iRebels[client], g_iLastRequests[client], sAuthId); SQL_TQuery(Databases, SQL_JailTop_Handler, sQuery_JailTop, client); return; } /* [ Helpers ] */ public void Reset(int client, int type) { if(type == 1) { g_iRebels[client] = 0; g_iLastRequests[client] = 0; g_bIsRebel[client] = false; g_bHasLastRequest[client] = false; g_bIsDataLoaded[client] = false; } if(type == 2) { g_bIsRebel[client] = false; g_bHasLastRequest[client] = false; } } stock bool IsValidClient(int client) { if(client <= 0 ) return false; if(client > MaxClients) return false; if(!IsClientConnected(client)) return false; if(IsFakeClient(client)) return false; return IsClientInGame(client); }
I oczywiście download:
Dziękuje, następna moja wypowiedź w jakimś temacie za x tygodni
.
I co w związku z tym tematem.
Coraz więcej osób gra serwer się rozwija myślę że warto to dodać
Aktualnie musiałbym to spowrotem skonfigurować bo było ale był problem z bazą. Nie zamykam, zamknę jak wykonam.