Raised This Month: $32 Target: $400
 8% 

SDK Hooks 2.1 - Updated 2011-9-10


Post New Thread Closed Thread   
 
Thread Tools Display Modes
adrianman
Senior Member
Join Date: Sep 2010
Old 08-06-2011 , 07:39   Re: SDK Hooks 2.0 - It's beta time again!
#1531

not sure if this is the right place to report a bug but upon using m_hActiveWeapon and any buttons such as IN_ATTACK or others when i hold attack in game and try to change my weapon it gets back to the active weapon and keeps firing,this happens in l4d2 and it's bothering when i'm about to throw a pipebomb and i want to switch to something else,what i want to do is keep the m60 from being thrown after its ammo has been depleted,so i can refill it at a nearby ammo pile. If you know any other way,i would be grateful
adrianman is offline
adrianman
Senior Member
Join Date: Sep 2010
Old 08-06-2011 , 07:42   Re: SDK Hooks 2.0 - It's beta time again!
#1532

Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
    if (buttons & IN_ATTACK)
    {
        decl String:s_Weapon[64];
        
        weapon = GetEntDataEnt2(client, FindSendPropInfo("CBasePlayer", "m_hActiveWeapon"));
        if (IsValidEntity(weapon) && IsValidEdict(weapon))
                {

        GetEdictClassname(weapon, s_Weapon, sizeof(s_Weapon));

        if (StrEqual(s_Weapon, "weapon_rifle_m60"))
        {
            decl i_Clip;
            i_Clip = GetEntProp(weapon, Prop_Data, "m_iClip1");
            
            if (i_Clip == 1)
                        {
            buttons &= ~IN_ATTACK;
                        PrintHintText(client, "M60 is empty,refill it at ammo pile or pick up another gun");
                        }
                }
                }
         }
this code here would block me from switching to another gun while holding fire,using mwheelup or down to switch,even though it doesn't loose the m60 upon emptying
adrianman is offline
sosi_alliedmodders
Junior Member
Join Date: Mar 2011
Old 08-06-2011 , 13:03   Re: SDK Hooks 2.0 - It's beta time again!
#1533

I suspect for zps server crashes when some ones open the doors, push the buttons destroying the flameable barrels and etc thats is result server crash. Who knows how solve this issue?

debug:
CRASH: Sat Aug 6 19:52:22 EEST 2011
Start Line: ./srcds_i486 -game zps +maxplayers 24 +map zpo_harvest +ip xx.xxx.xx.xx +port 27026 /srcds_run -console -master -game zps -noipx -sv_lan 0 -pingbooster 1 +log on -pidfile zps1.pid -debug -pidfile zps/addons/metamod/bin/zps1.pid
#0 0xb0be3e55 in ?? ()
No symbol table info available.
End of Source crash report

screenshot: http://s1136.photobucket.com/albums/...8-07_00002.png

Last edited by sosi_alliedmodders; 08-07-2011 at 04:38.
sosi_alliedmodders is offline
Mr.Firefox
Junior Member
Join Date: Aug 2011
Old 08-06-2011 , 23:59   Re: SDK Hooks 2.0 - It's beta time again!
#1534

Quote:
Originally Posted by unt0uch4bl3 View Post
This means that something like this which gamedescoverride is using (and other plugins)
Code:
if (GetExtensionFileStatus("sdkhooks.ext") != 1)
Must be replaced with
Code:
if (LibraryExists("sdkhooks.ext"))
I've attached the corrected plugin below.
So for your plugin, you need SDK hooks to not be loaded?

Code:
    
if (LibraryExists("sdkhooks.ext"))
{
    SDKHooksFail();
}
So if sdkhooks.ext exists... the plugin will fail.

I'm not sure if I am understanding your code or not. But I have SDK hooks loaded and your plugin is failing, so IDK
Mr.Firefox is offline
Fenderic
Junior Member
Join Date: Sep 2009
Old 08-08-2011 , 10:37   Re: SDK Hooks 2.0 - It's beta time again!
#1535

hey, i'm having some trouble compiling my plugin and i was wondering if anyone could give me some insight on how to fix it.

I am able to compile this:
Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <tf2_stocks>

