"SteamId" "Nick" "Team Name"
#pragma semicolon 1 #define DEBUG #define PLUGIN_AUTHOR "JDie-" #define PLUGIN_VERSION "1.00" #include <sourcemod> #include <sdktools> #include <cstrike> #pragma newdecls required ConVar sm_removemessages_changename; bool changename; public Plugin myinfo = { name = "Changer Names", author = PLUGIN_AUTHOR, description = "", version = PLUGIN_VERSION, url = "" }; public void OnPluginStart() { sm_removemessages_changename = CreateConVar("sm_removemessages_changename", "1", "[(1)Вкл/(0)Выкл] Удаление сообщений о смене ников.", _, true, 0.0, true, 1.0); HookUserMessage(GetUserMessageId("SayText2"), SayText2, true); //HookEvent("player_connect", eV_player_connect); AutoExecConfig(true, "remove_messages", "sourcemod"); RegConsoleCmd("sm_test", TestNameChanger); } public void OnConfigsExecuted() { changename = sm_removemessages_changename.BoolValue; } public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue) { if (convar == sm_removemessages_changename) { changename = convar.BoolValue; } } public Action SayText2(UserMsg msg_id, Handle bf, players[], int playersNum, bool reliable, bool init) { if(changename) { if(!reliable) { return Plugin_Continue; } char buffer[25]; if(GetUserMessageType() == UM_Protobuf) { PbReadString(bf, "msg_name", buffer, sizeof(buffer)); if(StrEqual(buffer, "#Cstrike_Name_Change")) { return Plugin_Handled; } } } return Plugin_Continue; } public void OnClientPutInServer(int client) { char s_SteamId[64]; char g_Filename[255]; GetClientAuthId(client, AuthId_Steam2, s_SteamId, sizeof(s_SteamId)); BuildPath(Path_SM, g_Filename, sizeof(g_Filename), "configs/constant_names.ini"); File file = OpenFile(g_Filename, "rt"); while (!file.EndOfFile()) { char line[255]; if (!file.ReadLine(line, sizeof(line))) break; //Trim comments int len = strlen(line); bool ignoring = false; for (int i=0; i<len; i++) { if (ignoring) { if (line[i] == '"') ignoring = false; } else { if (line[i] == '"') { ignoring = true; } else if (line[i] == ';') { line[i] = '\0'; break; } else if (line[i] == '/' && i != len - 1 && line[i+1] == '/') { line[i] = '\0'; break; } } } TrimString(line); if ((line[0] == '/' && line[1] == '/') || (line[0] == ';' || line[0] == '\0')) { continue; } int idx, cur_idx; char auth[64]; if ((cur_idx = BreakString(line, auth, sizeof(auth))) == -1) { return; } idx = cur_idx; char nickname[MAX_NAME_LENGTH]; char f_SteamID[64]; char newTag[12]; char info[40]; char teamCT[12], teamT[12]; BreakString(line, f_SteamID, sizeof(f_SteamID)); cur_idx = BreakString(line[idx], nickname, sizeof(nickname)); idx += cur_idx; BreakString(line[idx], newTag, sizeof(newTag)); GetTeamName(3, teamCT, 12); GetTeamName(2, teamT, 12); //CreateTimer(1.0, TestTimer, client, TIMER_FLAG_NO_MAPCHANGE); if (!strcmp(s_SteamId, f_SteamID, true)) { SetClientName(client, nickname); FormatEx(info, sizeof(info), "%s", newTag); CS_SetClientClanTag(client, info); } } file.Close(); } /*public Action TestTimer(Handle timer, any client) { char teamCT[12], teamT[12]; char tag[12]; char newTag[12]; char info[40]; GetTeamName(3, teamCT, 12); GetTeamName(2, teamT, 12); tag = "Underdogs"; newTag = "test"; if (!strcmp(teamCT, tag, true)) { ChangeClientTeam(client, 2); FormatEx(info, sizeof(info), "%t", "REPLAY", newTag); CS_SetClientClanTag(client, info); } else { ChangeClientTeam(client, 3); FormatEx(info, sizeof(info), "%t", "REPLAY", tag); CS_SetClientClanTag(client, info); }*/
Сообщение отредактировал 1scull1: 15 Октябрь 2022 - 7:15