Raised This Month: $ Target: $400
 0% 

[HELP] Can this code be made better?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BioI-Iazard
Senior Member
Join Date: Sep 2005
Location: Calgary, Alberta
Old 10-12-2009 , 14:29   [HELP] Can this code be made better?
Reply With Quote #1

Code:
#include <amxmodx> #include <fun> #include <fakemeta> new regen_hp; new regen_time; new g_Classname[] = "healdelay" public plugin_init() {         register_plugin("Auto-Healer", "1.0", "aaaa"); //previously by CSL and Slmclarengt          regen_hp = register_cvar("AH_hp", "2");             regen_time = register_cvar("AH_time", "2.0");     new Ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))         set_pev(Ent,pev_classname,g_Classname)         set_pev(Ent,pev_nextthink,get_pcvar_float(regen_time)) } public ForwardThink(Ent) {     static Classname[33]         pev(Ent,pev_classname,Classname,32)         if(!equal(Classname,g_Classname))             return FMRES_IGNORED     static Float: s_glbtime         new players[32],num     for (new counter=0; counter<num; counter++)     {         heal_player(players[counter])     }     global_get(glb_time, s_glbtime)         set_pev(Ent,pev_nextthink, s_glbtime + get_pcvar_float(regen_time))         return FMRES_IGNORED } public heal_player(id) {     new hp=get_user_health(id);     new healed=hp+get_pcvar_num(regen_hp)     if (healed>100)     {         set_user_health(id, 100);     }     else     {         set_user_health(id, healed);     } }
__________________
Loved by Many ....
Hated by Some ....
Respected by All !!!!
BioI-Iazard is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-12-2009 , 15:36   Re: [HELP] Can this code be made better?
Reply With Quote #2

Let engine do the job.
PHP Code:
#include < amxmodx >
#include < engine >

public plugin_init( ) {
    
register_plugin"Auto Healer""1.0""xPaw" );
    
    new 
iEntity create_entity"trigger_hurt" );
    
    if( 
is_valid_entiEntity ) ) {
        
DispatchKeyValueiEntity"classname""trigger_hurt" );
        
DispatchKeyValueiEntity"damagetype""1024" );
        
DispatchKeyValueiEntity"dmg""-50" );
        
DispatchKeyValueiEntity"origin""0 0 0" );
        
        
DispatchSpawniEntity );
        
        
entity_set_sizeiEntityFloat:{ -4096.0, -4096.0, -4096.0 }, Float:{ 4096.04096.04096.0 } );
        
entity_set_intiEntityEV_INT_solidSOLID_TRIGGER );
    }

__________________

Last edited by xPaw; 10-12-2009 at 15:46.
xPaw is offline
BioI-Iazard
Senior Member
Join Date: Sep 2005
Location: Calgary, Alberta
Old 10-12-2009 , 15:39   Re: [HELP] Can this code be made better?
Reply With Quote #3

How would the finished code look? (sry im noob)

Help greatly appreciated
__________________
Loved by Many ....
Hated by Some ....
Respected by All !!!!
BioI-Iazard is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 10-12-2009 , 15:39   Re: [HELP] Can this code be made better?
Reply With Quote #4

Next ->

Edit: xPaw I know, Exo is too fast for me as well.

Last edited by SnoW; 10-12-2009 at 15:47.
SnoW is offline
Send a message via MSN to SnoW
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-12-2009 , 15:43   Re: [HELP] Can this code be made better?
Reply With Quote #5

Quote:
Originally Posted by SnoW View Post
->
PHP Code:
entity_set_sizeiEntity, { -4096.0, -4096.0, -4096.0 }, { 4096.04096.04096.0 } ); 

PHP Code:
entity_set_sizeiEntityFloat:{ -4096.0, -4096.0, -4096.0 }, Float:{ 4096.04096.04096.0 } ); 
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-12-2009 , 15:46   Re: [HELP] Can this code be made better?
Reply With Quote #6

@BioI-Iazard: done.
@SnoW: You forgot Float: prefix
@Exolent[jNr]: Rawr nigguh
__________________
xPaw is offline
BioI-Iazard
Senior Member
Join Date: Sep 2005
Location: Calgary, Alberta
Old 10-12-2009 , 15:48   Re: [HELP] Can this code be made better?
Reply With Quote #7

and the code u provided me will heal 2 health every 2 seconds?
__________________
Loved by Many ....
Hated by Some ....
Respected by All !!!!
BioI-Iazard is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-12-2009 , 15:49   Re: [HELP] Can this code be made better?
Reply With Quote #8

How about you test it?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
BioI-Iazard
Senior Member
Join Date: Sep 2005
Location: Calgary, Alberta
Old 10-12-2009 , 17:38   Re: [HELP] Can this code be made better?
Reply With Quote #9

nope this heals u to 100 health so fast.

I need it so its 2 health every seconds
__________________
Loved by Many ....
Hated by Some ....
Respected by All !!!!
BioI-Iazard is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-12-2009 , 18:12   Re: [HELP] Can this code be made better?
Reply With Quote #10

Change -50 to -2 in the code.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



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 22:34.


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