PDA

View Full Version : Native: set_speak PROBLEM... [SOLVED]


Bello
06-15-2010, 00:33
Hi friends i have this code:

#include <amxmodx>
#include <amxmisc>
#include <engine>

new const plugin_author[] = "Bello"
new const plugin_name[] = "MUTE PLAYER"
new const plugin_version[] = "1.0"

#define MUTED 2

new const Muted[MUTED][] = {
"[no comm]",
" [no comm]"
}

new Array:Muteados
new Direccion[46]

new bool:MsgMutedChat

public plugin_init() {
register_plugin(plugin_name, plugin_version, plugin_author)
register_concmd(".mute", "cmdMute", ADMIN_RCON, "<name>")
register_concmd(".unmute", "cmdUnmute", ADMIN_RCON, "<name>")

new sConfig[32]
get_configsdir(sConfig, sizeof(sConfig)-1)
formatex(Direccion, sizeof(Direccion)-1, "%s/mute.ini", sConfig)

register_clcmd("say","handle_say")
register_clcmd("say_team","handle_say")

register_message(get_user_msgid("SayText"), "MessageNameChange")

Muteados = ArrayCreate(32, 1)

Cargar_ini()
}

public client_putinserver(id) {
if(!file_exists(Direccion)) return

new ID[28], sName[32]
get_user_authid(id, ID, sizeof(ID)-1)
get_user_name(id, sName, sizeof(sName)-1)

new lines = file_size(Direccion,1)
new file[1024], len

for(new i=0; i<=lines; i++) {
read_file(Direccion, i , file, 1023, len)

if(equal(ID, file)) {
set_speak(id, 1)

if(!(contain(sName, Muted[0]) != -1)) {
add(sName, sizeof(sName)-1, Muted[1])
set_user_info(id, "name", sName)
MsgMutedChat = true
break
}
}
}
}

public cmdMute(id, level, cid) {
if(!cmd_access(id, level, cid, 2)) return 1

new Argv[32]
read_argv(1, Argv, sizeof(Argv)-1)

new player = cmd_target(id, Argv, 3)

new ID[28], sName[32]
get_user_authid(player, ID, sizeof(ID)-1)
get_user_name(player, sName, sizeof(sName)-1)

new lines = file_size(Direccion,1)
new file[1024], len

for(new i=0; i<=lines; i++) {
read_file(Direccion, i , file, 1023, len)

if(equal(ID, file)) {
console_print(id, "El SteamID: %s, ya esta en la lista", ID)
return 1
}
}

MsgMutedChat = true
set_speak(player, 1)

new NAME[32]
get_user_name(player, NAME, sizeof(NAME)-1)
client_print(0, print_chat, "[ESVE Pug] %s ha sido muteado.", NAME)

write_file(Direccion, ID)
console_print(id, "Usuario muteado: %s^nSe ha agregado el SteamID: %s", sName, ID)

if(!(contain(sName, Muted[0]) != -1)) {
add(sName, sizeof(sName)-1, Muted[1])
set_user_info(player, "name", sName)
}
return 1
}

public cmdUnmute(id, level, cid) {
if(!cmd_access(id, level, cid, 2)) return 1

new Argv[32]
read_argv(1, Argv, sizeof(Argv)-1)

new player = cmd_target(id, Argv, 3)

new ID[28], sName[32]
get_user_authid(player, ID, sizeof(ID)-1)
get_user_name(player, sName, sizeof(sName)-1)

MsgMutedChat = true

new NAME[32]
get_user_name(player, NAME, sizeof(NAME)-1)
client_print(0, print_chat, "[ESVE Pug] %s ha sido desmuteado.", NAME)

new lines = file_size(Direccion, 1)
new file[1024], len

for(new i=0; i<=lines; i++) {
read_file(Direccion, i , file, 1023, len)

if(equal(ID, file)) {
set_speak(player, 0)
write_file(Direccion, "", i)
console_print(id, "Cliente: %s ha sido desmuteado^nSteamID: %s, ha sido removido", sName, ID)

if(contain(sName, Muted[0]) != -1) {
replace_all(sName, sizeof(sName)-1, Muted[1], "")
set_user_info(player, "name", sName)
break
}
}
}
return 1
}

public Cargar_ini() {
if(!file_exists(Direccion)) return

new linea[128], file = fopen(Direccion, "rt")

while(file && !feof(file)) {
fgets(file, linea, 127)
replace(linea, 127, "^n", "")

if((linea[0] == '/' && linea[1] == '/') || linea[0] == ';' || strlen(linea) < 1) continue
ArrayPushString(Muteados, linea)
}

if(file) fclose(file)
}

public handle_say(id) {
new ID[28]
get_user_authid(id, ID, sizeof(ID)-1)

new lines = file_size(Direccion, 1)
new file[1024], len

for(new i=0; i<=lines; i++) {
read_file(Direccion, i , file, 1023, len)

if(equal(ID, file)) {
client_print(id, print_chat, "")
return PLUGIN_HANDLED_MAIN
}
}
return PLUGIN_CONTINUE
}

