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

SDK Hooks 2.1 - Updated 2011-9-10


Post New Thread Closed Thread   
 
Thread Tools Display Modes
psychonic

BAFFLED
Join Date: May 2008
Old 04-12-2011 , 18:04   Re: SDK Hooks 1.3 (NEW 2.0 IN BETA)
#1211

Quote:
Originally Posted by altex View Post
Very strange problem on both 1.3 and 2.0 SDKHooks versions.



PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#undef AUTOLOAD_EXTENSIONS
#undef REQUIRE_EXTENSIONS
#include <sdkhooks>

public Plugin:myinfo =
{
    
name "Test name",
    
author "Test author",
    
description "Test descr",
    
version "Test version",
    
url "Test url"
};

new 
bool:g_SdkHooksEnabled false;

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
MarkNativeAsOptional("SDKHook");
    
MarkNativeAsOptional("SDKUnhook");
    return 
APLRes_Success;
}

public 
Action:Timer_CheckSdkHooks(Handle:timer) {
    
g_SdkHooksEnabled GetExtensionFileStatus("sdkhooks.ext") == 1;
}

public 
OnPluginStart()
{
    
g_SdkHooksEnabled GetExtensionFileStatus("sdkhooks.ext") == 1;
    if ( !
g_SdkHooksEnabled ) {
        
InsertServerCommand("sm exts load sdkhooks");
        
CreateTimer(0.1Timer_CheckSdkHooks);
    }
}

public 
OnClientPutInServer(client) {
    if ( 
g_SdkHooksEnabled ) {
        
SDKHook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
    }
}

public 
OnClientDisconnect(client)
{
    if ( 
g_SdkHooksEnabled ) {
        
SDKUnhook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
    }
}

public 
Action:OnWeaponSwitch(clientweapon) {
    return 
Plugin_Continue;

Ignoring the other things bad in this, you're missing parentheses in your check. = is taking precedence over ==.
psychonic is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 04-12-2011 , 18:51   Re: SDK Hooks 1.3 (NEW 2.0 IN BETA)
#1212

Quote:
Originally Posted by psychonic View Post
Ignoring the other things bad in this, you're missing parentheses in your check. = is taking precedence over ==.
Assuming i have the following fixed chunk of code, what next should i do to make it work?
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#undef AUTOLOAD_EXTENSIONS
#undef REQUIRE_EXTENSIONS
#include <sdkhooks>

public Plugin:myinfo =
{
    
name "Test name",
    
author "Test author",
    
description "Test descr",
    
version "Test version",
    
url "Test url"
};

new 
bool:g_SdkHooksEnabled false;

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
LogMessage("AskPluginLoad2");
    
MarkNativeAsOptional("SDKHook");
    
MarkNativeAsOptional("SDKUnhook");
    return 
APLRes_Success;
}

public 
Action:Timer_CheckSdkHooks(Handle:timer) {
    
LogMessage("Timer_CheckSdkHooks");
    
g_SdkHooksEnabled = (GetFeatureStatus(FeatureType_Native"SDKHookEx") == FeatureStatus_Available);
    
LogMessage("... g_SdkHooksEnabled is %i"g_SdkHooksEnabled);
}

public 
OnPluginStart()
{
    
LogMessage("OnPluginStart");
    
g_SdkHooksEnabled = (GetFeatureStatus(FeatureType_Native"SDKHookEx") == FeatureStatus_Available);
    
LogMessage("... g_SdkHooksEnabled is %i"g_SdkHooksEnabled);
    if ( !
g_SdkHooksEnabled ) {
        
InsertServerCommand("sm exts load sdkhooks");
        
CreateTimer(0.1Timer_CheckSdkHooks);
    }
}

public 
OnClientPutInServer(client) {
    
LogMessage("OnClientPutInServer");
    
LogMessage("... g_SdkHooksEnabled is %i"g_SdkHooksEnabled);
    if ( 
g_SdkHooksEnabled ) {
        
SDKHook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
    }
}

public 
OnClientDisconnect(client)
{
    
LogMessage("OnClientDisconnect");
    
LogMessage("... g_SdkHooksEnabled is %i"g_SdkHooksEnabled);
    if ( 
g_SdkHooksEnabled ) {
        
SDKUnhook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
    }
}

