AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Health Display. (https://forums.alliedmods.net/showthread.php?t=101462)

Mr.Noobie 08-24-2009 05:52

Health Display.
 
How to match this plugin:

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
#include <fakemeta>

#define PLUGIN_NAME "[ZP] Survivor Health"
#define PLUGIN_VERS "1.0"
#define PLUGIN_AUTH "hi!"

#define TASK_HEALTH 1234554321
new g_iHudSync

public plugin_init() 
{
 
register_plugin(PLUGIN_NAMEPLUGIN_VERSPLUGIN_AUTH)
 
 
//
 
g_iHudSync CreateHudSyncObj()
 
 
// Fwd's
 
RegisterHam(Ham_Spawn"player""Fwd_PlayerSpawn_Post"1)
 
RegisterHam(Ham_Killed"player""Fwd_PlayerKilled_Pre"0)
        
register_forward(FM_ClientDisconnect"client_disconnect")
}

public 
Fwd_PlayerSpawn_Post(id)
{
 if (
task_exists(id+TASK_HEALTH))
  
remove_task(id+TASK_HEALTH)
}

public 
Fwd_PlayerKilled_Pre(victimattackershouldgib)
{
 if (
task_exists(victim+TASK_HEALTH))
  
remove_task(victim+TASK_HEALTH)
}

public 
client_disconnect(id)
{
 if (
task_exists(id+TASK_HEALTH))
  
remove_task(id+TASK_HEALTH)
}

public 
zp_round_started(modeid)
{
 if (
mode != MODE_SURVIVOR)
  return
  
 if (!
zp_get_user_survivor(id))
  return
  
 
set_task(1.0"Task_ShowHealth"id+TASK_HEALTH__"b")
}

public 
Task_ShowHealth(id)
{
 
id -= TASK_HEALTH
 
 
if (!zp_get_user_survivor(id))
  
remove_task(id+TASK_HEALTH)
 
 
set_hudmessage(00225, -1.00.201.01.00.10.2, -1)
 
ShowSyncHudMsg(0g_iHudSync"Survivor Health: %d"get_user_health(id))


With this :

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
#include <fakemeta>

#define PLUGIN_NAME "[ZP] Survivor Health"
#define PLUGIN_VERS "1.0"
#define PLUGIN_AUTH "hi!"

#define TASK_HEALTH 1234554321
new g_iHudSync

public plugin_init() 
{
 
register_plugin(PLUGIN_NAMEPLUGIN_VERSPLUGIN_AUTH)
 
 
//
 
g_iHudSync CreateHudSyncObj()
 
 
// Fwd's
 
RegisterHam(Ham_Spawn"player""Fwd_PlayerSpawn_Post"1)
 
RegisterHam(Ham_Killed"player""Fwd_PlayerKilled_Pre"0)
        
register_forward(FM_ClientDisconnect"client_disconnect")
}

public 
Fwd_PlayerSpawn_Post(id)
{
 if (
task_exists(id+TASK_HEALTH))
  
remove_task(id+TASK_HEALTH)
}

public 
Fwd_PlayerKilled_Pre(victimattackershouldgib)
{
 if (
task_exists(victim+TASK_HEALTH))
  
remove_task(victim+TASK_HEALTH)
}

public 
client_disconnect(id)
{
 if (
task_exists(id+TASK_HEALTH))
  
remove_task(id+TASK_HEALTH)
}

public 
zp_round_started(modeid)
{
 if (
mode != MODE_NEMESIS)
  return
  
 if (!
zp_get_user_nemesis(id))
  return
  
 
set_task(1.0"Task_ShowHealth"id+TASK_HEALTH__"b")
}

public 
Task_ShowHealth(id)
{
 
id -= TASK_HEALTH
 
 
if (!zp_get_user_nemesis(id))
  
remove_task(id+TASK_HEALTH)
 
 
set_hudmessage(00225, -1.00.201.01.00.10.2, -1)
 
ShowSyncHudMsg(0g_iHudSync"Nemesis Health: %d"get_user_health(id))



BOYSplayCS 08-24-2009 09:35

Re: Health Display.
 
What?

IneedHelp 08-24-2009 12:13

Re: Health Display.
 
You want to join both? Oo

Exolent[jNr] 08-24-2009 16:12

Re: Health Display.
 
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
#include <fakemeta>

#define PLUGIN_NAME "[ZP] Survivor Health"
#define PLUGIN_VERS "1.0"
#define PLUGIN_AUTH "hi!"

#define TASK_HEALTH 1234554321
new g_iHudSync

enum GameTypes
{
    
GAME_NONE,
    
    
GAME_SURVIVOR,
    
GAME_NEMESIS
};

new const 
g_iGameModesGameTypes ] =
{
    
0,
    
    
MODE_SURVIVOR,
    
MODE_NEMESIS
};

new const 
g_szGameNamesGameTypes ][ ] =
{
    
"",
    
    
"Survivor",
    
"Nemesis"
};

enum RGB
{
    
RGB
};

new const 
g_iGameColorsGameTypes ][ RGB ] =
{
    { 
00},
    
    { 
00255 },
    { 
2550}
};

