Dr.G
02-14-2010, 04:56 PM
This is a quick test of the Orpheu module. It looks like its working very well...
Is this better then Hamsandwich? I dont know, but its looks more stabil IMO.
/* Plugin generated by AMXX-Studio */
////////////////////////////////////////////////////////////////////////////////////////////////////
#include <amxmodx>
#include <Orpheu>
////////////////////////////////////////////////////////////////////////////////////////////////////
#define PLUGIN "DoD Orpheu testing"
#define VERSION "1.0 by Dr.G"
#define AUTHOR "AMXX DoD Team"
////////////////////////////////////////////////////////////////////////////////////////////////////
/* NOTE: */
/* CBasePlayer::PreThink(void) -> Offset WIN32 = 132 */
/* CBasePlayer::Spawn(void) -> Offset WIN32 = 3 */
/* CBasePlayer::Killed(entvars_s *, int) -> Offset WIN32 = 20 */
/* THESE are offsets for Day of Defeat! */
////////////////////////////////////////////////////////////////////////////////////////////////////
new i[33] = 0
new time_to_run
new counter[33] = 0
new is_alive[33] = 0
////////////////////////////////////////////////////////////////////////////////////////////////////
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
new OrpheuFunction:iThink = OrpheuGetFunctionFromClass("player", "PreThink", "CBasePlayer" )
OrpheuRegisterHook(iThink,"think_Player")
new OrpheuFunction:Player_Spawn = OrpheuGetFunctionFromClass("player", "Spawn", "CBasePlayer" )
OrpheuRegisterHook(Player_Spawn,"Spawn")
new OrpheuFunction:Player_Killed = OrpheuGetFunctionFromClass("player","Killed", "CBasePlayer" )
OrpheuRegisterHook(Player_Killed,"player_Killed")
time_to_run = register_cvar("time_to_run","30")
register_clcmd("say /thinktest","start_Test")
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public start_Test(id)
{
set_task( get_pcvar_float(time_to_run), "stop_Test", id )
counter[id] = 0
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public stop_Test(id)
{
client_print(id, 3, "*Thinks per Sec: %d", (counter[id]/get_pcvar_num(time_to_run)))
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public Spawn(player) //looks like its pre..
{
set_task(1.0, "Spawn_Delayed", player)
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public Spawn_Delayed(id)
is_alive[id] = is_user_alive(id)
////////////////////////////////////////////////////////////////////////////////////////////////////
public think_Player(player)
{
counter[player]++
if(i[player] == 600)
{
i[player] = 0
if(is_alive[player])
{
client_print(player, 3, "*Thinkin' and alive..")
return
}
else
client_print(player, 3, "*Thinkin' and dead..")
}
i[player]++
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public player_Killed(victim, killer, something)
{
is_alive[victim] = 0
client_print(victim, 3, "*You died!")
}
////////////////////////////////////////////////////////////////////////////////////////////////////
Ref.: Orpheu: Using virtual functions
(https://forums.alliedmods.net/showthread.php?t=118138)
-Cheers!
Is this better then Hamsandwich? I dont know, but its looks more stabil IMO.
/* Plugin generated by AMXX-Studio */
////////////////////////////////////////////////////////////////////////////////////////////////////
#include <amxmodx>
#include <Orpheu>
////////////////////////////////////////////////////////////////////////////////////////////////////
#define PLUGIN "DoD Orpheu testing"
#define VERSION "1.0 by Dr.G"
#define AUTHOR "AMXX DoD Team"
////////////////////////////////////////////////////////////////////////////////////////////////////
/* NOTE: */
/* CBasePlayer::PreThink(void) -> Offset WIN32 = 132 */
/* CBasePlayer::Spawn(void) -> Offset WIN32 = 3 */
/* CBasePlayer::Killed(entvars_s *, int) -> Offset WIN32 = 20 */
/* THESE are offsets for Day of Defeat! */
////////////////////////////////////////////////////////////////////////////////////////////////////
new i[33] = 0
new time_to_run
new counter[33] = 0
new is_alive[33] = 0
////////////////////////////////////////////////////////////////////////////////////////////////////
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
new OrpheuFunction:iThink = OrpheuGetFunctionFromClass("player", "PreThink", "CBasePlayer" )
OrpheuRegisterHook(iThink,"think_Player")
new OrpheuFunction:Player_Spawn = OrpheuGetFunctionFromClass("player", "Spawn", "CBasePlayer" )
OrpheuRegisterHook(Player_Spawn,"Spawn")
new OrpheuFunction:Player_Killed = OrpheuGetFunctionFromClass("player","Killed", "CBasePlayer" )
OrpheuRegisterHook(Player_Killed,"player_Killed")
time_to_run = register_cvar("time_to_run","30")
register_clcmd("say /thinktest","start_Test")
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public start_Test(id)
{
set_task( get_pcvar_float(time_to_run), "stop_Test", id )
counter[id] = 0
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public stop_Test(id)
{
client_print(id, 3, "*Thinks per Sec: %d", (counter[id]/get_pcvar_num(time_to_run)))
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public Spawn(player) //looks like its pre..
{
set_task(1.0, "Spawn_Delayed", player)
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public Spawn_Delayed(id)
is_alive[id] = is_user_alive(id)
////////////////////////////////////////////////////////////////////////////////////////////////////
public think_Player(player)
{
counter[player]++
if(i[player] == 600)
{
i[player] = 0
if(is_alive[player])
{
client_print(player, 3, "*Thinkin' and alive..")
return
}
else
client_print(player, 3, "*Thinkin' and dead..")
}
i[player]++
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public player_Killed(victim, killer, something)
{
is_alive[victim] = 0
client_print(victim, 3, "*You died!")
}
////////////////////////////////////////////////////////////////////////////////////////////////////
Ref.: Orpheu: Using virtual functions
(https://forums.alliedmods.net/showthread.php?t=118138)
-Cheers!