Tutaj kod z pliku sp.
/********************************************************
1.0 - Pierwsze wydanie pluginu.
1.1 - Dodanie możliwości zmiany wyglądu rang w tabeli.
1.2 - Optymalizacja kodu, poprawienie komunikatów na chacie pod względem estetycznym, zmiana timera zapisującego dane na akcję w Event_RoundEnd
1.3 - Dodanie opcji wyłączenia złotych naboi, zmiana kominkatów, ukrywanie opcji przy wyłączonych złotych nabojach.
1.4 - Dodanie hudu
********************************************************/
/* [ Includes ] */
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <multicolors>
#include <clientprefs>
#include <yRanks>
/* [ Compiler Options ] */
#pragma newdecls required
#pragma semicolon 1
/* [ Defines ] */
#define PluginTag "{lightred}★{darkred} Ranks {lightred}★{default}"
#define Table_Main "yRanks_Main"
#define Table_Stats "yRanks_Stats"
/* [ Modules ] */
#include "yRanks/yRanks_Globals.sp"
#include "yRanks/yRanks_Commands.sp"
#include "yRanks/yRanks_Database.sp"
#include "yRanks/yRanks_Events.sp"
#include "yRanks/yRanks_AdminPanel.sp"
#include "yRanks/yRanks_standardActions.sp"
#include "yRanks/yRanks_Helpers.sp"
#include "yRanks/yRanks_Natives.sp"
#include "yRanks/yRanks_Config.sp"
/* [ Plugin Author And Informations ] */
public Plugin myinfo =
{
name = "[CS:GO] Yamakashi - [ yRanks ]",
author = Plugin_Author,
description = Plugin_Description,
version = "1.4",
url = Plugin_Url
};
/* [ Plugin Startup ] */
public void OnPluginStart()
{
/* [ Admin Commands ] */
RegAdminCmd("sm_ap", AdminPanel_Command, ADMFLAG_ROOT, "Panel Administracyjny");
RegAdminCmd("sm_adminpanel", AdminPanel_Command, ADMFLAG_ROOT, "Panel Administracyjny");
RegAdminCmd("sm_reloadcfg", ReloadConfigs_Command, ADMFLAG_ROOT, "Przeładowanie configów");
/* [ Commands ] */
RegConsoleCmd("sm_ranks", Ranks_Command, "Główne menu rang.");
RegConsoleCmd("sm_ranga", Ranks_Command, "Główne menu rang.");
RegConsoleCmd("sm_rangi", Ranks_Command, "Główne menu rang.");
RegConsoleCmd("sm_rank", Ranks_Command, "Główne menu rang.");
RegConsoleCmd("sm_sklep", Shop_Command, "Sklep z punktami.");
RegConsoleCmd("sm_shop", Shop_Command, "Sklep z punktami.");
RegConsoleCmd("sm_hud", Hud_Command, "Wybór hudu");
RegConsoleCmd("say", Say_Command);
RegConsoleCmd("say_team", Say_Command);
/* [ Hooks ] */
HookEvent("round_end", Event_RoundEnd);
HookEvent("round_mvp", Event_RoundMvp);
HookEvent("bomb_defused", Event_BombDefused);
HookEvent("bomb_planted", Event_BombPlanted);
HookEvent("player_death", Event_PlayerDeath);
HookEvent("hostage_rescued", Event_HostageRescued);
/* [ Timers ] */
CreateTimer(360.0, AuthorInfo, _, TIMER_FLAG_NO_MAPCHANGE);
/* [ Cookies ] */
g_hCookie1 = RegClientCookie("first_connection", "Pierwsze połaczenie", CookieAccess_Private);
g_hCookie2 = RegClientCookie("type_of_hud", "Rodzaj hudu", CookieAccess_Private);
/* [ Database Connect ] */
DatabaseConnect();
/* [ Hud ] */
g_hHud = CreateHudSynchronizer();
/* [ Check Player ] */
LoopClients(i)
{
OnClientCookiesCached(i);
OnClientPutInServer(i);
}
/* [ LogFile ] */
char sDate[16];
FormatTime(sDate, sizeof(sDate), "%Y-%m-%d", GetTime());
BuildPath(Path_SM, g_sLogFile, sizeof(g_sLogFile), "logs/yRanks/%s.log", sDate);
/* [ ConfigFile ] */
BuildPath(Path_SM, g_sConfigPathMain, sizeof(g_sConfigPathMain), "configs/yRanks/yRanks_Main.cfg");
BuildPath(Path_SM, g_sConfigPathShop, sizeof(g_sConfigPathShop), "configs/yRanks/yRanks_Shop.cfg");
BuildPath(Path_SM, g_sConfigPathRanks, sizeof(g_sConfigPathRanks), "configs/yRanks/yRanks_Ranks.cfg");
}
/* [ Timers ] */
public Action UpdateEverythingTimer(Handle timer, any client)
{
if(IsValidClient(client))
{
UpdateEverything(client);
CreateTimer(30.0, UpdateEverythingTimer, client, TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action AuthorInfo(Handle timer)
{
LoopClients(i)
{
CPrintToChat(i, "%s {darkred}=========> {lightred}Informacja{darkred} <=========", PluginTag);
CPrintToChat(i, "%s Plugin został napisany przez {lime}Yamakashiego{default}.", PluginTag);
CPrintToChat(i, "%s {darkred}=========> {lightred}Informacja{darkred} <=========", PluginTag);
}
CreateTimer(360.0, AuthorInfo, _, TIMER_FLAG_NO_MAPCHANGE);
}
public Action UpdateStatus(Handle timer, int client)
{
char sBuffer[1024];
if(IsValidClient(client))
{
if(g_iHud[client] == 1)
{
if(IsPlayerAlive(client))
{
Format(sBuffer, sizeof(sBuffer), "<font color='#FF0033'>Ranga:</font> %s", g_sRanksNames[g_iRank[client]]);
if(g_iRank[client] > 18)
Format(sBuffer, sizeof(sBuffer), "%s\n<font color='#FF0033'>Punkty:</font> %d", sBuffer, g_iScore[client]);
else
Format(sBuffer, sizeof(sBuffer), "%s\n<font color='#FF0033'>Punkty:</font> %d/%d", sBuffer, g_iScore[client], g_iRequirements[g_iRank[client] + 1]);
}
else
{
int spect = GetEntProp(client, Prop_Send, "m_iObserverMode");
if(spect == 4 || spect == 5)
{
int target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
if(target != -1 && IsValidClient(target))
{
Format(sBuffer, sizeof(sBuffer), "<font color='#FF0033'>Odznaka:</font> %s", g_sRanksNames[g_iRank[target]]);
if(g_iRank[target] > 18)
Format(sBuffer, sizeof(sBuffer), "%s\n<font color='#FF0033'>Zabójstwa:</font> %d", sBuffer, g_iScore[target]);
else
Format(sBuffer, sizeof(sBuffer), "%s\n<font color='#FF0033'>Zabójstwa:</font> %d/%d", sBuffer, g_iScore[target], g_iRequirements[g_iRank[target] + 1]);
}
}
}
PrintHintText(client, sBuffer);
}
else if(g_iHud[client] == 2)
{
if(IsPlayerAlive(client))
{
Format(sBuffer, sizeof(sBuffer), "# Ranga: %s", g_sRanksNames[g_iRank[client]]);
if(g_iRank[client] > 18)
Format(sBuffer, sizeof(sBuffer), "%s\n# Punkty: %d", sBuffer, g_iScore[client]);
else
Format(sBuffer, sizeof(sBuffer), "%s\n# Punkty: %d/%d", sBuffer, g_iScore[client], g_iRequirements[g_iRank[client] + 1]);
SetHudTextParams(0.03, -0.33, 1.0, 6, 231, 1, 255, 0, 10.0, 0.0, 0.0);
ShowSyncHudText(client, g_hHud, sBuffer);
}
else
{
int spect = GetEntProp(client, Prop_Send, "m_iObserverMode");
if(spect == 4 || spect == 5)
{
int target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
if(target != -1 && IsValidClient(target))
{
Format(sBuffer, sizeof(sBuffer), "# Ranga: %s", g_sRanksNames[g_iRank[target]]);
if(g_iRank[target] > 18)
Format(sBuffer, sizeof(sBuffer), "%s\n# Punkty: %d", sBuffer, g_iScore[target]);
else
Format(sBuffer, sizeof(sBuffer), "%s\n# Punkty: %d/%d", sBuffer, g_iScore[target], g_iRequirements[g_iRank[target] + 1]);
SetHudTextParams(0.03, -0.33, 1.0, 6, 231, 1, 255, 0, 10.0, 0.0, 0.0);
ShowSyncHudText(client, g_hHud, sBuffer);
}
}
}
}
}
CreateTimer(0.1, UpdateStatus, client, TIMER_FLAG_NO_MAPCHANGE);
}