#define PLUGIN_VERSION "0.3"
public Plugin:myinfo = 
{
	name = "Glass Attack",
	author = "Fenderic",
	description = "Sniper-only deathmatch with tons of breakable glass!",
	version = PLUGIN_VERSION,
	url = "http://www.moddb.com/mods/glass-attack"
};
//CVars
new Handle:g_Cvar_GlassEnabled;


public Event_PlayerClass(Handle:event, const String:name[], bool:dontBroadcast)
{
	if(!GetConVarBool(g_Cvar_GlassEnabled))
	{
		return;
	}
	new glass_user = GetClientOfUserId(GetEventInt(event, "userid"));
	new glass_user_class  = GetEventInt(event, "class");
	if(glass_user_class != 2)
	{
		TF2_SetPlayerClass(glass_user, TFClassType:2);
	}
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	if(!GetConVarBool(g_Cvar_GlassEnabled))
	{
		return;
	}
	new glass_user = GetClientOfUserId(GetEventInt(event, "userid"));
	if(TF2_GetPlayerClass(glass_user) != TFClassType:7)
	{
		TF2_SetPlayerClass(glass_user, TFClassType:2);
		if(IsPlayerAlive(glass_user))
		{
			TF2_RespawnPlayer(glass_user);
		}
	}
}

public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch);
}

public Action:OnWeaponSwitch(client, weapon)
{
    decl String:sWeapon[32];
    GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
    
    if(StrEqual(sWeapon, "tf_weapon_smg"))
        return Plugin_Handled;
    
    return Plugin_Continue;
}
but i am not able to compile this:
Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <tf2_stocks>

#define PLUGIN_VERSION "0.3"
public Plugin:myinfo = 
{
	name = "Glass Attack",
	author = "Fenderic",
	description = "Sniper-only deathmatch with tons of breakable glass!",
	version = PLUGIN_VERSION,
	url = "http://www.moddb.com/mods/glass-attack"
};
//CVars
new Handle:g_Cvar_GlassEnabled;
new Handle:checkmapname = INVALID_HANDLE;


public OnPluginStart()
{
	CreateConVar("sm_glass_version", PLUGIN_VERSION, "Glass Attack version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
	g_Cvar_GlassEnabled = CreateConVar("sm_glass_enabled", "1", "Enables the Glass Attack plugin", 0, false, 0.0, false, 0.0);
	checkmapname = CreateConVar("glass_checkmapname", "1", "Disables Glass Attack on maps that do not start with 'glass_'.", FCVAR_PLUGIN);
	enabled = GetConVarBool(enabled_cvar);
	// Check map name (if necessary).
	if (enabled && GetConVarBool(checkmapname)) {
		decl String:prefix[6];
		GetCurrentMap(prefix, sizeof(prefix));
		enabled = StrEqual(prefix, "glass_", false);
	}
	if(GetConVarBool(g_Cvar_GlassEnabled))
	{
		HookEvent("player_changeclass", Event_PlayerClass);
		HookEvent("player_spawn", Event_PlayerSpawn);
		
	}
}

public Event_PlayerClass(Handle:event, const String:name[], bool:dontBroadcast)
{
	if(!GetConVarBool(g_Cvar_GlassEnabled))
	{
		return;
	}
	new glass_user = GetClientOfUserId(GetEventInt(event, "userid"));
	new glass_user_class  = GetEventInt(event, "class");
	if(glass_user_class != 2)
	{
		TF2_SetPlayerClass(glass_user, TFClassType:2);
	}
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	if(!GetConVarBool(g_Cvar_GlassEnabled))
	{
		return;
	}
	new glass_user = GetClientOfUserId(GetEventInt(event, "userid"));
	if(TF2_GetPlayerClass(glass_user) != TFClassType:7)
	{
		TF2_SetPlayerClass(glass_user, TFClassType:2);
		if(IsPlayerAlive(glass_user))
		{
			TF2_RespawnPlayer(glass_user);
		}
	}
}

public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch);
}

