I wrote this plugin.. it all works.. except the part of set_client_listen.. it doesn't give me any errors when compiling or running.. it just doesn't work.. is my logic flawed or something?
Code:
/* AMX Mod script.
*
* DeadChat w/ Admin_PA by SuicideDog
* This file is provided as is (no warranties).
* This plugin will allow for an admin to turn on personal all talk.
* If you turn it on, everyone in the server will hear you and you can hear them,
* but everyone else will have normal voice communitcation.
* Basically it turns on "all talk" for only the admin
*
* It also does "dead all_talk" which allows all the dead ppl to VOICE chat
* with each other (normal is only to dead teammates) and hear all of the
* alive players (normal is only alive players on the same team hear and
* talk to alive players). Note: alive players cannot hear dead players.
*
*/
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <cstrike>
public plugin_init() {
register_plugin("Dead Chat w/ Admin PA","1.0","SuicideDog")
register_clcmd("amx_pa_on","go_loud",ADMIN_KICK,"- Turns on PA system for that admin")
register_clcmd("amx_pa_off","go_normal",ADMIN_KICK,"- Turns off PA system for that admin")
register_event("DeathMsg","death","a")
register_event("ResetHUD","alive","b")
register_cvar("amx_deadchat","1")
}
public go_loud(id,level,cid){
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
client_print(id,print_center,"PA: ON") // let the user know whats going on
for (new i = 1; i <= get_maxplayers(); i++) {
if (is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i)) {
if (i != id){
set_client_listen(i, id, 1)
set_client_listen(id, i, 1)
}
}
}
return PLUGIN_HANDLED
}
public go_normal(id,level,cid){
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
client_print(id,print_center,"PA: OFF") // let the user know whats going on
for (new i = 1; i <= get_maxplayers(); i++) {
if (is_user_alive(id)){
if (is_user_alive(i) && is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i)){
if (cs_get_user_team(id) != cs_get_user_team(i)) {
set_client_listen(i,id,0)
set_client_listen(id,i,0)
}
}
}
else {
if (is_user_alive(i) && is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i)){
if (i != id){
set_client_listen(i,id,0)
}
}
}
}
return PLUGIN_HANDLED
}
public death(){
if ( get_cvar_num("amx_deadchat")!=1 ) return PLUGIN_CONTINUE
new id = read_data(2)
set_speak(id, SPEAK_LISTENALL)
client_print(id,print_center,"You are dead now, you can chat with other team via voice")
return PLUGIN_HANDLED
}
public alive(id){
if ( get_cvar_num("amx_deadchat")!=1 ) return PLUGIN_CONTINUE
set_speak(id, SPEAK_NORMAL)
return PLUGIN_CONTINUE
}