PDA

View Full Version : Advanced Block RTV


Dark Style
10-30-2011, 16:12
http://img163.**************/img163/4531/63888648.png

[Description]
This plugin turn off the option rtv when a admin is online and isn't on the spectator team.

Original Post:
http://forums.alliedmods.net/showthread.php?t=145621

Why create another post?
I create this new post because the plugin have a bug and the original author is banned. The bug was this: if you leave a space before /rtv the plugin didn't work.

[Attention]
If you have GALILEO (http://forums.alliedmods.net/showthread.php?p=684848) installed in your server and the version is above 1.2 (http://code.google.com/p/amxx-plugin-galileo/wiki/changeLog), you don't need this plugin...
If you have GALILEO (http://forums.alliedmods.net/showthread.php?p=684848) installed in your server and the version is lower 1.2 (http://code.google.com/p/amxx-plugin-galileo/wiki/changeLog), you need to change the cvar:
// Indicates which say commands can be used to rock the vote.
gal_rtv_commands 3

(TO)

gal_rtv_commands 2

[Messages]
Warn for the players when a admin is on and say rtv.

[en]
[AMXX] There are admins on server, therefore you can't say rtv.
[bp]
[AMXX] Tem admins no server, por isso voce nao pode dizer rtv.
[es]
[AMXX] Tiene los administradores del servidor, por lo que no se puede decir rtv.
[de]
[AMXX] Es sind Admins auf dem Server, deswegen kann rtv momentan nicht genutzt werden.
[sr]
[AMXX] Imaju Admini na Serveru, zato trenutno rtv nemoze da se koristi.
[fr]
[AMXX] La commande rtv est inactive lorsqu'il y'a des admins sur le serveur.
[bg]
[AMXX] Ima administratori v servera i zatova ne moje da polzvate rtv.
[hu]
[AMXX] A szerveren van admin, ezert nem tudsz rtvzni!
[tr]
[AMXX] Serverda Admin Oldugu Icin RTV Komutu Gecersiz.
[pl]
[AMXX] Na serwerze sa admini, wiec nie mozesz uzyc komendy rtv.
[ro]
[AMXX] Sunt admini pe acest server, nu poti folosi RTV.

[Cvars]
// 1 active, 0 disables
amx_block_rtv <1 or 0>

[RTV Messages Block]
You can add in the file advanced_block_rtv.ini more things, default:
; Advanced Block RTV
; Maximun Caracteres: 300

rtv
/rtv
.rtv
rockthevote
/rockthevote
.rockthevote
rock the vote
/rock the vote
.rock the vote

[Instaling]
- Put the file advanced_block_rtv.ini in: amxmodx/configs/
- Put the file advanced_block_rtv.txt in: amxmodx/data/lang/
- Put the file advanced_block_rtv.amxx in: amxmodx/plugins/
- Open the file amxmodx/configs/plugins.ini and write advanced_block_rtv.amxx

[Modules]
- Cstrike.

[Credits]
MMYTH (http://forums.alliedmods.net/member.php?u=89364) - Original Plugin;
GalegO (http://forums.alliedmods.net/member.php?u=77181) - Related bug plugin;
Dark Style (http://forums.alliedmods.net/member.php?u=114604)(me) - Fixed bug at the plugin.

[Translations (http://forums.alliedmods.net/showthread.php?p=1588386)]

[Changelog]
0.0.1b - Fixed some bugs and test it.
0.0.2 - Optmized functions.
0.0.3 - Optmized functions,
Added a new and better form to get admin on.

nikhilgupta345
10-30-2011, 16:22
Instead of reading the file every time a player talks, read it when the plugin starts, and store the strings into a Trie. Also, it would be better if you stored whether or not an admin was in the server as a bool. So when the player connects, determine whether he is an admin or not and set the bool to true if he is. Then when all admins leave, set the bool to false.

Then you could do


if( TrieKeyExists( g_tCommands, szMessage ) && g_bAdminInServer )
{ ... }

Dark Style
10-30-2011, 16:50
Update 0.0.2

nikhilgupta345
10-30-2011, 17:09
Update 0.0.2

Instead of doing it like you did, do the following:


/*
[Description]
This plugin turn off the option rtv when a admin is online.

Original Post:
http://forums.alliedmods.net/showthread.php?t=145621

[Cvars]
// 1 active, 0 disables
amx_block_rtv <1 or 0>

[Changelog]
0.0.1b - Fixed some bugs and test it.
0.0.2 - Optmized functions.
*/

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#pragma semicolon 1

#define PLUGIN "Advanced Block RTV"
#define VERSION "0.0.2"
#define AUTHOR "MMYTH&Dark Style"

new g_on, i, adminon;

new Trie:rtv;

new configdir[50], buffer[301], form[40];

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);

register_dictionary("advanced_block_rtv.txt");

g_on = register_cvar("amx_block_rtv", "1");

register_clcmd("say", "HandleSay");
register_clcmd("say_team", "HandleSay");

get_configsdir(configdir, charsmax(configdir));
add(configdir, charsmax(configdir), "/advanced_block_rtv.ini", 0);

rtv = TrieCreate();

new fp = fopen(configdir, "rt");

if(fp)
{
while(!feof(fp))
{
fgets(fp, buffer, charsmax(buffer));

trim(buffer);

if(!buffer[0] || buffer[0] == ';' || buffer[0] == '/' && buffer[1] == '/')
continue;

TrieSetCell( rtv, buffer, 1 );
}
}
else
{
set_fail_state("File ^"advanced_block_rtv.ini^" Required");
}

fclose(fp);
}

public plugin_end()
{
TrieDestroy(rtv);
}

public client_putinserver(id)
{
if(is_user_admin(id))
adminon ++;
}

public client_disconnect(id)
{
if(is_user_admin(id))
adminon --;
}

public HandleSay(id)
{
if(get_pcvar_num(g_on) && adminon != 0 && is_user_connected(id))
{
new args[128];
read_args(args, 127);
remove_quotes(args);

if( TrieKeyExists( rtv, args ) )
{
client_print(id, print_chat, "%L", id, "BLOCK_RTV_MSG1");
return PLUGIN_HANDLED;
}
}

return PLUGIN_CONTINUE;
}

Dark Style
10-30-2011, 19:07
Instead of doing it like you did, do the following:


/*
[Description]
This plugin turn off the option rtv when a admin is online.

Original Post:
http://forums.alliedmods.net/showthread.php?t=145621

[Cvars]
// 1 active, 0 disables
amx_block_rtv <1 or 0>

[Changelog]
0.0.1b - Fixed some bugs and test it.
0.0.2 - Optmized functions.
*/

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#pragma semicolon 1

#define PLUGIN "Advanced Block RTV"
#define VERSION "0.0.2"
#define AUTHOR "MMYTH&Dark Style"

new g_on, i, adminon;

new Trie:rtv;

new configdir[50], buffer[301], form[40];

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);

register_dictionary("advanced_block_rtv.txt");

g_on = register_cvar("amx_block_rtv", "1");

register_clcmd("say", "HandleSay");
register_clcmd("say_team", "HandleSay");

get_configsdir(configdir, charsmax(configdir));
add(configdir, charsmax(configdir), "/advanced_block_rtv.ini", 0);

rtv = TrieCreate();

new fp = fopen(configdir, "rt");

if(fp)
{
while(!feof(fp))
{
fgets(fp, buffer, charsmax(buffer));

trim(buffer);

if(!buffer[0] || buffer[0] == ';' || buffer[0] == '/' && buffer[1] == '/')
continue;

TrieSetCell( rtv, buffer, 1 );
}
}
else
{
set_fail_state("File ^"advanced_block_rtv.ini^" Required");
}

fclose(fp);
}

public plugin_end()
{
TrieDestroy(rtv);
}

public client_putinserver(id)
{
if(is_user_admin(id))
adminon ++;
}

public client_disconnect(id)
{
if(is_user_admin(id))
adminon --;
}

public HandleSay(id)
{
if(get_pcvar_num(g_on) && adminon != 0 && is_user_connected(id))
{
new args[128];
read_args(args, 127);
remove_quotes(args);

if( TrieKeyExists( rtv, args ) )
{
client_print(id, print_chat, "%L", id, "BLOCK_RTV_MSG1");
return PLUGIN_HANDLED;
}
}

return PLUGIN_CONTINUE;
}


Your version isn't compatible with containi, but thanks.

Arkshine
10-30-2011, 19:10
You just need to lower all the characters of the string before checking the trie.

Dark Style
10-30-2011, 19:12
Give me an exemple.

Arkshine
10-30-2011, 19:14
http://www.amxmodx.org/funcwiki.php?go=func&id=60 ...

Dark Style
11-01-2011, 19:14
Update 0.0.3

- I didin't need use strtolower(), i just use trim() and it's ok now.

Korxu
11-02-2011, 09:56
WTF? Don't use Google Translator... it is a very bad translation...

Change:

[es]
[AMXX] Tiene los administradores del servidor, por lo que no se puede decir rtv.

:arrow::arrow:

[es]
[AMXX] Hay administradores en el servidor, no se puede escribir rtv.