AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Native: set_speak PROBLEM... [SOLVED] (https://forums.alliedmods.net/showthread.php?t=129628)

Bello 06-15-2010 00:33

Native: set_speak PROBLEM... [SOLVED]
 
Hi friends i have this code:

PHP 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_nameplugin_versionplugin_author)
    
register_concmd(".mute""cmdMute"ADMIN_RCON"<name>")
    
register_concmd(".unmute""cmdUnmute"ADMIN_RCON"<name>")
    
    new 
sConfig[32]
    
get_configsdir(sConfigsizeof(sConfig)-1)
    
formatex(Direccionsizeof(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(321)
    
    
Cargar_ini()
}

public 
client_putinserver(id) {
    if(!
file_exists(Direccion)) return
    
    new 
ID[28], sName[32]
    
get_user_authid(idIDsizeof(ID)-1)
    
get_user_name(idsNamesizeof(sName)-1)
    
    new 
lines file_size(Direccion,1)
    new 
file[1024], len
    
    
for(new i=0i<=linesi++) {
        
read_file(Direccionfile1023len)
        
        if(
equal(IDfile)) {
            
set_speak(id1)
            
            if(!(
contain(sNameMuted[0]) != -1)) {
                
add(sNamesizeof(sName)-1Muted[1])
                
set_user_info(id"name"sName)
                
MsgMutedChat true
                
break
            }
        }
    }
}

public 
cmdMute(idlevelcid) {
    if(!
cmd_access(idlevelcid2)) return 1
    
    
new Argv[32]
    
read_argv(1Argvsizeof(Argv)-1)
    
    new 
player cmd_target(idArgv3)
    
    new 
ID[28], sName[32]
    
get_user_authid(playerIDsizeof(ID)-1)
    
get_user_name(playersNamesizeof(sName)-1)
    
    new 
lines file_size(Direccion,1)
    new 
file[1024], len
    
    
for(new i=0i<=linesi++) {
        
read_file(Direccionfile1023len)
        
        if(
equal(IDfile)) {
            
console_print(id"El SteamID: %s, ya esta en la lista"ID)
            return 
1
        
}
    }

    
MsgMutedChat true
    set_speak
(player1)    

    new 
NAME[32]
    
get_user_name(playerNAMEsizeof(NAME)-1)
    
client_print(0print_chat"[ESVE Pug] %s ha sido muteado."NAME)
    
    
write_file(DireccionID)
    
console_print(id"Usuario muteado: %s^nSe ha agregado el SteamID: %s"sNameID)
    
    if(!(
contain(sNameMuted[0]) != -1)) {
        
add(sNamesizeof(sName)-1Muted[1])
        
set_user_info(player"name"sName)
    }
    return 
1
}

public 
cmdUnmute(idlevelcid) {
    if(!
cmd_access(idlevelcid2)) return 
    
    
new Argv[32]
    
read_argv(1Argvsizeof(Argv)-1)
    
    new 
player cmd_target(idArgv3)
    
    new 
ID[28], sName[32]
    
get_user_authid(playerIDsizeof(ID)-1)
    
get_user_name(playersNamesizeof(sName)-1)

    
MsgMutedChat true

    
new NAME[32]
    
get_user_name(playerNAMEsizeof(NAME)-1)
    
client_print(0print_chat"[ESVE Pug] %s ha sido desmuteado."NAME)
    
    new 
lines file_size(Direccion1)
    new 
file[1024], len
    
    
for(new i=0i<=linesi++) {
        
read_file(Direccionfile1023len)
        
        if(
equal(IDfile)) {
            
set_speak(player0)
            
write_file(Direccion""i)
            
console_print(id"Cliente: %s ha sido desmuteado^nSteamID: %s, ha sido removido"sNameID)
            
            if(
contain(sNameMuted[0]) != -1) {
                
replace_all(sNamesizeof(sName)-1Muted[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(filelinea127)
        
replace(linea127"^n""")
            
        if((
linea[0] == '/' && linea[1] == '/') || linea[0] == ';' || strlen(linea) < 1) continue
        
ArrayPushString(Muteadoslinea)
    }

    if(
filefclose(file)
}

public 
handle_say(id) {
    new 
ID[28]
    
get_user_authid(idIDsizeof(ID)-1)
    
    new 
lines file_size(Direccion1)
    new 
file[1024], len
    
    
for(new i=0i<=linesi++) {
        
read_file(Direccionfile1023len)
        
        if(
equal(IDfile)) {
            
client_print(idprint_chat"")
            return 
PLUGIN_HANDLED_MAIN
            
}
    }
    return 
PLUGIN_CONTINUE
}

public 
client_infochanged(id) {
    static 
sName[32], NewName[32], ID[28]
    
get_user_name(idsNamesizeof(sName)-1)
    
get_user_info(id"name"NewNamesizeof(NewName)-1)
    
get_user_authid(idIDsizeof(ID)-1)
    
    if(!
equali(sNameNewName)) {
        new 
lines file_size(Direccion,1)
        new 
file[1024], len
    
        
for(new i=0i<=linesi++) {
            
read_file(Direccionfile1023len)
        
            if(
equal(IDfile)) {
                
set_speak(id1)
            
                if(!(
contain(NewNameMuted[0]) != -1)) {
                    
add(NewNamesizeof(sName)-1Muted[1])
                    
set_user_info(id"name"NewName)
                    break
                }
            }
        }
    }
}

public 
MessageNameChange(msg_idmsg_destreceiver) {
    if(
MsgMutedChat) {
        new 
szInfo[64]
        
get_msg_arg_string(2szInfo63)

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

        MsgMutedChat 
false
        
return 1
    
}
    return 
0


The problem is this:

Code:

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

Re: CODE PROBLEM...
 
mMM, i am not sure, but try with this:

PHP Code:

if(is_user_connected(id) )
    
set_speak(id1


Bello 06-16-2010 20:20

Re: CODE PROBLEM...
 
No, the problem this is in infochanged...

PHP Code:

public client_infochanged(id) {
    static 
sName[32], NewName[32], ID[28]
    
get_user_name(idsNamesizeof(sName)-1)
    
get_user_info(id"name"NewNamesizeof(NewName)-1)
    
get_user_authid(idIDsizeof(ID)-1)
    
    if(!
equali(sNameNewName)) {
        new 
lines file_size(Direccion,1)
        new 
file[1024], len
    
        
for(new i=0i<=linesi++) {
            
read_file(Direccionfile1023len)
        
            if(
equal(IDfile)) {
                
set_speak(id1)
            
                if(!(
contain(NewNameMuted[0]) != -1)) {
                    
add(NewNamesizeof(sName)-1Muted[1])
                    
set_user_info(id"name"NewName)
                    break
                }
            }
        }
    }


Code:

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

Re: CODE PROBLEM...
 
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

Re: CODE PROBLEM...
 
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:

PHP Code:

if(is_user_connected(id) )
    
set_speak(id1

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

Re: CODE PROBLEM...
 
Quote:

Originally Posted by Bello (Post 1211069)
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:

PHP Code:

if(is_user_connected(id) )
    
set_speak(id1

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

Re: Native: set_speak PROBLEM...
 
Ok then what place as said alucard?

fysiks 06-17-2010 00:35

Re: Native: set_speak PROBLEM...
 
Quote:

Originally Posted by Bello (Post 1211109)
Ok then what place as said alucard?

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

PHP Code:

public client_infochanged(id)
{
    if( 
is_user_connected(id) )
    {
        static 
sName[32], NewName[32], ID[28]
        
get_user_name(idsNamesizeof(sName)-1)
        
get_user_info(id"name"NewNamesizeof(NewName)-1)
        
get_user_authid(idIDsizeof(ID)-1)
        
        if(!
equali(sNameNewName))
        {
            new 
lines file_size(Direccion,1)
            new 
file[1024], len
        
            
for(new i=0i<=linesi++)
            {
                
read_file(Direccionfile1023len)
            
                if(
equal(IDfile))
                {
                    
set_speak(id1)
                
                    if(!(
contain(NewNameMuted[0]) != -1))
                    {
                        
add(NewNamesizeof(sName)-1Muted[1])
                        
set_user_info(id"name"NewName)
                        break
                    }
                }
            }
        }
    }


Mine is more efficient.

Bello 06-17-2010 00:59

Re: Native: set_speak PROBLEM... [SOLVED]
 
thanks fysiks You can revise this post?

https://forums.alliedmods.net/showth...81#post1210981

wrecked_ 06-17-2010 01:35

Re: Native: set_speak PROBLEM... [SOLVED]
 
Quote:

Originally Posted by Bello (Post 1211121)
thanks fysiks You can revise this post?

https://forums.alliedmods.net/showth...81#post1210981

Has anyone else noticed yet, or is it just me?


All times are GMT -4. The time now is 14:51.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.