Raised This Month: $51 Target: $400
 12% 

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
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-22-2008 , 12:01   Re: How to make a ini file?
Reply With Quote #4

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 #5

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 #6

fclose( fopen( g_szFile, "x" )

can be

fclose( fopen( g_szFile, "" )

? Don't write anything?
__________________
Aaaaaa!
GoGoGo is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 12-22-2008 , 13:39   Re: How to make a ini file?
Reply With Quote #7

"x" is a flag. It will create an empty file.
__________________
hleV is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-22-2008 , 13:40   Re: How to make a ini file?
Reply With Quote #8

If you are looking to just save settings and do not care about it being in ini-file format, try using nVault. The commands are very simple.
__________________
Bugsy 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 #9

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
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-22-2008 , 14:14   Re: How to make a ini file?
Reply With Quote #10

Using this:
fclose(fopen("filename.ini", "wt"));

Makes an empty file.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 02:46.


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