new 
GameTypes:g_iGamePlay;

GameTypes:GetModeiMode )
{
    for( new 
GameTypes:GameTypes:1GameTypesi++ )
    {
        if( 
g_iGameModes] == iMode )
        {
            return 
i;
        }
    }
    
    return 
GAME_NONE;
}

UserMatchesModeclient )
{
    switch( 
g_iGamePlay )
    {
        case 
GAME_SURVIVOR:
        {
            return 
zp_get_user_survivorclient );
        }
        case 
GAME_NEMESIS:
        {
            return 
zp_get_user_nemesisclient );
        }
    }
    
    return 
0;
}

public 
plugin_init() 
{
 
register_plugin(PLUGIN_NAMEPLUGIN_VERSPLUGIN_AUTH)
 
 
//
 
g_iHudSync CreateHudSyncObj()
 
 
// Fwd's
 
RegisterHam(Ham_Spawn"player""Fwd_PlayerSpawn_Post"1)
 
RegisterHam(Ham_Killed"player""Fwd_PlayerKilled_Pre"0)
        
register_forward(FM_ClientDisconnect"client_disconnect")
}

public 
Fwd_PlayerSpawn_Post(id)
{
 if (
task_exists(id+TASK_HEALTH))
  
remove_task(id+TASK_HEALTH)
}

public 
Fwd_PlayerKilled_Pre(victimattackershouldgib)
{
 if (
task_exists(victim+TASK_HEALTH))
  
remove_task(victim+TASK_HEALTH)
}

public 
client_disconnect(id)
{
 if (
task_exists(id+TASK_HEALTH))
  
remove_task(id+TASK_HEALTH)
}

public 
zp_round_started(modeid)
{
 
g_iGamePlay GetModemode )
 if( !
g_iGamePlay )
  return
  
 if( !
UserMatchesModeid ) )
  return
  
 
set_task(1.0"Task_ShowHealth"id+TASK_HEALTH__"b")
}

public 
Task_ShowHealth(id)
{
 
id -= TASK_HEALTH
 
 
if( !g_iGamePlay
 
|| !UserMatchesModeid ) )
 {
  
remove_task(id+TASK_HEALTH)
  return
 }
 
 
set_hudmessage(g_iGameColorsg_iGamePlay ][ ], g_iGameColorsg_iGamePlay ][ ], g_iGameColorsg_iGamePlay ][ ], -1.00.201.01.00.10.2, -1)
 
ShowSyncHudMsg(idg_iHudSync"%s Health: %d"g_szGameNamesg_iGamePlay ], get_user_health(id))



Mr.Noobie 08-25-2009 06:30

Re: Health Display.
 
Quote:

Originally Posted by Exolent[jNr] (Post 911553)
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
#include <fakemeta>
 
#define PLUGIN_NAME "[ZP] Survivor Health"
#define PLUGIN_VERS "1.0"
#define PLUGIN_AUTH "hi!"
 
#define TASK_HEALTH 1234554321
new g_iHudSync
 
enum GameTypes
{
    
GAME_NONE,
 
    
GAME_SURVIVOR,
    
GAME_NEMESIS
};
 
new const 
g_iGameModesGameTypes ] =
{
    
0,
 
    
MODE_SURVIVOR,
    
MODE_NEMESIS
};
 
new const 
g_szGameNamesGameTypes ][ ] =
{
    
"",
 
    
"Survivor",
    
"Nemesis"
};
 
new 
GameTypes:g_iGamePlay;
 
GameTypes:GetModeiMode )
{
    for( new 
GameTypes:GameTypes:1GameTypesi++ )
    {
        if( 
g_iGameModes] == iMode )
        {
            return 
i;
        }
    }
 
    return 
GAME_NONE;
}
 
UserMatchesModeclient )
{
    switch( 
g_iGamePlay )
    {
        case 
GAME_SURVIVOR:
        {
            return 
zp_get_user_survivorclient );
        }
        case 
GAME_NEMESIS:
        {
            return 
zp_get_user_nemesisclient );
        }
    }
 
    return 
0;
}
 
public 
plugin_init() 
{
 
register_plugin(PLUGIN_NAMEPLUGIN_VERSPLUGIN_AUTH)
 
 
//
 
g_iHudSync CreateHudSyncObj()
 
 
// Fwd's
 
RegisterHam(Ham_Spawn"player""Fwd_PlayerSpawn_Post"1)
 
RegisterHam(Ham_Killed"player""Fwd_PlayerKilled_Pre"0)
        
register_forward(FM_ClientDisconnect"client_disconnect")
}
 
public 
Fwd_PlayerSpawn_Post(id)
{
 if (
task_exists(id+TASK_HEALTH))
  
remove_task(id+TASK_HEALTH)
}
 
public 
Fwd_PlayerKilled_Pre(victimattackershouldgib)
{
 if (
task_exists(victim+TASK_HEALTH))
  
remove_task(victim+TASK_HEALTH)
}
 
public 
client_disconnect(id)
{
 if (
task_exists(id+TASK_HEALTH))
  
remove_task(id+TASK_HEALTH)
}
 
public 
zp_round_started(modeid)
{
 
g_iGamePlay GetModemode )
 if( !
g_iGamePlay )
  return
 
 if( !
UserMatchesModeid ) )
  return
 
 
set_task(1.0"Task_ShowHealth"id+TASK_HEALTH__"b")
}
 
public 
Task_ShowHealth(id)
{
 
id -= TASK_HEALTH
 
 
if( !g_iGamePlay
 
|| !UserMatchesModeid ) )
 {
  
remove_task(id+TASK_HEALTH)
  return
 }
 
 
set_hudmessage(00225, -1.00.201.01.00.10.2, -1)
 
ShowSyncHudMsg(idg_iHudSync"%s Health: %d"g_szGameNamesg_iGamePlay ], get_user_health(id))



Is it possible to make the hud message for nemesis in red ?

Or blue for survivor ?

Exolent[jNr] 08-25-2009 10:28

Re: Health Display.
 
Done.

Mr.Noobie 08-30-2009 03:46

Re: Health Display.
 
Quote:

Originally Posted by Exolent[jNr] (Post 911553)
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
#include <fakemeta>
 
#define PLUGIN_NAME "[ZP] Survivor Health"
#define PLUGIN_VERS "1.0"
#define PLUGIN_AUTH "hi!"
 
#define TASK_HEALTH 1234554321
new g_iHudSync
 
enum GameTypes
{
    
GAME_NONE,
 
    
GAME_SURVIVOR,
    
GAME_NEMESIS
};
 
new const 
g_iGameModesGameTypes ] =
{
    
0,
 
    
MODE_SURVIVOR,
    
MODE_NEMESIS
};
 
new const 
g_szGameNamesGameTypes ][ ] =
{
    
"",
 
    
"Survivor",
    
"Nemesis"
};
 
enum RGB
{
    
RGB
};
 
new const 
g_iGameColorsGameTypes ][ RGB ] =
{
    { 
00},
 
    { 
00255 },
    { 
2550}
};
 
new 
GameTypes:g_iGamePlay;
 
GameTypes:GetModeiMode )
{
    for( new 
GameTypes:GameTypes:1GameTypesi++ )
    {
        if( 
g_iGameModes] == iMode )
        {
            return 
i;
        }
    }
 
    return 
GAME_NONE;
}
 
UserMatchesModeclient )
{
    switch( 
g_iGamePlay )
    {
        case 
GAME_SURVIVOR:
        {
            return 
zp_get_user_survivorclient );
        }
        case 
GAME_NEMESIS:
        {
            return 
zp_get_user_nemesisclient );
        }
    }
 
    return 
0;
}
 
public 
plugin_init() 
{
 
register_plugin(PLUGIN_NAMEPLUGIN_VERSPLUGIN_AUTH)
 
 
//
 
g_iHudSync CreateHudSyncObj()
 
 
// Fwd's
 
RegisterHam(Ham_Spawn"player""Fwd_PlayerSpawn_Post"1)
 
RegisterHam(Ham_Killed"player""Fwd_PlayerKilled_Pre"0)
        
register_forward(FM_ClientDisconnect"client_disconnect")
}
 
public 
Fwd_PlayerSpawn_Post(id)
{
 if (
task_exists(id+TASK_HEALTH))
  
remove_task(id+TASK_HEALTH)
}
 
public 
Fwd_PlayerKilled_Pre(victimattackershouldgib)
{
 if (
task_exists(victim+TASK_HEALTH))
  
remove_task(victim+TASK_HEALTH)
}
 
public 
client_disconnect(id)
{
 if (
task_exists(id+TASK_HEALTH))
  
remove_task(id+TASK_HEALTH)
}
 
public 
zp_round_started(modeid)
{
 
g_iGamePlay GetModemode )
 if( !
g_iGamePlay )
  return
 
 if( !
UserMatchesModeid ) )
  return
 
 
set_task(1.0"Task_ShowHealth"id+TASK_HEALTH__"b")
}
 
public 
Task_ShowHealth(id)
{
 
id -= TASK_HEALTH
 
 
if( !g_iGamePlay
 
|| !UserMatchesModeid ) )
 {
  
remove_task(id+TASK_HEALTH)
  return
 }
 
 
set_hudmessage(g_iGameColorsg_iGamePlay ][ ], g_iGameColorsg_iGamePlay ][ ], g_iGameColorsg_iGamePlay ][ ], -1.00.201.01.00.10.2, -1)
 
ShowSyncHudMsg(idg_iHudSync"%s Health: %d"g_szGameNamesg_iGamePlay ], get_user_health(id))




There is still a problem with this. The health display doesn't apear sometime.

hzqst 08-30-2009 04:51

Re: Health Display.
 
use a certain channel for your plugin and try to stop the 3rd plugins with message displaying

Mr.Noobie 08-30-2009 06:19

Re: Health Display.
 
Quote:

Originally Posted by hzqst (Post 917628)
use a certain channel for your plugin and try to stop the 3rd plugins with message displaying

Yeah did. still same


All times are GMT -4. The time now is 15:06.

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