AlliedModders

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

AlejandroSk 02-19-2009 00:26

leech bullets
 
How can i make something like leech bullets (The attacker gets the hp of the victim)

anakin_cstrike 02-19-2009 03:55

Re: leech bullets
 
Did you mean if i shoot you and you have 50hp, my hp will be set to 50 ?
Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> public plugin_init()     RegisterHam( Ham_TakeDamage, "player", "ham_takedamage" );     public ham_takedamage( victim, inflictor, attacker, Float:damage, damagebits ) {     if( ! ( damagebits & DMG_BULLET ) )         return HAM_IGNORED;             static fHealth;     pev( victim, pev_health, fHealth );         if( pev( attacker, pev_health ) != fHealth )         set_pev( attacker, pev_health, fHealth );             return HAM_IGNORED; }
If you want to add your hp to mine
Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> public plugin_init()     RegisterHam( Ham_TakeDamage, "player", "ham_takedamage" );     public ham_takedamage( victim, inflictor, attacker, Float:damage, damagebits ) {     if( ! ( damagebits & DMG_BULLET ) )         return HAM_IGNORED;             static f_vHealth, f_aHealth;     pev( victim, pev_health, f_vHealth );     pev( attacker, pev_health, f_aHealth );         set_pev( attacker, pev_health,  f_aHealth+f_vHealth );             return HAM_IGNORED; }

Arkshine 02-19-2009 05:43

Re: leech bullets
 
pev_health ; the field is a float. You can retrieve it as integer but to set it needs to be in float.

Dores 02-19-2009 07:14

Re: leech bullets
 
Code:
// you can't get pev_health like that. if( pev( attacker, pev_health ) != fHealth ) ---> // you need to create another variable static Float:health; pev(attacker, pev_health, health); if(health != fHealth) {     // ...

Arkshine 02-19-2009 07:31

Re: leech bullets
 
It's wrong, I mean you can check/retrieve pev_health as integer if you want but you have to set it as float. For all pev which are integer but the field a float.

anakin_cstrike 02-19-2009 08:11

Re: leech bullets
 
Quote:

Originally Posted by Dores (Post 764489)
Code:
// you can't get pev_health like that. if( pev( attacker, pev_health ) != fHealth ) ---> // you need to create another variable static Float:health; pev(attacker, pev_health, health); if(health != fHealth) { // ...

I tried that way and works.


All times are GMT -4. The time now is 17:07.

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