Raised This Month: $ Target: $400
 0% 

Entity problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-26-2014 , 04:45   Entity problem
Reply With Quote #1

So,I want to make this: at spawn it will star a task that will check your hp.If the hp is under 100 will add 1 hp/second until you reach 100 hp. It is working but I want to ask if it is possible to make this by entitity. Here is the code:

By entity:

I have a bool that is set on spawn,if the player has this power. It is called "test"

Code:
        new iEnt2
	iEnt2 = create_entity("info_target")
	set_pev(iEnt2, pev_classname, "check_health")
	set_pev(iEnt2, pev_nextthink, get_gametime() + 0.1)
	register_think("check_health", "public1")

public public1(iEnt2) {
	
	if(is_user_connected(iEnt2) && is_user_alive(iEnt2) && !is_user_bot(iEnt2)) {
		
		
		entity_set_float(iEnt2, EV_FL_nextthink, get_gametime() + 0.1)
		
		if(test[iEnt2]==true && is_user_alive(iEnt2) && is_user_connected(iEnt2) && !is_user_bot(iEnt2)) { 
			
			if(get_user_health(iEnt2) < 111) {
				
				client_print(iEnt2,print_chat,"asdfgsdghdsgfhjgf")
				set_user_health(iEnt2,get_user_health(iEnt2)+1)
				
				
			}
			
			
			client_print(iEnt2,print_chat,"asdfgs23431224dghdsgfhjgf")
			
			
		}
	}
	
}
Now by set task,this way work as it should:

Code:
public TaskRegenHp1(id){ //this is called at spawn by an 1.0 task
	
	
	if(is_user_alive(id) && is_user_connected(id) && !is_user_bot(id)) { 
		
		if(get_user_health(id) < 111) {
			
			client_print(id,print_chat,"asdfgsdghdsgfhjgf")
			set_user_health(id,get_user_health(id)+1)
			
			
		}
		
		set_task(1.0,"TaskRegenHp1",id)
		client_print(id,print_chat,"asdfgs23431224dghdsgfhjgf")
	}
So,I want the entity to check health instand of making a task that may produce lag.
HamletEagle is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-26-2014 , 05:24   Re: Entity problem
Reply With Quote #2

No ent no task (amxx 1.8.3 required) :

PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >

#pragma semicolon 1

#define PLUGIN ""
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

enum {
    
itbd_Paralyze,        
    
itbd_NerveGas,
    
itbd_Poison,
    
itbd_Radiation,
    
itbd_DrownRecover,
    
itbd_Acid,
    
itbd_SlowBurn,
    
itbd_SlowFreeze,
    
CDMG_TIMEBASED
}

new const 
m_rgbTimeBasedDamage[CDMG_TIMEBASED] = {308,309,...};

const 
m_idrowndmg 345;

public 
plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );
    
RegisterHam(Ham_Spawn"player""OnCBasePlayer_Spawn_Post"true);
}

public 
OnCBasePlayer_Spawn_Postid )
{
    if( 
is_user_alive(id) )
    {
        new 
needed_health 100 get_user_health(id);
        if( 
needed_health )
        {
            
set_pdata_byte(idm_rgbTimeBasedDamage[itbd_DrownRecover], needed_health);
            
set_pdata_int(idm_idrowndmgneeded_health);
        }
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 10:06.


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