public Action:OnWeaponSwitch(client, weapon)
{
    decl String:sWeapon[32];
    GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
    
    if(StrEqual(sWeapon, "tf_weapon_smg"))
        return Plugin_Handled;
    
    return Plugin_Continue;
The second one is the same code, except it has the added ability to turn the plugin on/off depending on map prefix.
The reason I am posting this here though is because the second code was able to compile before I added in the last part that uses SDKHooks to remove the sniper's smg. Now when I do try to compile the whole thing, I get this error in the compiler.
Code:
////glassattack.sp
//C:\HLServer\orangebox\tf\addons\sourcemod\scripting\glassattack.sp<25> :error 017: undefined symbol "enabled"
//C:\HLServer\orangebox\tf\addons\sourcemod\scripting\glassattack.sp<25> :error 017: undefined symbol "enabled_cvar"
//C:\HLServer\orangebox\tf\addons\sourcemod\scripting\glassattack.sp<27> :error 017: undefined symbol "enabled"
//C:\HLServer\orangebox\tf\addons\sourcemod\scripting\glassattack.sp<30> :error 017: undefined symbol "enabled"
//
// 4 Errors.
I'm a bit confused as to why it doesn't recognize enabled when it did before.
If anyone has some insight into why it is doing this and how I can change the code to make it compile I would greatly appreciate it!
Thanks!
Fenderic is offline
Yeah=}
Member
Join Date: Apr 2010
Location: Ural, Russia
Old 08-09-2011 , 04:30   Re: SDK Hooks 2.0 - It's beta time again!
#1536

I have already wrote about my problem, but users' advices does not work.

Code:
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:15:40: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:15:40: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:15:40: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:15:40: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:15:40: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:15:40: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
L 08/09/2011 - 11:15:40: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:15:40: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:15:40: [SM]   [0]  Line 493, bonuses.sp::TakeDamage()
Code:
#define IsClient(%1) ( 0 < %1 < MaxClients )
Code:
public Action:TakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
	if( GetConVarBool( bonuses_block_more_frags ) )
	{
		if ( 
			IsClient(attacker) 
			&& IsClient(victim)
			&& IsClientInGame(attacker)
			&& GetClientFrags(attacker) >= GetMaxFrags() 
			&& GetClientTeam(attacker) != GetClientTeam(victim) 
		)
		{
			PrintToChat(attacker,MSG,"kill");
			ForcePlayerSuicide(attacker);
			
			damage = 0.0;
			
			return Plugin_Changed;
		}
	}
	
	return Plugin_Continue;
}
Please, help me, where is the error?
Yeah=} is offline
Yeah=}
Member
Join Date: Apr 2010
Location: Ural, Russia
Old 08-09-2011 , 08:36   Re: SDK Hooks 2.0 - It's beta time again!
#1537

Quote:
Originally Posted by Chanz View Post
Code:
&& IsClientInGame(attacker)
and where is the victim?
try:
Code:
&& IsClientInGame(attacker)
&& IsClientInGame(victim)
Man, look at the error...
L 08/09/2011 - 11:13:00: [SM] Native "IsClientInGame" reported: Client index 41 is invalid
L 08/09/2011 - 11:13:00: [SM] Displaying call stack trace for plugin "bonuses.smx":
L 08/09/2011 - 11:13:00: [SM] [0] Line 493, bonuses.sp::TakeDamage()
Yeah=} is offline
psychonic

BAFFLED
Join Date: May 2008
Old 08-09-2011 , 08:43   Re: SDK Hooks 2.0 - It's beta time again!
#1538

The majority of this stuff belongs in the scripting forum, not in this thread.
psychonic is offline
Yeah=}
Member
Join Date: Apr 2010
Location: Ural, Russia
Old 08-09-2011 , 11:25   Re: SDK Hooks 2.0 - It's beta time again!
#1539

Quote:
Originally Posted by psychonic View Post
The majority of this stuff belongs in the scripting forum, not in this thread.
Ok, sorry.
Yeah=} is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 08-09-2011 , 17:16   Re: SDK Hooks 2.0 - It's beta time again!
#1540

It would be rather dandy if CTakeDamageInfo::m_iDamageCustom was added to the OnTakeDamage forward, it would be useful for indentifying special attacks.
Wazz is offline
Closed Thread


Thread Tools
Display Modes

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:36.


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