AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Annoyng bug with replace function (https://forums.alliedmods.net/showthread.php?t=90054)

Unlimited! 04-13-2009 13:24

Annoyng bug with replace function
 
I'm using replace_all function, and it says this
Quote:

L 04/13/2009 - 00:00:13: replace() buffer not big enough (35>=33)
L 04/13/2009 - 00:00:13: [AMXX] Displaying debug trace (plugin "zombie_plague40.amxx")
L 04/13/2009 - 00:00:13: [AMXX] Run time error 10: native error (native "replace")
L 04/13/2009 - 00:00:13: [AMXX] [0] string.inc::replace_all (line 239)
L 04/13/2009 - 00:00:13: [AMXX] [1] zombie_plague40.sma::save_data3 (line 9598)
L 04/13/2009 - 00:00:13: [AMXX] [2] zombie_plague40.sma::save_data2 (line 9523)
L 04/13/2009 - 00:00:13: [AMXX] [3] zombie_plague40.sma::save_data (line 9493)
L 04/13/2009 - 00:00:13: [AMXX] [4] zombie_plague40.sma::client_disconnect (line 1645)
In few words, replace_all drops this error: buffer not big enough (35>=33)

Im using this code
PHP Code:

    /* LOGGING*/
    
static name[27]
    
get_user_name(idname26)
    static 
file2[70]
    
formatex(file2sizeof file2 1"Logs_%s.log"name)
    
replace_all(file239"\", "char1")
    replace_all(file2, 39, "
|", "char2")
    replace_all(file2, 39, "
/", "char3")
    replace_all(file2, 39, "
*", "char4")
    replace_all(file2, 39, "
:", "char5")
    replace_all(file2, 39, "
<", "char6")
    replace_all(file2, 39, "
>", "char7")
    replace_all(file2, 39, "
^"""char8")
    
replace_all(file239"?""char9")
    
log_to_file(file2"---------------")
    
log_to_file(file2"Accediendo a estadisticas de %s"name)
    
log_to_file(file2"%s - Puntos Zombie - %i"namestr_to_num(vaultdata))
    
log_to_file(file2"%s - Zombies Matados - %i"namestr_to_num(vaultdata2))
    
log_to_file(file2"%s - Humanos Infectados - %i"namestr_to_num(vaultdata3))
    
log_to_file(file2"%s - Clase Zombie - %i"namestr_to_num(vaultdata4))
    
log_to_file(file2"%s - Armas Automaticas - %i"namestr_to_num(vaultdata5))
    
log_to_file(file2"%s - Arma Primaria - %i"namestr_to_num(vaultdata6))
    
log_to_file(file2"%s - Arma Secundaria - %i"namestr_to_num(vaultdata7))
    
log_to_file(file2"%s - Granadas - %i"namestr_to_num(vaultdata8))
    
log_to_file(file2"Accedidas estadisticas de %s"name)
    
log_to_file(file2"---------------")
    return 
PLUGIN_HANDLED;
    
/* LOGGING*/ 


Arkshine 04-13-2009 13:31

Re: Annoyng bug with replace function
 
Why 39 and not sizeof file2 - 1 ?

Unlimited! 04-13-2009 13:39

Re: Annoyng bug with replace function
 
Quote:

Originally Posted by arkshine (Post 804615)
Why 39 and not sizeof file2 - 1 ?

Ohh, I'm blind though. Sorry this is not my day LOL

stupok 04-13-2009 15:09

Re: Annoyng bug with replace function
 
Quote:

Originally Posted by arkshine (Post 804615)
Why 39 and not sizeof file2 - 1 ?

Any reason to avoid charsmax( file2 ) ? Is it just preference, or is there more to it?

Arkshine 04-13-2009 15:20

Re: Annoyng bug with replace function
 
I don't avoid it. He uses sizeof in its script, that's why I said sizeof instead of charsmax, better understandable for him.


All times are GMT -4. The time now is 02:20.

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