Raised This Month: $32 Target: $400
 8% 

file return 2 times the same line


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 09-12-2012 , 04:00   file return 2 times the same line
Reply With Quote #1

hi everybody, I'm new in sourcemod and my english sucks.. my question is.. why this code return 2 time the last line

PHP Code:
    new String:buffer[64], iString:buffer2[32]
    
    if(
File != INVALID_HANDLE) {
    
        while(!
IsEndOfFile(File)) {
        
            
ReadFileLine(Filebuffercharsmax(buffer))
            
            
BreakString(bufferbuffer2charsmax(buffer2))
            
            
PrintToServer("NAME=%s ELO=%s"buffer2buffer[i])
            
        }
    } 
My File
Code:
"Juann" 35.046012
"CariiTaa~" 34.828620
"djmdjjmdj77" 33.839138
"Player :D" 32.539482
"btx'z" 32.409900
"Legends (aprendiendo)" 32.293331
"[PlanB] Sr. Tosquero" 28.103418
"RAX" 27.353481
"am_goot" 24.435813
"GOLD EDITION" 21.537391
"+.+" 20.779787
"coscoys*-*" 20.142627
"puto de mierda" 19.951238
"!TARiiNGA!" 18.554384
"MkL" 15.425476
"Ramona ._." 14.871540
"sNk" 11.403923
":_: Te[B]e :_:" 10.845191
"AsD" 10.714365
"LeguiDelMillo" 9.045612
"batmanbarabarabara" 7.214382
"re_loco" 6.630043
"[EE.UU] | A7X" 5.902048
"Naaahuelciito" 4.791936
"TuerCa.  (L.P)" 3.968909
"La_Cucaracha" 3.482640
"Leox99" 3.207921
"Luuuucas!" 1.732609
"; S w k 'Evee'" 1.503445
"Hay Q Malote :).!" 1.000000
"facuu" 1.000000
"Pijudo :$" 1.000000
"@_@ *_* PelucaSaaapeee *_* @_@" 1.000000
"CoLoSaNtA.::TaTeNgUe::." 1.000000
"TuerCa.   (L.P)" 1.000000
"| | BricK GamE [FG-ARG] Lovizon" 1.000000
"rodri .-  xd" 1.000000
"wNv otto_strike" 1.000000
"qweqwed" 1.000000
"tu_vieja" 1.000000
":_:_:_:_:_" 1.000000
"BRUNO" 1.000000
"Naaahueelciito" 1.000000
"TuerCa. (L.P)" 1.000000
"GOLD EDITION Boiina Rojja" 1.000000
"MiiLii" 1.000000
"_ExtaSiis_8" 1.000000
"A7X" 1.000000
"MOro" 1.000000
"MED ( exe)" 1.000000
"Boomkid" 1.000000
"MaarCos" 1.000000
"okeichu" 1.000000
thanks for reading
__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 09-12-2012 at 04:31.
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 09-12-2012 , 09:22   Re: file return 2 times the same line
Reply With Quote #2

Quote:
Originally Posted by rak View Post
return 2 time the last line
try do{...}while() instead of while(){...}

Last edited by Leonardo; 09-12-2012 at 09:23.
Leonardo is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 09-12-2012 , 20:41   Re: file return 2 times the same line
Reply With Quote #3

Quote:
Originally Posted by Leonardo View Post
try do{...}while() instead of while(){...}
nop u.u still return 2 times the last line

edit; little solution.. i dont like it but works

PHP Code:
    new String:buffer[64], iString:buffer2[32], String:Check[32], c
    
    
if(File != INVALID_HANDLE) {
        
        do {
        
            
ReadFileLine(Filebuffercharsmax(buffer))
            
            
BreakString(bufferbuffer2charsmax(buffer2))
            
            if(!
CheckLastArray(buffer2Checkc)) {
                
                
c++
                
                
PushArrayString(g_Namebuffer2)
                
                
SetTrieValue(g_Elobuffer2StringToFloat(buffer[i]))
                
                
PrintToServer("NAME=%s ELO=%s ID=%d"buffer2buffer[i], c-1)
            }            
        }
        
        while(!
IsEndOfFile(File))
                
        
CloseHandle(File)
        
        
PrintToServer("FINISH")
        
    }
}

CheckLastArray(String:NewData[], String:Check[32], id) {

    if(!
id)
        return 
false
    
    GetArrayString
(g_Nameid-1Checkcharsmax(Check))
    
    if(
StrEqual(NewDataCheckfalse))
        return 
true
    
    
return false
    

__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 09-13-2012 at 08:45.
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 09-27-2012 , 08:21   Re: file return 2 times the same line
Reply With Quote #4

bump

any idea why this happen?
__________________

www.amxmodx-es.com

Steam: Luchokoldo
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-27-2012 , 08:49   Re: file return 2 times the same line
Reply With Quote #5

Why you just test yourself, starting little.
PHP Code:

public OnPluginStart()
{
    
RegConsoleCmd("sm_test"test);
}

public 
Action:test(clientargs)
{
    new 
Handle:File OpenFile("yourfile.txt""r");

    new 
String:buffer[64], iString:buffer2[32];

    if(
File != INVALID_HANDLE) {

        while(!
IsEndOfFile(File)) {
        
            
ReadFileLine(Filebuffersizeof(buffer));
            
            
BreakString(bufferbuffer2sizeof(buffer2));

            
PrintToServer("%s %s"buffer2buffer[i]);
            
// server conosle output - con_logfile "newfile.txt"
        
}
    }  

Attached Files
File Type: txt yourfile.txt (1.3 KB, 54 views)
File Type: txt newfile.txt (1.3 KB, 131 views)
__________________
Do not Private Message @me
Bacardi is offline
Snach
Member
Join Date: Jul 2012
Old 09-27-2012 , 08:49   Re: file return 2 times the same line
Reply With Quote #6

PHP Code:
new String:buffer[64], iString:buffer2[32];

if(
File != INVALID_HANDLE)
{
    while (
ReadFileLine(Filebuffersizeof(buffer)))
    {
        
BreakString(bufferbuffer2charsmax(buffer2));
        
PrintToServer("NAME=%s ELO=%s"buffer2buffer[i]);
    }

Snach is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:13.


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