Raised This Month: $ Target: $400
 0% 

leech bullets


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AlejandroSk
BANNED
Join Date: Nov 2008
Location: Aqui, en mi casa. Karma:
Old 02-19-2009 , 00:26   leech bullets
Reply With Quote #1

How can i make something like leech bullets (The attacker gets the hp of the victim)
AlejandroSk is offline
Send a message via MSN to AlejandroSk
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 02-19-2009 , 03:55   Re: leech bullets
Reply With Quote #2

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; }
__________________

anakin_cstrike is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-19-2009 , 05:43   Re: leech bullets
Reply With Quote #3

pev_health ; the field is a float. You can retrieve it as integer but to set it needs to be in float.
Arkshine is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 02-19-2009 , 07:14   Re: leech bullets
Reply With Quote #4

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) {     // ...
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-19-2009 , 07:31   Re: leech bullets
Reply With Quote #5

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.

Last edited by Arkshine; 02-19-2009 at 08:22.
Arkshine is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 02-19-2009 , 08:11   Re: leech bullets
Reply With Quote #6

Quote:
Originally Posted by Dores View Post
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.
__________________

anakin_cstrike is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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