public client_infochanged(id) {
static sName[32], NewName[32], ID[28]
get_user_name(id, sName, sizeof(sName)-1)
get_user_info(id, "name", NewName, sizeof(NewName)-1)
get_user_authid(id, ID, sizeof(ID)-1)

if(!equali(sName, NewName)) {
new lines = file_size(Direccion,1)
new file[1024], len

for(new i=0; i<=lines; i++) {
read_file(Direccion, i , file, 1023, len)

if(equal(ID, file)) {
set_speak(id, 1)

if(!(contain(NewName, Muted[0]) != -1)) {
add(NewName, sizeof(sName)-1, Muted[1])
set_user_info(id, "name", NewName)
break
}
}
}
}
}

public MessageNameChange(msg_id, msg_dest, receiver) {
if(MsgMutedChat) {
new szInfo[64]
get_msg_arg_string(2, szInfo, 63)

if(!equali(szInfo, "#Cstrike_Name_Change")) return 0

MsgMutedChat = false
return 1
}
return 0
}The problem is this:

L 06/14/2010 - 23:57:39: Start of error session.
L 06/14/2010 - 23:57:39: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20100614.log")
L 06/14/2010 - 23:57:39: [ENGINE] Invalid player 1
L 06/14/2010 - 23:57:39: [AMXX] Displaying debug trace (plugin "yap_mute.amxx")
L 06/14/2010 - 23:57:39: [AMXX] Run time error 10: native error (native "set_speak")
L 06/14/2010 - 23:57:39: [AMXX] [0] yap_mute.sma::client_infochanged (line 198)I have not able to fix this problem, as could fix it?

Alucard^
06-15-2010, 01:00
mMM, i am not sure, but try with this:

if(is_user_connected(id) )
set_speak(id, 1)

Bello
06-16-2010, 20:20
No, the problem this is in infochanged...

public client_infochanged(id) {
static sName[32], NewName[32], ID[28]
get_user_name(id, sName, sizeof(sName)-1)
get_user_info(id, "name", NewName, sizeof(NewName)-1)
get_user_authid(id, ID, sizeof(ID)-1)

if(!equali(sName, NewName)) {
new lines = file_size(Direccion,1)
new file[1024], len

for(new i=0; i<=lines; i++) {
read_file(Direccion, i , file, 1023, len)

if(equal(ID, file)) {
set_speak(id, 1)

if(!(contain(NewName, Muted[0]) != -1)) {
add(NewName, sizeof(sName)-1, Muted[1])
set_user_info(id, "name", NewName)
break
}
}
}
}
}

L 06/14/2010 - 23:57:39: Start of error session.
L 06/14/2010 - 23:57:39: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20100614.log")
L 06/14/2010 - 23:57:39: [ENGINE] Invalid player 1
L 06/14/2010 - 23:57:39: [AMXX] Displaying debug trace (plugin "yap_mute.amxx")
L 06/14/2010 - 23:57:39: [AMXX] Run time error 10: native error (native "set_speak")
L 06/14/2010 - 23:57:39: [AMXX] [0] yap_mute.sma::client_infochanged (line 198)

who can help with this :(

fysiks
06-16-2010, 22:42
The suggestion is a good one, you should check if the user is connected before doing anything in infochanged.

Show the code that you tried because I'm pretty sure that you did it wrong (if you did anything at all other that ASSUME).

Bello
06-16-2010, 23:04
The code is that this in the post #1, The client_info_changed is used only when the user changes its name is muted.

I can't use this:

if(is_user_connected(id) )
set_speak(id, 1)

Since that part of the code is scheduled in client_putinserver...

As i can solve the problem that this in infochanged?

P.S: The other part of the code works to the perfection

fysiks
06-17-2010, 00:18
The code is that this in the post #1, The client_info_changed is used only when the user changes its name is muted.

I can't use this:

if(is_user_connected(id) )
set_speak(id, 1)

Since that part of the code is scheduled in client_putinserver...

As i can solve the problem that this in infochanged?

P.S: The other part of the code works to the perfection

Ok, seriously, just do what he said. client_infochanged it called before the person is actually connected!

Bello
06-17-2010, 00:29
Ok then what place as said alucard?

fysiks
06-17-2010, 00:35
Ok then what place as said alucard?

Wow, this is sad. You can either do what he said or do this:

public client_infochanged(id)
{
if( is_user_connected(id) )
{
static sName[32], NewName[32], ID[28]
get_user_name(id, sName, sizeof(sName)-1)
get_user_info(id, "name", NewName, sizeof(NewName)-1)
get_user_authid(id, ID, sizeof(ID)-1)

if(!equali(sName, NewName))
{
new lines = file_size(Direccion,1)
new file[1024], len

for(new i=0; i<=lines; i++)
{
read_file(Direccion, i , file, 1023, len)

if(equal(ID, file))
{
set_speak(id, 1)

if(!(contain(NewName, Muted[0]) != -1))
{
add(NewName, sizeof(sName)-1, Muted[1])
set_user_info(id, "name", NewName)
break
}
}
}
}
}
}



Mine is more efficient.

Bello
06-17-2010, 00:59
thanks fysiks You can revise this post?

https://forums.alliedmods.net/showthread.php?p=1210981#post1210981

wrecked_
06-17-2010, 01:35
thanks fysiks You can revise this post?

https://forums.alliedmods.net/showthread.php?p=1210981#post1210981
Has anyone else noticed yet, or is it just me?

RedRobster
06-17-2010, 04:29
Just you. :shock:

Bello
06-17-2010, 18:26
Has anyone else noticed yet, or is it just me?

lol, that speak?