public 
Action:OnWeaponSwitch(clientweapon) {
    return 
Plugin_Continue;

Quote:
L 04/13/2011 - 03:06:43: [test.smx] AskPluginLoad2
L 04/13/2011 - 03:06:43: [test.smx] OnPluginStart
L 04/13/2011 - 03:06:43: [test.smx] ... g_SdkHooksEnabled is 0
L 04/13/2011 - 03:06:43: [test.smx] Timer_CheckSdkHooks
L 04/13/2011 - 03:06:43: [test.smx] ... g_SdkHooksEnabled is 1
L 04/13/2011 - 03:06:49: [test.smx] OnClientPutInServer
L 04/13/2011 - 03:06:49: [test.smx] ... g_SdkHooksEnabled is 1

L 04/13/2011 - 03:06:49: [SM] Plugin encountered error 21: Native is not bound
L 04/13/2011 - 03:06:49: [SM] Native "SDKHook" reported:
L 04/13/2011 - 03:06:49: [SM] Displaying call stack trace for plugin "test.smx":
L 04/13/2011 - 03:06:49: [SM] [0] Line 50, test.sp::OnClientPutInServer()
__________________

Last edited by altex; 04-12-2011 at 19:08.
altex is offline
rhelgeby
Veteran Member
Join Date: Oct 2008
Location: 0x4E6F72776179
Old 04-13-2011 , 03:23   Re: SDK Hooks 1.3 (NEW 2.0 IN BETA)
#1213

Is it possible to run multiple instances of SDK Hooks (like multiple versions of the same library in linux)? Or - is 2.0 backwards compatible?

When 2.0 is released, there will be a mix of plugins who use 1.3 and 2.0. I'd like to have a plugin work with both versions and only use the new features if they are available.

A possible solution might be to include the major version number in the library name, so we could do this in the plugin:

PHP Code:
if (LibraryExists("sdkhooks-2"))
{
    
// Use new features
}
else if (
LibraryExists("sdkhooks"))
{
    
// Only use old features

Then it will use the newest extension available. And if SDK Hooks 2.0 is installed it won't break older plugins because of the version number in the name.

Either way, if it's backwards compatible that's just great. Otherwise it could just be renamed to "sdkhooks-2" or something indicating it's the 2.0 branch. Though, I'm not sure how multiple versions affect the server's stability.
__________________
Richard Helgeby

Zombie:Reloaded | PawnUnit | Object Library
(Please don't send private messages for support, they will be ignored. Use the forum.)

Last edited by rhelgeby; 04-13-2011 at 04:59.
rhelgeby is offline
Send a message via MSN to rhelgeby
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 04-13-2011 , 06:31   Re: SDK Hooks 1.3 (NEW 2.0 IN BETA)
#1214

I believe it was mentioned that you don't even have to recompile old plugins if you're not using any of the new functionality, so it's probably backwards compatible.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
psychonic

BAFFLED
Join Date: May 2008
Old 04-13-2011 , 06:50   Re: SDK Hooks 1.3 (NEW 2.0 IN BETA)
#1215

Quote:
Originally Posted by rhelgeby View Post
Is it possible to run multiple instances of SDK Hooks (like multiple versions of the same library in linux)? Or - is 2.0 backwards compatible?

When 2.0 is released, there will be a mix of plugins who use 1.3 and 2.0. I'd like to have a plugin work with both versions and only use the new features if they are available.

A possible solution might be to include the major version number in the library name, so we could do this in the plugin:

PHP Code:
if (LibraryExists("sdkhooks-2"))
{
    
// Use new features
}
else if (
LibraryExists("sdkhooks"))
{
    
// Only use old features

Then it will use the newest extension available. And if SDK Hooks 2.0 is installed it won't break older plugins because of the version number in the name.

Either way, if it's backwards compatible that's just great. Otherwise it could just be renamed to "sdkhooks-2" or something indicating it's the 2.0 branch. Though, I'm not sure how multiple versions affect the server's stability.
The library "sdkhooks" is only registered on version 2 and later. Version 1.x doesn't have it.
psychonic is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 04-13-2011 , 07:22   Re: SDK Hooks 1.3 (NEW 2.0 IN BETA)
#1216

Quote:
Originally Posted by altex View Post
Assuming i have the following fixed chunk of code, what next should i do to make it work?
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#undef AUTOLOAD_EXTENSIONS
#undef REQUIRE_EXTENSIONS
#include <sdkhooks>

public Plugin:myinfo =
{
    
name "Test name",
    
author "Test author",
    
description "Test descr",
    
version "Test version",
    
url "Test url"
};

new 
bool:g_SdkHooksEnabled false;

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
LogMessage("AskPluginLoad2");
    
MarkNativeAsOptional("SDKHook");
    
MarkNativeAsOptional("SDKUnhook");
    return 
APLRes_Success;
}

public 
Action:Timer_CheckSdkHooks(Handle:timer) {
    
LogMessage("Timer_CheckSdkHooks");
    
g_SdkHooksEnabled = (GetFeatureStatus(FeatureType_Native"SDKHookEx") == FeatureStatus_Available);
    
LogMessage("... g_SdkHooksEnabled is %i"g_SdkHooksEnabled);
}

public 
OnPluginStart()
{
    
LogMessage("OnPluginStart");
    
g_SdkHooksEnabled = (GetFeatureStatus(FeatureType_Native"SDKHookEx") == FeatureStatus_Available);
    
LogMessage("... g_SdkHooksEnabled is %i"g_SdkHooksEnabled);
    if ( !
g_SdkHooksEnabled ) {
        
InsertServerCommand("sm exts load sdkhooks");
        
CreateTimer(0.1Timer_CheckSdkHooks);
    }
}

public 
OnClientPutInServer(client) {
    
LogMessage("OnClientPutInServer");
    
LogMessage("... g_SdkHooksEnabled is %i"g_SdkHooksEnabled);
    if ( 
g_SdkHooksEnabled ) {
        
SDKHook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
    }
}

public 
OnClientDisconnect(client)
{
    
LogMessage("OnClientDisconnect");
    
LogMessage("... g_SdkHooksEnabled is %i"g_SdkHooksEnabled);
    if ( 
g_SdkHooksEnabled ) {
        
SDKUnhook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
    }
}

public 
Action:OnWeaponSwitch(clientweapon) {
    return 
Plugin_Continue;

I'm sorry, just tell me if somebody interested or not in resolving this issue.
The best answer will be example of using sdkhooks as optional plugin.
This is my third post about the same issue and i still don't understand if it will be resolved or not.
__________________
altex is offline
psychonic

BAFFLED
Join Date: May 2008
Old 04-13-2011 , 07:35   Re: SDK Hooks 1.3 (NEW 2.0 IN BETA)
#1217

Quote:
Originally Posted by altex View Post
I'm sorry, just tell me if somebody interested or not in resolving this issue.
The best answer will be example of using sdkhooks as optional plugin.
This is my third post about the same issue and i still don't understand if it will be resolved or not.
Soon 2.0 will be released, and the only supported check will be against the library, which will work fine with OnLibraryAdded/OnLibraryRemoved/LibraryExists. Version 1.3 will be considered no longer officially supported so I would just encourage people to upgrade. I will try to post the last beta today. It fixes some inconsistencies that have exists with 1.3 in the ShouldCollide hook and add a blockable hook on Use.

There has been no bugs reported since the last beta so either no one cares to try it or it works greats. Either way, a release is imminent.
psychonic is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 04-13-2011 , 07:47   Re: SDK Hooks 1.3 (NEW 2.0 IN BETA)
#1218

Quote:
Originally Posted by psychonic View Post
or it works greats

at least for me and my use cases.
thx!
__________________
einmal mit profis arbeiten. einmal.
Thrawn2 is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 04-13-2011 , 08:09   Re: SDK Hooks 1.3 (NEW 2.0 IN BETA)
#1219

Quote:
Originally Posted by psychonic View Post
Soon 2.0 will be released, and the only supported check will be against the library, which will work fine with OnLibraryAdded/OnLibraryRemoved/LibraryExists. Version 1.3 will be considered no longer officially supported so I would just encourage people to upgrade. I will try to post the last beta today. It fixes some inconsistencies that have exists with 1.3 in the ShouldCollide hook and add a blockable hook on Use.

There has been no bugs reported since the last beta so either no one cares to try it or it works greats. Either way, a release is imminent.
omg

I use SdkHooks 2.0.

The issue is not in detecting library (OnLibraryAdded/OnLibraryRemoved/LibraryExists).

After library is loaded with "sm exts load" it does not work.

So there is no way to use sdkhooks as optional.
So defines AUTOLOAD_EXTENSION and REQUIRE_EXTENSION actualy dont needed if library can not be used as optional.

Trying to use sdkhooks as optional library leads to the following error
Quote:
L 04/13/2011 - 03:06:49: [SM] Plugin encountered error 21: Native is not bound
L 04/13/2011 - 03:06:49: [SM] Native "SDKHook" reported:
L 04/13/2011 - 03:06:49: [SM] Displaying call stack trace for plugin "test.smx":
L 04/13/2011 - 03:06:49: [SM] [0] Line 50, test.sp::OnClientPutInServer()
__________________

Last edited by altex; 04-13-2011 at 08:13.
altex is offline
psychonic

BAFFLED
Join Date: May 2008
Old 04-13-2011 , 08:15   Re: SDK Hooks 1.3 (NEW 2.0 IN BETA)
#1220

Quote:
Originally Posted by altex View Post
After library is loaded with "sm exts load" it does not work.
If the library callbacks or native are not working properly, please file a bug with a short test case attached so that it can be looked into further.

Last edited by psychonic; 04-13-2011 at 08:25.
psychonic is offline
Closed Thread



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 04:26.


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