PDA

View Full Version : [CSGO] Some minor errors [DHOOKS]


'-_-'<3zok<3'-_-'
03-07-2016, 17:34
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.

#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|FC VAR_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;
}
}

//// admin-allspec.sp
//
// C:\steamcmd\csgo3\csgo\addons\sourcemod\scrip ting\admin-allspec.sp(65) : erro
r 122: expected type expression
// C:\steamcmd\csgo3\csgo\addons\sourcemod\scrip ting\admin-allspec.sp(72) : erro
r 166: cannot use 'this' outside of a methodmap method or property
// C:\steamcmd\csgo3\csgo\addons\sourcemod\scrip ting\admin-allspec.sp(72) : erro
r 166: cannot use 'this' outside of a methodmap method or property
// C:\steamcmd\csgo3\csgo\addons\sourcemod\scrip ting\admin-allspec.sp(72) : erro
r 166: cannot use 'this' outside of a methodmap method or property
// C:\steamcmd\csgo3\csgo\addons\sourcemod\scrip ting\admin-allspec.sp(72) : fata
l error 189: too many error messages on one line
//
// Compilation aborted.
// 5 Errors.
//
// Compilation Time: 0,09 sec
// ----------------------------------------

xerox8521
03-07-2016, 17:39
this may be reserved keyword (methodmaps) by sourcemod as of 1.7 so try it with pThis instead or any other name

'-_-'<3zok<3'-_-'
03-07-2016, 18:20
Thanks, it compiles perfectly now after changing this to pThis,

public MRESReturn:IsValidTarget(pThis, 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);
if(target <= 0 || target > MaxClients || !IsClientInGame(pThis) || !IsClientInGame(target) || !IsPlayerAlive(target) || IsPlayerAlive(pThis) || GetClientTeam(pThis) <= 1 || GetClientTeam(target) <= 1)
{
return MRES_Ignored;
}
else
{
DHookSetReturn(hReturn, true);
return MRES_Override;
}
}