I'm getting a little error that I cant figure out by myself when trying to compile this code here(Error message located at the bottom),
Newly updated gamedata, dhooks and sourcemod are both the latest builds.
I marked out line 65 and 72.
Code:
#include <sourcemod>
#include <dhooks>
#define PLUGIN_VERSION "1.0.2"
new Handle:hIsValidTarget;
new Handle:mp_forcecamera;
new bool:g_bCheckNullPtr = false;
public Plugin:myinfo =
{
name = "Admin all spec",
author = "Dr!fter",
description = "Allows admin to spec all players",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net"
}
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
MarkNativeAsOptional("DHookIsNullParam");
return APLRes_Success;
}
public OnPluginStart()
{
mp_forcecamera = FindConVar("mp_forcecamera");
if(!mp_forcecamera)
{
SetFailState("Failed to locate mp_forcecamera");
}
new Handle:temp = LoadGameConfigFile("allow-spec.games");
if(!temp)
{
SetFailState("Failed to load allow-spec.games.txt");
}
new offset = GameConfGetOffset(temp, "IsValidObserverTarget");
hIsValidTarget = DHookCreate(offset, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, IsValidTarget);
DHookAddParam(hIsValidTarget, HookParamType_CBaseEntity);
CloseHandle(temp);
g_bCheckNullPtr = (GetFeatureStatus(FeatureType_Native, "DHookIsNullParam") == FeatureStatus_Available);
CreateConVar("admin_allspec_version", PLUGIN_VERSION, "Plugin version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
}
public OnClientPostAdminCheck(client)
{
if(IsFakeClient(client))
return;
if(CheckCommandAccess(client, "admin_allspec_flag", ADMFLAG_KICK))
{
SendConVarValue(client, mp_forcecamera, "0");
DHookEntity(hIsValidTarget, true, client);
}
}
65-> public MRESReturn:IsValidTarget(this, Handle:hReturn, Handle:hParams)
{
// As of DHooks 1.0.12 we must check for a null param.
if (g_bCheckNullPtr && DHookIsNullParam(hParams, 1))
return MRES_Ignored;
new target = DHookGetParam(hParams, 1);
72-> if(target <= 0 || target > MaxClients || !IsClientInGame(this) || !IsClientInGame(target) || !IsPlayerAlive(target) || IsPlayerAlive(this) || GetClientTeam(this) <= 1 || GetClientTeam(target) <= 1)
{
return MRES_Ignored;
}
else
{
DHookSetReturn(hReturn, true);
return MRES_Override;
}
}
Code:
//// admin-allspec.sp
//
// C:\steamcmd\csgo3\csgo\addons\sourcemod\scripting\admin-allspec.sp(65) : erro
r 122: expected type expression
// C:\steamcmd\csgo3\csgo\addons\sourcemod\scripting\admin-allspec.sp(72) : erro
r 166: cannot use 'this' outside of a methodmap method or property
// C:\steamcmd\csgo3\csgo\addons\sourcemod\scripting\admin-allspec.sp(72) : erro
r 166: cannot use 'this' outside of a methodmap method or property
// C:\steamcmd\csgo3\csgo\addons\sourcemod\scripting\admin-allspec.sp(72) : erro
r 166: cannot use 'this' outside of a methodmap method or property
// C:\steamcmd\csgo3\csgo\addons\sourcemod\scripting\admin-allspec.sp(72) : fata
l error 189: too many error messages on one line
//
// Compilation aborted.
// 5 Errors.
//
// Compilation Time: 0,09 sec
// ----------------------------------------