#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <fakemeta_util>
#define MSG_SHOW_MIN_TIME 0.1
new is_glowing[33]
new last_ent[33],can_touch[33]
new onoff,dist,glow,glow_color
new red,green,blue
public plugin_init() {
register_plugin("E betûre fegyver felvétel","0.9","Sh!nE")
onoff = register_cvar("amx_rwpickup","1")
dist = register_cvar("amx_rwp_distance","150")
glow = register_cvar("amx_rwp_glow","1")
glow_color = register_cvar("amx_rwp_glow_color","255 4 44")
register_logevent("round_start",2,"1=Round_Start")
register_forward(FM_CmdStart,"cmd_start")
RegisterHam(Ham_Touch,"weaponbox","touch_weapon")
RegisterHam(Ham_Touch,"armoury_entity","touch_weapon")
RegisterHam(Ham_Touch,"weapon_shield","touch_weapon")
register_forward(FM_AddToFullPack,"addtofullpack",1)
}
public round_start() {
new temp_rgb[12],temp_rgb2[3][4]
get_pcvar_string(glow_color,temp_rgb,11)
parse(temp_rgb,temp_rgb2[0],3,temp_rgb2[1],3,temp_rgb2[2],3)
red=str_to_num(temp_rgb2[0])
green=str_to_num(temp_rgb2[1])
blue=str_to_num(temp_rgb2[2])
}
public addtofullpack(es_handle,e,ent,id,hostflags,player,pSet) {
if(!is_user_alive(id) || !get_pcvar_num(onoff) || !get_pcvar_num(glow) || (id==ent) || is_user_bot(id)) return FMRES_IGNORED
if(is_glowing[id]==ent) {
new rgb[3]
rgb[0]=red
rgb[1]=green
rgb[2]=blue
set_es(es_handle,ES_RenderMode,kRenderNormal)
set_es(es_handle,ES_RenderFx,kRenderFxGlowShell)
set_es(es_handle,ES_RenderAmt,16)
set_es(es_handle,ES_RenderColor,rgb)
}
return FMRES_IGNORED
}
public cmd_start(id,uc_handle,random_seed) {
if(!is_user_alive(id) || !get_pcvar_num(onoff) || is_user_bot(id)) return FMRES_IGNORED
static buttons
buttons=get_uc(uc_handle,UC_Buttons)
new ent = get_aim_origin_ent(id)
if(ent!=last_ent[id]) {
is_glowing[id]=0
last_ent[id]=ent
}
if(!ent) {
remove_task(id)
return FMRES_IGNORED
}
is_glowing[id]=ent
if(!task_exists(id)) set_task(MSG_SHOW_MIN_TIME,"show_pickup",id,_,_,"b")
if(buttons & IN_USE) {
can_touch[id]=ent
dllfunc(DLLFunc_Touch,ent,id)
}
else if(!(buttons & IN_USE)) can_touch[id]=0
return FMRES_IGNORED
}
public show_pickup(id) {
set_hudmessage(0,255,0,-1.0,0.88,0,6.0,MSG_SHOW_MIN_TIME)
show_hudmessage(id,"Nyomd meg az E betűt, hogy felvedd")
}
public client_disconnect(id) {
is_glowing[id]=0
last_ent[id]=0
can_touch[id]=0
remove_task(id)
}
public touch_weapon(ent,id) {
if(!is_user_alive(id) || !get_pcvar_num(onoff) || is_user_bot(id)) return HAM_IGNORED
if(can_touch[id]==ent) {
can_touch[id]=0
return HAM_IGNORED
}
return HAM_SUPERCEDE
}
stock get_aim_origin_ent(id) {
new ent=-1
static Float:origin[2][3]
pev(id,pev_origin,origin[0])
fm_get_aim_origin(id,origin[1])
if(get_distance_f(origin[0],origin[1]) > float(get_pcvar_num(dist))) return 0
while((ent = engfunc(EngFunc_FindEntityInSphere,ent,origin[1],5.0))) {
static classname[33]
pev(ent,pev_classname,classname,32)
if(equal(classname,"weaponbox") || equal(classname,"armoury_entity") || equal(classname,"weapon_shield")) return ent
}
return 0
}