Hi, I am trying to get the player a user is aiming at and display it in a hud message. When I aim at a player nothing shows up though.
Code:
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
set_task(1.0, "getAimed", 0, "", 0, "b");
}
public getAimed(id) {
if(!is_user_alive(id)) {
return PLUGIN_HANDLED;
}
new ent, body;
get_user_aiming(id, ent, body);
if(is_valid_ent(ent)) {
new classname[50];
entity_get_string(ent,EV_SZ_classname,classname,49);
if(equal(classname,"player")) {
if(!is_user_alive(ent)) {
return PLUGIN_HANDLED;
}
showPlayerHud(id, ent);
}
}
return PLUGIN_CONTINUE;
}
public showPlayerHud(id, ent) {
new name[50];
get_user_name(ent, name, 49);
set_hudmessage(0, 100, 200, -1.0, 0.35, 0, 4.0, 0.9, 0.1, 0.2, 2);
show_hudmessage(id, "You are looking at %s", name);
}