Raised This Month: $ Target: $400
 0% 

How to make a ini file?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-22-2008 , 03:15   How to make a ini file?
Reply With Quote #1

Hi all,
I have a problem I have this code:
PHP Code:
    get_mapname(filename255);
    
get_configsdir(confFolder31);
    
format(filename255"%s/test/%s.coord"confFolderfilename);    

    if(
id 0)
    {
        
client_print(idprint_chat"OMG %s"filename);
        
        
        new 
filepointer fopen(filename"w");
        
client_print(idprint_chat"Filepoint %d"filepointer);
        if(
filepointer)
        {
            
client_print(idprint_chat"Save3");    
            
fprintf(filepointer"lol");
            
fclose(filepointer);
            
client_print(idprint_chat"Save1.");
        } else {    
        new 
fopenfilename"w" );
        
fputs(f"lol2");
        
fclose(f);
        
client_print(idprint_chat"Save2.");    
        }
    } 
And when I'm starting this funtion the plugin writes:
Code:
OMG addons/amxmodx/configs/test/cs_assault_upc.coord
Filepoint 0
Save2
How to make that plugin will write "lol"? (Plugin doesn't make any file)
__________________
Aaaaaa!
GoGoGo is offline
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-22-2008 , 10:04   Re: How to make a ini file?
Reply With Quote #2

Bump?
__________________
Aaaaaa!
GoGoGo is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-22-2008 , 10:38   Re: How to make a ini file?
Reply With Quote #3

I've never heard of .coord extension.
How do you except to make a .ini file when you've given your file a .coord extension(which I don't think even exists)?
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 12-22-2008 , 18:19   Re: How to make a ini file?
Reply With Quote #4

Quote:
Originally Posted by Dores View Post
I've never heard of .coord extension.
How do you except to make a .ini file when you've given your file a .coord extension(which I don't think even exists)?
A file extension is nothing but a piece of metadata that tells the operating system which program should be used to read a file that uses a particular encoding technique. It has no bearing on how the file is created in this context. The .ini file format is not well defined, either by an authoritative body or by de facto standard. As such, it can be considered as nothing more than a standard text file containing settings. Therefore, it really doesn't matter whether his file has an extension of .ini, .cuttlefish (if the file system in use permits an extension of that length of course), or since he probably won't be using a desktop computer to open it, whether it has one at all.

The documentation of C's fopen() makes no mention of an x flag (AMX Mod X's fopen() is just a wrapper).
__________________
No support via PM.

Last edited by Lee; 12-22-2008 at 18:37.
Lee is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-23-2008 , 07:46   Re: How to make a ini file?
Reply With Quote #5

Quote:
Originally Posted by Lee View Post
A file extension is nothing but a piece of metadata that tells the operating system which program should be used to read a file that uses a particular encoding technique. It has no bearing on how the file is created in this context. The .ini file format is not well defined, either by an authoritative body or by de facto standard. As such, it can be considered as nothing more than a standard text file containing settings. Therefore, it really doesn't matter whether his file has an extension of .ini, .cuttlefish (if the file system in use permits an extension of that length of course), or since he probably won't be using a desktop computer to open it, whether it has one at all.
I know, but if you look at the topic he specifically asked for a .ini file, so I thought maybe it does matter for him. I guess I was wrong.

Quote:
Originally Posted by Lee
The documentation of C's fopen() makes no mention of an x flag (AMX Mod X's fopen() is just a wrapper).
AMX Mod X is also very similar to PHP, so I thought that the PHP flag "x" might exist here too. Thanks for the information.

@GoGoGo
Search in the code I gave you the "x" flag and change it to "wt" then test.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-23-2008 , 09:50   Re: How to make a ini file?
Reply With Quote #6

In my Windows it doesn't make file. It doesn't matter with "x" or "wt". Maybe something in my Windows block it?
__________________
Aaaaaa!
GoGoGo is offline
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-22-2008 , 12:01   Re: How to make a ini file?
Reply With Quote #7

The same with .ini...
__________________
Aaaaaa!
GoGoGo is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-22-2008 , 13:06   Re: How to make a ini file?
Reply With Quote #8

Try this:
Code:
#include <amxmodx> #include <amxmisc> #define VERSION "1.0" new g_szFile[ 62 ]; public plugin_precache() {     get_configsdir( g_szFile, 61 );     new mapname[ 20 ];     get_mapname( mapname, 19 );     format( g_szFile, 61, "%s/test/%s.ini", g_szFile, mapname );         fclose( fopen( g_szFile, "x" ) ); // Creates the file. // I think it's useless as the file is //                    created when attempting to write into it. } public plugin_init() {     register_plugin( "File Test", VERSION, "Dores" );     register_clcmd( "say /lol", "Cmd_LoL" ); } public Cmd_LoL( id ) {     new f = fopen( g_szFile, "w" );     fputs( f, "LoL" );     fclose( f ); // Always close the file no matter what. }
Type in chat: /lol, or say /lol in console to write "LoL" into the file.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-22-2008 , 13:18   Re: How to make a ini file?
Reply With Quote #9

fclose( fopen( g_szFile, "x" )

can be

fclose( fopen( g_szFile, "" )

? Don't write anything?
__________________
Aaaaaa!
GoGoGo is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-22-2008 , 14:05   Re: How to make a ini file?
Reply With Quote #10

Quote:
Originally Posted by GoGoGo View Post
fclose( fopen( g_szFile, "x" )

can be

fclose( fopen( g_szFile, "" )

? Don't write anything?
A constant mode must be set.

Please test and tell me if it works.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Reply



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 23:12.


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