For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Help with ScriptHook.

Report bugs, read about fixes, new features and ask questions about the Unreal 227 patch here. Place comments and commit suggestions.
User avatar
ExpEM
OldUnreal Member
Posts: 74
Joined: Sun Jan 20, 2013 4:10 am

Help with ScriptHook.

Post by ExpEM »

Looking into messing around with ScriptHooks, I am not winning.

This is the code I am using:

Code: Select all

//=============================================================================
// ScriptHookTestTrigger.
//=============================================================================
class ScriptHookTestTrigger extends Triggers;

function Trigger(Actor A, Pawn EventInstigator)
{
	Local Object O;

	O = Class<ScriptHookTestClass>(DynamicLoadObject("ScriptHookTest.ScriptHookTestClass",Class'Object'));
	Log(O.Name);
	
	if (O)
	{
		Log("Yes ScriptHookTestClass(O) (Happy)");
		ScriptHookTestClass(O).Test();
	}
	else
		Log("No ScriptHookTestClass(O) (Sadness)");

	if (!ScriptHook(O).HooksEnabled())
		Level.Game.SetHooksEnabled(True);
	Log("HooksEnabled ="@ScriptHook(O).HooksEnabled());
}
Relevant Log output:

Code: Select all

ScriptLog: ScriptHookTestClass
ScriptLog: Yes ScriptHookTestClass(O) (Happy)
ScriptLog: HooksEnabled = False
HooksEnabled should be True.

I am also unable to call my test function from ScriptHookTestClass:

Code: Select all

//=============================================================================
// ScriptHookTestClass.
//=============================================================================
class ScriptHookTestClass extends ScriptHook;

static final Function Test()
{
	Log("Test Test Test");
}
Hopefully I'm just doing something dumb like missunderstanding how DynamicLoadObject works.
User avatar
ExpEM
OldUnreal Member
Posts: 74
Joined: Sun Jan 20, 2013 4:10 am

Re: Help with ScriptHook.

Post by ExpEM »

Found some example code on the Discord.

Bad Code:

Code: Select all

O = Class<ScriptHookTestClass>(DynamicLoadObject("ScriptHookTest.ScriptHookTestClass",Class'Object'));
Good Code:

Code: Select all

O = New Class'ScriptHookTestClass';
Log Output:

Code: Select all

ScriptLog: ScriptHookTestClass
ScriptLog: Yes ScriptHookTestClass(O) (Happy)
ScriptLog: Test Test Test
ScriptLog: HooksEnabled = True
I was dumb after all.

Return to “Unreal 227”