Home » Renegade Discussions » Mod Release Forum » [Script] Hooks.dll
[Script] Hooks.dll [message #369904] |
Sun, 01 February 2009 10:09 ![Go to next message Go to previous message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/avatars/gosticon 0000.jpeg) |
jnz
Messages: 3396 Registered: July 2006 Location: 30th century
Karma:
|
General (3 Stars) |
|
|
Please follow instalation instructions carefuly.
I've created a simple dll that contains some of the hooks that I've used.
Simply create 2 new files in your project and add the following code.
"Hooks.h"
Toggle Spoiler
typedef void (*_SerialHook)(int, const char *);
typedef void (*_LoadingEHook)(int, bool);
typedef bool (*_DamageHook)(int, int, int, float, unsigned int);
typedef bool (*_ChatEHook)(int, int, WideStringClass &, int);
typedef void (*_PingHook)(int, int);
typedef bool (*_SuicideHook)(int);
typedef bool (*_RadioHook)(int, int, int, int, int);
typedef void (*_AddSerialHook)(_SerialHook);
typedef void (*_AddLoadingEHook)(_LoadingEHook);
typedef void (*_AddDamageHook)(_DamageHook);
typedef void (*_AddChatEHook)(_ChatEHook);
typedef void (*_AddPingHook)(_PingHook);
typedef void (*_AddSuicideHook)(_SuicideHook);
typedef void (*_AddRadioHook)(_RadioHook);
typedef void (*_RequestSerial)(int, StringClass &);
extern _RequestSerial RequestSerial;
extern _AddSerialHook AddSerialHook;
extern _AddLoadingEHook AddLoadingEHook;
extern _AddDamageHook AddDamageHook;
extern _AddChatEHook AddChatEHook;
extern _AddPingHook AddPingHook;
extern _AddSuicideHook AddSuicideHook;
extern _AddRadioHook AddRadioHook;
void Load_Hooks();
"Hooks.cpp"
Toggle Spoiler
#include "Windows.h"
#include "stdio.h"
#include "scripts.h"
#include "engine.h"
#include "Hooks.h"
_RequestSerial RequestSerial = 0;
_AddSerialHook AddSerialHook = 0;
_AddLoadingEHook AddLoadingEHook = 0;
_AddDamageHook AddDamageHook = 0;
_AddChatEHook AddChatEHook = 0;
_AddPingHook AddPingHook = 0;
_AddSuicideHook AddSuicideHook = 0;
_AddRadioHook AddRadioHook = 0;
inline void LoadHook(HMODULE dll, void **hook, const char *name)
{
*hook = (void *)GetProcAddress(dll, name);
if(!*hook)
{
printf("Error loading \"%s\"", name);
*hook = 0;
}
}
void Load_Hooks()
{
HMODULE hooks = LoadLibrary("Hooks.dll");
LoadHook(hooks, (void **)&RequestSerial, "RequestSerial");
LoadHook(hooks, (void **)&AddSerialHook, "AddSerialHook");
LoadHook(hooks, (void **)&AddLoadingEHook, "AddLoadingEHook");
LoadHook(hooks, (void **)&AddDamageHook, "AddDamageHook");
LoadHook(hooks, (void **)&AddChatEHook, "AddChatHook");
LoadHook(hooks, (void **)&AddPingHook, "AddPingHook");
LoadHook(hooks, (void **)&AddSuicideHook, "AddSuicideHook");
LoadHook(hooks, (void **)&AddRadioHook, "AddRadioHook");
}
Make sure you call
Make sure you load the file attached into the server before you call Load_Hooks.
If you use SSGM, just load it as a plugin in the 01 slot.
Here is a sample SSGM plugin "plugin.cpp" file that uses this:
Toggle Spoiler
/* Renegade Scripts.dll
Example Plugin Code
Copyright 2007 Whitedragon(MDB), Jonathan Wilson
This file is part of the Renegade scripts.dll
The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version. See the file COPYING for more details.
In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
Only the source code to the module(s) containing the licenced code has to be released.
*/
/* This is designed to serve as both an example on how to make a plugin and to give users the basic framework of a plugin.
The plugin is simple: it creates an object creation hook and attaches the script "Plugin_Example_Script" to all objects.
The script prints out a message whenever an object is created or destroyed.
There are also examples of the new format for bhs.dll hooks.
*/
#include "scripts.h"
#include <windows.h>
#include "engine.h"
#include "gmmain.h"
#include "plugin.h"
#include "Hooks.h"
void Serial_Hook(int ID, const char *Serial)
{
printf("[Serial] %d - %s\n", ID, Serial);
}
void Loading_Hook(int PlayerID, bool IsInGame)
{
printf("[Load] %d %s\n", PlayerID, IsInGame ? "True" : "False");
}
bool Damage_Hook(int PlayerID, int Damager, int Target, float Damage, unsigned int Warhead)
{
printf("[Damage] %d %d %d %f %u\n", PlayerID, Damager, Target, Damage, Warhead);
return 1;
}
bool Chat_Hook(int PlayerID, int Type, WideStringClass &Message, int Target)
{
printf("[Chat] %d %d %S %d\n", PlayerID, Type, (const wchar_t *)Message, Target);
return 1;
}
void Ping_Hook(int PlayerID, int PingID)
{
printf("[Ping] %d %d\n", PlayerID, PingID);
}
bool Suicide_Hook(int PlayerID)
{
printf("[Suicide] %d\n", PlayerID);
return 1;
}
bool Radio_Hook(int Team, int PlayerID, int a, int RadioID, int b)
{
printf("[Radio] %d %d %d %d %d\n", Team, PlayerID, a, RadioID, b);
return 1;
}
void Plugin_Load()
{
Load_Hooks();
AddSerialHook(Serial_Hook);
AddLoadingEHook(Loading_Hook);
AddDamageHook(Damage_Hook);
AddChatEHook(Chat_Hook);
AddPingHook(Ping_Hook);
AddSuicideHook(Suicide_Hook);
AddRadioHook(Radio_Hook);
}
void Plugin_Unload()
{
}
extern "C" {
DLLEXPORT void SSGM_Player_Join_Hook(int ID, const char *Nick)
{
StringClass tmp;
RequestSerial(ID, tmp);
}
}
Some of the hook functions allow you to return a bool. For example, the chat hook. If you return 0 you BLOCK the message. With the chat hook, you can also change the message.
bool Chat_Hook(int PlayerID, int Type, WideStringClass &Message, int Target)
{
Message.Format("Hello world!"); //now everyone will always say "Hello world!"
return 1;
}
All of these hooks are compatable with RR, scripts and BIATCH as far as I know. If not, give me a shout.
Updated download.
-
Attachment: Hooks.dll
(Size: 80.00KB, Downloaded 208 times)
[Updated on: Tue, 03 February 2009 00:31] Report message to a moderator
|
|
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
[Script] Hooks.dll
By: jnz on Sun, 01 February 2009 10:09
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: cAmpa on Sun, 01 February 2009 10:31
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: halo2pac on Sun, 01 February 2009 14:38
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: Omar007 on Sun, 01 February 2009 14:42
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: Caveman on Sun, 01 February 2009 17:29
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: _SSnipe_ on Sun, 01 February 2009 17:31
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: raven on Sun, 01 February 2009 21:55
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: _SSnipe_ on Sun, 01 February 2009 22:03
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: raven on Sun, 01 February 2009 18:22
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: Ethenal on Sun, 01 February 2009 21:43
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: _SSnipe_ on Sun, 01 February 2009 21:53
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: jnz on Mon, 02 February 2009 00:08
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: Omar007 on Mon, 02 February 2009 14:23
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: cAmpa on Mon, 02 February 2009 14:41
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: raven on Mon, 02 February 2009 23:40
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: jnz on Tue, 03 February 2009 00:30
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: raven on Tue, 03 February 2009 00:50
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: halo2pac on Thu, 26 February 2009 18:29
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: jnz on Fri, 27 February 2009 05:31
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: raven on Fri, 27 February 2009 04:47
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: halo2pac on Fri, 27 February 2009 11:32
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: jnz on Fri, 27 February 2009 11:36
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
By: jnz on Sat, 23 April 2011 00:36
|
![Read Message Read Message](/theme/Renegade_Forums/images/read.png) |
|
Re: [Script] Hooks.dll
|
Goto Forum:
Current Time: Sun Sep 01 18:18:11 MST 2024
Total time taken to generate the page: 0.01128 seconds
|