Raised This Month: $51 Target: $400
 12% 

[CSGO] Some minor errors [DHOOKS]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
'-_-'<3zok<3'-_-'
Senior Member
Join Date: Feb 2010
Location: Norway
Old 03-07-2016 , 17:34   [CSGO] Some minor errors [DHOOKS]
Reply With Quote #1

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
// ----------------------------------------

Last edited by '-_-'<3zok<3'-_-'; 03-07-2016 at 17:35.
'-_-'<3zok<3'-_-' is offline
Send a message via Skype™ to '-_-'<3zok<3'-_-'
xerox8521
Senior Member
Join Date: Sep 2011
Old 03-07-2016 , 17:39   Re: [CSGO] Some minor errors [DHOOKS]
Reply With Quote #2

this may be reserved keyword (methodmaps) by sourcemod as of 1.7 so try it with pThis instead or any other name

Last edited by xerox8521; 03-07-2016 at 17:40.
xerox8521 is offline
'-_-'<3zok<3'-_-'
Senior Member
Join Date: Feb 2010
Location: Norway
Old 03-07-2016 , 18:20   Re: [CSGO] Some minor errors [DHOOKS]
Reply With Quote #3

Thanks, it compiles perfectly now after changing this to pThis,
Code:
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;
	}
}

Last edited by '-_-'<3zok<3'-_-'; 03-07-2016 at 18:20.
'-_-'<3zok<3'-_-' is offline
Send a message via Skype™ to '-_-'<3zok<3'-_-'
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode