AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Can this code be made better? (https://forums.alliedmods.net/showthread.php?t=106229)

BioI-Iazard 10-12-2009 14:29

[HELP] Can this code be made better?
 
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);     } }

xPaw 10-12-2009 15:36

Re: [HELP] Can this code be made better?
 
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 );
    }



BioI-Iazard 10-12-2009 15:39

Re: [HELP] Can this code be made better?
 
How would the finished code look? (sry im noob)

Help greatly appreciated

SnoW 10-12-2009 15:39

Re: [HELP] Can this code be made better?
 
Next ->

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

Exolent[jNr] 10-12-2009 15:43

Re: [HELP] Can this code be made better?
 
Quote:

Originally Posted by SnoW (Post 960091)
->
PHP Code:

entity_set_sizeiEntity, { -4096.0, -4096.0, -4096.0 }, { 4096.04096.04096.0 } ); 


:arrow:
PHP Code:

entity_set_sizeiEntityFloat:{ -4096.0, -4096.0, -4096.0 }, Float:{ 4096.04096.04096.0 } ); 


xPaw 10-12-2009 15:46

Re: [HELP] Can this code be made better?
 
@BioI-Iazard: done.
@SnoW: You forgot Float: prefix :P
@Exolent[jNr]: Rawr nigguh

BioI-Iazard 10-12-2009 15:48

Re: [HELP] Can this code be made better?
 
and the code u provided me will heal 2 health every 2 seconds?

Exolent[jNr] 10-12-2009 15:49

Re: [HELP] Can this code be made better?
 
How about you test it?

BioI-Iazard 10-12-2009 17:38

Re: [HELP] Can this code be made better?
 
nope this heals u to 100 health so fast.

I need it so its 2 health every seconds

Exolent[jNr] 10-12-2009 18:12

Re: [HELP] Can this code be made better?
 
Change -50 to -2 in the code.


All times are GMT -4. The time now is 22:34.

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