Raised This Month: $ Target: $400
 0% 

Entity problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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