Hi i made a plugin that turns alltalk on and off, reacting on how many players on the server.
I made it with a cvar put in amxx.cfg, so users of the plugin can put in the number of users they want to.
In my code it is set to 4, and it works nicely when player number 5 joins, it turns off all talk, but when player 5 disconnects alltalk dont come back on.
Here is my code:
Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "AutoAllTalk"
#define VERSION "1.1"
#define AUTHOR "Lone Wolf"
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_logevent("roundstart", 2, "0=World triggered", "1=Round_Start")
}
public roundstart() {
set_task(1.0, "set_NewAlltalk")
}
public client_connect(id) {
set_task(1.0, "set_NewAlltalk")
}
public client_disconnect(id) {
set_task(1.0, "set_NewAlltalk")
}
public set_NewAlltalk(taskId) {
new tmpPlayer
new tmpCount
tmpPlayer = get_cvar_num("amx_nrPlayer")
tmpCount = get_playersnum(1)
if (tmpCount==tmpPlayer) {
set_cvar_num("sv_alltalk",1)
}
else if (tmpCount==(tmpPlayer+1)) {
set_cvar_num("sv_alltalk",0)
}
}
I also tried using plugin_init() instead of roundstart, but that didnt seem to work either, i removed that because i wasnt sure if plugin_init is run on reload or mapchange......
Hope someone can se the error
/Lone Wolf