AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   read_file help me (https://forums.alliedmods.net/showthread.php?t=147773)

JonathanRF 01-13-2011 20:20

read_file help me
 
hi every1, i'm from brazil, so sry for my bad english,
PHP Code:

[...]
    new 
arquivo[62]; // arquivo = file (portuguese...)
    
new usrname[32];
    
    
get_user_name(id,usrname,31)
    
    
replace_all(usrname,31,":","_00");
    
replace_all(usrname,31,">","_01");
    
replace_all(usrname,31,"<","_02");
    
replace_all(usrname,31,"/","_03");
    
replace_all(usrname,31,"?","_04");
    
    
format(arquivo,sizeof(arquivo),"addons/amxmodx/data/users/%s.txt",usrname)
    
    
/*and here i wanna read the file, are 4 lines, i tried to do it:
    new data[4][31];
    new ln;

    read_file(arquivo,0,data[0],30,ln);
    read_file(arquivo,1,data[1],30,ln);
    etc...
    but "data[x]" hasn't the content of the line
    */
[...] 

help me please :)
thx :wink:

Exolent[jNr] 01-13-2011 20:25

Re: read_file help me
 
Looks fine.
Make sure that the directory exists as well as the file.

JonathanRF 01-13-2011 20:28

Re: read_file help me
 
file and directory exists...

Exolent[jNr] 01-13-2011 20:35

Re: read_file help me
 
Show your code that writes to the file.

JonathanRF 01-13-2011 20:37

Re: read_file help me
 
PHP Code:

    new arquivo[62];
    new 
usrname[32];
    
    
get_user_name(id,usrname,31)
    
    
replace_all(usrname,31,":","_00");
    
replace_all(usrname,31,">","_01");
    
replace_all(usrname,31,"<","_02");
    
replace_all(usrname,31,"/","_03");
    
replace_all(usrname,31,"?","_04");
    
    
format(arquivo,sizeof(arquivo),"addons/amxmodx/data/users/%s.txt",usrname)
    
    
//Escreve no Arquivo (write to file)
    
write_file(arquivo,"1",0);
    
write_file(arquivo,"0",1);
    
write_file(arquivo,"0",2);
    
write_file(arquivo,"1000",3); 


Exolent[jNr] 01-13-2011 20:45

Re: read_file help me
 
Show the contents of the file when it is written to (the actual file contents, don't just type it out).

JonathanRF 01-13-2011 20:50

Re: read_file help me
 
content of file:
Code:

1
0
0
1000

Filename:
EU_01SOU_02EU_00SENDO_03EU.txt (my nickname: EU>SOU<EU:SENDO/EU)

Exolent[jNr] 01-13-2011 20:59

Re: read_file help me
 
Everything seems fine. I don't see where the problem would be.


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

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