AlliedModders

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

sooN 07-03-2009 21:57

Health
 
Hello,

I need plugin that remove one health per bullet. If one player full with her weapons ( m4a1 ) he lost 30 hp.. and if it's a deagle he lost 7 hp.

Thanks

LaineN 07-04-2009 03:22

Re: Health
 
Try this:

Code:
#include <amxmodx> #include <hamsandwich> new g_iMaxPlayers; public plugin_init() {     RegisterHam(Ham_TakeDamage, "player", "ham_player_damage");         g_iMaxPlayers = get_maxplayers(); } public ham_player_damage(e_Victim, e_Inflictor, e_Attacker, Float:f_Damage, m_DamageBits) {     if ( 1 <= e_Attacker <= g_iMaxPlayers )     {         SetHamParamFloat(4, 1.0);     } }

sooN 07-04-2009 09:03

Re: Health
 
You're plugin run but you don't understand me.. if CT shoot he lost 1 hp not ennemy ? :P

LaineN 07-04-2009 13:19

Re: Health
 
Oh :)

Try this:
Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> #pragma semicolon 1 #define PLUGIN_NAME    "Shoot Damage" #define PLUGIN_VERSION    "1.0" #define PLUGIN_AUTHOR    "LaineN" new g_alive[33]; public plugin_init() {     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);         register_forward(FM_CmdStart,"FwdCmdStart");         RegisterHam(Ham_Spawn, "player", "FwdPlayerSpawn", 1);     RegisterHam(Ham_Killed, "player", "FwdPlayerKilled", 1); } public FwdPlayerSpawn(id) {     if ( !is_user_alive(id) ) g_alive[id] = true; } public FwdPlayerKilled(id) {     g_alive[id] = false; } public FwdCmdStart(id, uc_handle, seed) {     if ( !g_alive[id] ) return FMRES_IGNORED;         new buttons = get_uc(uc_handle, UC_Buttons);         if ( buttons & IN_ATTACK )     {         static health;         pev(id, pev_health, health);                 if ( health > 1 )    set_pev(id, pev_health, health - 1.0);         else                 user_kill(id);     }         return FMRES_IGNORED; }

Bugsy 07-04-2009 14:16

Re: Health
 
This method will be a bit more resourceful

PHP Code:

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

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "bugsy

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event"CurWeapon" "fw_EvCurWeapon" "be" "1=1" );
}

public 
fw_EvCurWeaponid )
{
    static 
iWeapon iWeaponTmp;
    static 
iAmmo iAmmoTmp;
    
    
iWeaponTmp read_data);
    
iAmmoTmp read_data);
    
    if ( ( 
iWeapon == iWeaponTmp ) && ( iAmmoTmp iAmmo ) )
        
set_pevid pev_health pevid pev_health ) - 1.0 );
    
    
iAmmo iAmmoTmp;
    
iWeapon iWeaponTmp;    



sooN 07-04-2009 15:40

Re: Health
 
Bugsy you're plugin run but when i have 1 health and i shoot i have 0 hp and i'm not die. i'm blocked.

hleV 07-04-2009 16:08

Re: Health
 
PHP Code:

    if ( ( iWeapon == iWeaponTmp ) && ( iAmmoTmp iAmmo ) )
        
set_pevid pev_health pevid pev_health ) - 1.0 ); 

:arrow:
PHP Code:

    if ( ( iWeapon == iWeaponTmp ) && ( iAmmoTmp iAmmo ) )
    {
        new 
Float:Health;
        
pev(idpev_healthHealth);
 
        if (
Health 1)
            
set_pevid pev_health Health 1.0 );
        else
            
user_kill(id);
    } 


sooN 07-04-2009 16:14

Re: Health
 
Waaaw, it's perfect :) Thanks :P


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

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