[Half-Life AMXX] / include / lib_idle.inc Repository:
ViewVC logotype

View of /include/lib_idle.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (download) (annotate)
Tue Oct 30 09:08:11 2007 UTC (15 years, 3 months ago) by ian
File size: 2023 byte(s)
/*Lib Idle
* Version 0.1
*
* by Don Juan-jello
* www.jello-net.com
*
* This file is provided as is (no warranties).
*/
#if defined _lib_idle_included
  #endinput
#endif
#define _lib_idle_included

new Float:INTERVAL
new Float:idle_time[32],idle_button[32],Float:idle_vwx[32]
new bool:idle_btn[32],bool:idle_cmd[32]

public _idleupdate(){
	new players[32],num
	get_players(players,num,"c")
	for(new i=0;i<num;i++){
		if(is_user_alive(players[i])){
			new Float:view[3]
			entity_get_vector(players[i],EV_VEC_angles,view)
			if(idle_cmd[players[i]]&&idle_btn[players[i]]&&view[0]==idle_vwx[players[i]])
				idle_time[players[i]]+=INTERVAL
			else idle_time[players[i]]=0.0
			if(idle_time[players[i]]!=0)handle_idle(players[i],floatround(idle_time[players[i]],floatround_ceil))
			idle_vwx[players[i]]=view[0]
			idle_cmd[players[i]]=true
			idle_btn[players[i]]=true
		}
	}
	return PLUGIN_CONTINUE
}
public idlefix(id){
	new ida[1]
	ida[0]=id
	set_task(0.1,"idlefix2",_,ida,1)
	return PLUGIN_CONTINUE
}
public idlefix2(ida[1]){
	new Float:view[3]
	entity_get_vector(ida[0],EV_VEC_angles,view)
	idle_vwx[ida[0]]=view[0]
	idle_cmd[ida[0]]=true
	idle_btn[ida[0]]=true
	return PLUGIN_CONTINUE
}
public _libidle_spawn(id){
	idlefix(id)
	return PLUGIN_CONTINUE
}
/*
public _afktmm_rnd_strt(){
}
public _afktmm_rnd_end(){
}
*/
stock idleinit(Float:i=10.0){
	INTERVAL=i
	set_task(i,"_idleupdate",_,_,_,"b")
	set_task(0.5,"_btncheck",_,_,_,"b")
	register_event("ResetHUD","_libidle_spawn","b")
	//register_logevent("_afktmm_rnd_end",2,"1=Round_End")
	//register_logevent("_afktmm_rnd_strt",2,"1=Round_Start")
	return PLUGIN_CONTINUE
}
public _btncheck(){
	new num,players[32]
	get_players(players,num,"ca")
	for(new i=0;i<num;i++){
		new btn=get_user_button(players[i])
		if(btn!=idle_button[players[i]])idle_btn[players[i]]=false
		idle_button[players[i]]=btn
	}
	return PLUGIN_CONTINUE
}
stock clcmd(id){
	idle_cmd[id]=false
	return PLUGIN_CONTINUE
}

Contact
ViewVC Help
Powered by ViewVC 1.0.4