Плагин Observe Client 1.2.4 не корректно работает

Сообщения
166
Реакции
34
Помог
3 раз(а)
Ошибка
Ошибок нет
Список плагинов
01 "Nextmap" (1.9.0.6241) by AlliedModders LLC
  02 "Client Preferences" (1.9.0.6241) by AlliedModders LLC
  03 "BlackBox: Admin Camera Tools" (1.0.0) by Crimson
  04 "Observe Client" (1.2.4) by WhiteWolf, puopjik, psychonic, RedSword
  05 "Map Nominations" (1.9.0.6241) by AlliedModders LLC
  06 "Admin Help" (1.9.0.6241) by AlliedModders LLC
  07 "Admin File Reader" (1.9.0.6241) by AlliedModders LLC
  08 "Fun Commands" (1.9.0.6241) by AlliedModders LLC
  09 "VoteBKM" (1.0.5) by Drumanid
  10 "Basic Comm Control" (1.9.0.6241) by AlliedModders LLC
  11 "MapChooser" (1.9.0.6241) by AlliedModders LLC
  12 "SourceBans" (1.4.11) by SourceBans Development Team
  13 "Basic Commands" (1.9.0.6241) by AlliedModders LLC
  14 "Admin Menu" (1.9.0.6241) by AlliedModders LLC
  15 "Rock The Vote" (1.9.0.6241) by AlliedModders LLC
  16 "Resetscore" (1.1) by tuty
  17 "Fun Votes" (1.9.0.6241) by AlliedModders LLC
  18 "Basic Votes" (1.9.0.6241) by AlliedModders LLC
  19 "Player Commands" (1.9.0.6241) by AlliedModders LLC
  20 "Anti-Flood" (1.9.0.6241) by AlliedModders LLC
  21 "AFK Manager" (1.2.1) by neugomon
  22 "Basic Chat" (1.9.0.6241) by AlliedModders LLC
  23 "Reserved Slots" (1.9.0.6241) by AlliedModders LLC
  24 "Basic Info Triggers" (1.9.0.6241) by AlliedModders LLC
  25 "Sound Commands" (1.9.0.6241) by AlliedModders LLC
C++
Версия SourceMod
SourceMod Version Information:
    SourceMod Version: 1.9.0.6241
    SourcePawn Engine: 1.9.0.6241, jit-x86 (build 1.9.0.6241)
    SourcePawn API: v1 = 4, v2 = 12
    Compiled on: Jul  7 2018 07:13:38
    Built from: https://github.com/alliedmodders/sourcemod/commit/07f8043
    Build ID: 6241:07f8043
    http://www.sourcemod.net/
C++
ОС
Linux
Версия Metamod
Metamod:Source version 1.10.7-dev
Built from: https://github.com/alliedmodders/metamod-source/commit/20c72b5
Build ID: 963:20c72b5
Loaded As: Valve Server Plugin
Compiled on: Jul  7 2018
Plugin interface version: 15:14
SourceHook version: 5:5
http://www.metamodsource.net/
C++
Исходный код
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

#define VERSION "1.2.4"
#define NAME "Observe Client"

#define ADMINFLAG ADMFLAG_KICK

public Plugin:myinfo = 
{
	name = NAME,
	author = "WhiteWolf, puopjik, psychonic, RedSword",
	description = "Observe client when dead",
	version = VERSION,
	url = "http://www.whitewolf.us"
};

/* Credits:
	Mani - Showed me his observer code from MAP
*/

/* Globals */
new g_offObserverTarget;
new g_clientObserveTarget[MAXPLAYERS+1];
new bool:g_useSteamBans = false;

//CSGO-related
new bool:g_isCSGO;
new Handle:g_hSpec_freeze_time;
new Handle:g_hSpec_freeze_traveltime;
new Handle:g_hSpec_freeze_deathanim_time;


public OnPluginStart() {
	new Handle:conVar;
	
	CreateConVar("observe_version", VERSION, NAME, FCVAR_SPONLY|FCVAR_NOTIFY);
	
	HookEvent("player_spawn", EventPlayerSpawn);
	HookEvent("player_death", EventPlayerDeath);
	
	
	RegAdminCmd("sm_observe", CommandObserve, ADMINFLAG, "Spectate a player when dead.");
	RegAdminCmd("sm_endobserve", CommandEndObserve, ADMINFLAG, "End spectating a player.");
	
	LoadTranslations("common.phrases");
	LoadTranslations("observe.phrases");
	
	g_offObserverTarget = FindSendPropOffs("CBasePlayer", "m_hObserverTarget");
	if(g_offObserverTarget == -1) {
		SetFailState("Expected to find the offset to m_hObserverTarget, couldn't.");
	}
	
	conVar = FindConVar("sbsrc_version");
	if(conVar != INVALID_HANDLE) {
		g_useSteamBans = true;
	}
	
	decl String:szBuffer[ 8 ];
	
	GetGameFolderName(szBuffer, sizeof(szBuffer));
	
	g_isCSGO = StrEqual(szBuffer, "csgo", false);
	if (g_isCSGO)
	{
		g_hSpec_freeze_time = FindConVar("spec_freeze_time");
		g_hSpec_freeze_traveltime = FindConVar("spec_freeze_traveltime");
		g_hSpec_freeze_deathanim_time = FindConVar("spec_freeze_deathanim_time");
	}
}

/********************************************************************************
	Events
*********************************************************************************/

public Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) {
	/* Suggestions for improvement, or single-shot method? */
	new target = GetClientOfUserId(GetEventInt(event, "userid"));
	for(new client = 1; client <= MaxClients; client++) {
		if(g_clientObserveTarget[client] == target && (IsClientObserver(client) || !IsPlayerAlive(client))) {
			SetClientObserver(client, target, true);
			return Plugin_Handled;
		}
	}
	return Plugin_Handled;
}

public Action:EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) {
	
	new userId = GetEventInt(event, "userid");
	
	if (!g_isCSGO)
	{
		Timer_Death(INVALID_HANDLE, userId);
	}
	else
	{
		CreateTimer(GetConVarFloat(g_hSpec_freeze_time) + 
			GetConVarFloat(g_hSpec_freeze_traveltime) + 
			GetConVarFloat(g_hSpec_freeze_deathanim_time) +
			0.1, Timer_Death, userId ); //0.1 is needed; tested
	}
	
	return Plugin_Handled;
}

public Action:Timer_Death(Handle:timer, any:userId)
{
	new client = GetClientOfUserId(userId);
	
	if (g_isCSGO && client > 0 && IsClientInGame(client) && IsPlayerAlive(client))
	{
		return Plugin_Handled;//prevent late kill messages
	}
	
	//Won't be a real Timer
	if(g_clientObserveTarget[client] > 0) {
		new target = g_clientObserveTarget[client];
		if(!isValidHumanClient(target)) {
			g_clientObserveTarget[client] = 0;
			return Plugin_Handled;
		}
		
		if(IsPlayerAlive(target)) {
			SetClientObserver(client, target, true);
		}
	}
	return Plugin_Handled;
}

public OnClientDisconnect(client) {
	new String:clientName[MAX_NAME_LENGTH];
	GetClientName(client, clientName, MAX_NAME_LENGTH);
	
	g_clientObserveTarget[client] = 0;
	for(new i = 1; i <= MaxClients; i++) {
		if(g_clientObserveTarget[i] == client) {
			g_clientObserveTarget[i] = 0;
			if (IsClientInGame(i) && IsClientConnected(i)) {
				PrintToChat(i, "%t", "Target Left", clientName);
			}
		}
	}
}

/********************************************************************************
	Commands
*********************************************************************************/

public Action:CommandEndObserve(client, args) {
	g_clientObserveTarget[client] = 0;
	PrintToChat(client, "%t", "End Observe");
	return Plugin_Handled;
}

public Action:CommandObserve(client, args) {
	if(GetCmdArgs() < 1) {
		ReplyToCommand(client, "Usage: sm_observe <name or #userid>");
		return Plugin_Handled;
	}
	
	decl String:targetName[MAX_NAME_LENGTH], String:targetSteamID[MAX_NAME_LENGTH];
	
	GetCmdArg(1, targetName, sizeof(targetName)); //get username part from arguments
	
	new targetClient = FindTarget(client, targetName, false, false);
	if(targetClient == -1) {
		PrintToChat(client, "%t", "Unknown Target");
		return Plugin_Handled;
	}
	
	GetClientName(targetClient, targetName, sizeof(targetName));
	GetClientAuthString(targetClient, targetSteamID, sizeof(targetSteamID));
	g_clientObserveTarget[client] = targetClient;
	
	if(IsClientObserver(client) || !IsPlayerAlive(client)) {
		if(!SetClientObserver(client, targetClient, true)) {
			PrintToChat(client, "%t", "Observe Failed", targetName);
		}
	} else {
		PrintToChat(client, "%t", "Observe on Spec", targetName, targetSteamID);
	}
	
	return Plugin_Handled;
}

/********************************************************************************
	Helper Methods
*********************************************************************************/

public bool:isValidHumanClient(client) {
	if(client > 0 && IsClientInGame(client) && IsClientConnected(client)) {
		return true;
	}
	return false;
}
		
public bool:SetClientObserver(client, target, bool:sendMessage) {
	if(!isValidHumanClient(client) || !isValidHumanClient(target)) {
		return false;
	}
	
	SetEntDataEnt2(client, g_offObserverTarget, target, true);
	
	if(sendMessage) {
		SendClientObserveMessage(client, target);
	}
	
	if(g_useSteamBans) {
		ClientCommand(client, "sb_status");
	}
		
	return true; //we assume it went through, else SM would throw a native error and we wouldn't get here anyway
}

public SendClientObserveMessage(client, target) {
	decl String:targetName[MAX_NAME_LENGTH], String:targetSteamID[65];
	GetClientName(target, targetName, MAX_NAME_LENGTH);
	GetClientAuthString(target, targetSteamID, 65);
	PrintToChat(client, "%t", "Observing", targetName, targetSteamID);
}
C++
Плагин установил в соответствии с инструкцией. (все ок)
Создал "adminmenu_custom.txt" добавил необходимые строки. (все ок)
Код:
"Commands"
{
"Меню наблюдения"
{
"Начать наблюдение"
{
"admin" "sm_kick"
"cmd" "sm_observe #1"
"execute" "player"
"1"
{
"type" "groupplayer"
"method" "name"
"title" "Наблюдать за:"
}
}
"Закончить наблюдение"
{
"cmd" "sm_endobserve"
"admin" "sm_kick"
"execute" "player"
}
}
}
C++
В меню соурс мода все появилось можно выбрать игрока за кем наблюдать, так же информация о том за кем наблюдает администратор появляется в чате.
Но по факту наблюдение не начинается.
Вопрос, какое значение должно быть mp_forcecamera ?
Выставлял значение 1
Может я что то не доделал? или чего то не хватает. Подскажите пожалуйста:blush2:
28 Ноя 2018
Значение mp_forcecamera менял как в server.cfg так и в cfg режима игры, так как он вроде бы загружается после server.cfg
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу