AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   max hp amount (https://forums.alliedmods.net/showthread.php?t=239979)

linuxas 05-06-2014 15:09

max hp amount
 
Hi, guys. Im trying to make plugin where i could make a limit of hp for a player. So if set to 100, player cant have 101, 150 or 255 hp in no way... I was trying to browse forum, i have found this: https://forums.alliedmods.net/showth...=85774?t=85774 , but its not helping for me... I no need all the plugin, just the main lines which would set the limit and I would create plugin myself then... Thank you, and sorry for bad english.

aron9forever 05-07-2014 12:45

Re: max hp amount
 
PHP Code:

public plugin_init()
{
register_event("Health""EventHealth""be""1>0");
}
public 
EventHealth(client)
{

currenthp=get_user_health(client)
if(
currenthp>g_maxhp[client])
{
set_user_health(clientg_maxhp[client])
}



took hp change detection from exolent

ezio_auditore 05-08-2014 03:00

Re: max hp amount
 
Here is a version using HamSandwich

Code:
#inlcude <amxmodx> #include <hamsandwich> #inlclude <fun> new hp_limit[33] public plugin_init(){     register_plugin("HP Limit", "v1.00", "XxXxXxXxX")     RegisterHam(Ham_TakeHealth, "player", "evt_HamHeal") } public evt_HamHeal(id) {     new iHp = get_user_health(id)     if (iHp > hp_limit[id])     {         set_user_health(id, hp_limit[id])     } }

EDIT:
Quote:

Originally Posted by aron9forever (Post 2134875)
public plugin_init()
{
register_event("Health", "EventHealth", "be", "1>0");
}
public EventHealth(client)
{

currenthp=get_user_health(client)
if(currenthp>g_maxhp[client])
{
set_user_health(client, g_maxhp[client])
}

}

P.S. Place code in pawn / code / php BB markups :D

aron9forever 05-08-2014 07:26

Re: max hp amount
 
Quote:

Originally Posted by ezio_auditore (Post 2135094)
Here is a version using HamSandwich

Code:
#inlcude <amxmodx> #include <hamsandwich> #inlclude <fun> new hp_limit[33] public plugin_init(){     register_plugin("HP Limit", "v1.00", "XxXxXxXxX")     RegisterHam(Ham_TakeHealth, "player", "evt_HamHeal") } public evt_HamHeal(id) {     new iHp = get_user_health(id)     if (iHp > hp_limit[id])     {         set_user_health(id, hp_limit[id])     } }

EDIT:


P.S. Place code in pawn / code / php BB markups :D

I wanted to use ham first but I was unsure whether it records negative damage

Code:
#include <amxmodx> #include <hamsandwich> #include <fun> new hp_limit[33] public plugin_init(){     register_plugin("HP Limit", "v1.00", "XxXxXxXxX")     RegisterHam(Ham_TakeHealth, "player", "evt_HamHeal") } public evt_HamHeal(id) {     if (get_user_health(id) > hp_limit[id])     {         set_user_health(id, hp_limit[id])     } }
optimized & fixed includes

wickedd 05-08-2014 07:36

Re: max hp amount
 
Quote:

Originally Posted by ezio_auditore (Post 2135094)
Here is a version using HamSandwich

PHP Code:

#inlcude <amxmodx>
#include <hamsandwich> 
#inlclude <fun>  

new hp_limit[33
 
public 
plugin_init()
{    
    
register_plugin("HP Limit""v1.00""XxXxXxXxX")     
    
RegisterHam(Ham_TakeHealth"player""evt_HamHeal"
}  

public 
evt_HamHeal(id
{     
    new 
iHp get_user_health(id)     
    if (
iHp hp_limit[id]) 
    { 
         
set_user_health(idhp_limit[id]) 
    } 



NO!

Edit: @aron

NO!

swapped 05-08-2014 10:37

Re: max hp amount
 
why not this ?

PHP Code:

#include <amxmodx>
#include <hamsandwich> 
#include <fun>  

new g_iHealthStartCvar;

public 
plugin_init( )
{
    
register_plugin"Health Start""0.1""swapped" );

    
RegisterHamHam_Spawn"player""FwdPlayerRespawn");

    
g_iHealthStartCvar register_cvar"mp_starthealth""150" );
}

public 
FwdPlayerRespawnPlayerID )
{
    if ( 
is_user_alivePlayerID ) )
    {
        
set_user_healthPlayerIDget_pcvar_numg_iHealthStartCvar ) );
    }



ezio_auditore 05-09-2014 04:15

Re: max hp amount
 
Quote:

Originally Posted by swapped (Post 2135233)
why not this ?

PHP Code:

#include <amxmodx>
#include <hamsandwich> 
#include <fun>  
 
new g_iHealthStartCvar;
 
public 
plugin_init( )
{
    
register_plugin"Health Start""0.1""swapped" );
 
    
RegisterHamHam_Spawn"player""FwdPlayerRespawn");
 
    
g_iHealthStartCvar register_cvar"mp_starthealth""150" );
}
 
public 
FwdPlayerRespawnPlayerID )
{
    if ( 
is_user_alivePlayerID ) )
    {
        
set_user_healthPlayerIDget_pcvar_numg_iHealthStartCvar ) );
    }



No!.
he wants hp limit, not set hp on spawn.!

swapped 05-09-2014 04:30

Re: max hp amount
 
how it possibile to increase hp ?

( i mean in game. )

ezio_auditore 05-09-2014 04:35

Re: max hp amount
 
Quote:

Originally Posted by swapped (Post 2135465)
how it possibile to increase hp ?

( i mean in game. )

By using fun module's
Code:
set_user_health(index, iNewHp)

swapped 05-09-2014 04:38

Re: max hp amount
 
Quote:

Originally Posted by ezio_auditore (Post 2135467)
By using fun module's
Code:
set_user_health(index, iNewHp)

event health is not check when player recieve health with native set_user_health ( tested )

you should made an infinite task, check if user is alive and have more than max hp amount and set the default hp amount.


All times are GMT -4. The time now is 09:37.

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