Skip to content

Instantly share code, notes, and snippets.

@DfKimera
Created March 4, 2011 15:58
Show Gist options
  • Save DfKimera/854862 to your computer and use it in GitHub Desktop.
Save DfKimera/854862 to your computer and use it in GitHub Desktop.
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <fakemeta>
new plyRadio[32];
new Float:plyRadioOrigin[32][3];
public plugin_init() {
register_plugin("VoiceRadius Prototype","001","DfKimera");
register_clcmd("ams_updateradius", "AMS_VoiceUpdateRadius");
register_clcmd("ams_spawnradio", "AMS_SpawnRadio");
}
public plugin_precache() {
precache_model("models/3dm_pc4.mdl");
}
public AMS_SpawnRadio(id) {
entity_get_vector(id,EV_VEC_origin,plyRadioOrigin[id]);
new radioName[32];
format(radioName,31,"rd_%i",id);
if(!plyRadio[id]) {
plyRadio[id] = create_entity("ts_model");
entity_set_origin(plyRadio[id], plyRadioOrigin[id]);
entity_set_model(plyRadio[id], "models/3dm_pc4.mdl");
entity_set_float(plyRadio[id],EV_FL_dmg,0.0);
entity_set_float(plyRadio[id],EV_FL_dmg_take,0.0);
entity_set_float(plyRadio[id],EV_FL_max_health,99999.0);
entity_set_float(plyRadio[id],EV_FL_health,99999.0)
entity_set_int(plyRadio[id],EV_INT_solid,SOLID_BBOX);
entity_set_int(plyRadio[id],EV_INT_movetype,MOVETYPE_FLY);
entity_set_string(plyRadio[id],EV_SZ_targetname,radioName);
} else {
entity_set_origin(plyRadio[id], plyRadioOrigin[id]);
}
return PLUGIN_CONTINUE;
}
public AMS_MuteAllFromPlayer(id) {
new gPlayers[32], numPlayers, ply, dist;
get_players(gPlayers,numPlayers);
for( new i = 0 ; i < numPlayers ; i++) {
ply = gPlayers[i];
if(ply == id) continue;
if(plyRadio[ply]) {
dist = get_entity_distance (id, plyRadio[ply]);
if(dist < 256) {
//set_c)lient_listen(ply,id,1);
set_client_listen(id,ply,1);
} else {
//set_client_listen(ply,id,0);
set_client_listen(id,ply,0);
}
}
}
return PLUGIN_CONTINUE;
}
public client_PreThink(id) {
AMS_MuteAllFromPlayer(id);
}
public client_PostThink(id) {
AMS_MuteAllFromPlayer(id);
}
public AMS_VoiceUpdateRadius(id) {
new gPlayers[32], numPlayers, ply, dist;
new idName[128], plyName[128];
get_players(gPlayers,numPlayers);
get_user_name(id,idName,127);
for( new i = 0 ; i < numPlayers ; i++) {
ply = gPlayers[i];
if(ply == id) continue;
get_user_name(ply,plyName,127);
dist = get_entity_distance (id, plyRadio[ply]);
client_print(id,print_chat,"[VoiceRadius] (%s over %s's radio) Dist = %i",idName,plyName,dist);
client_print(ply,print_chat,"[VoiceRadius] (%s over %s's radio) Dist = %i",idName,plyName,dist);
}
return PLUGIN_CONTINUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment