AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to make a ini file? (https://forums.alliedmods.net/showthread.php?t=82371)

GoGoGo 12-22-2008 03:15

How to make a ini file?
 
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)

GoGoGo 12-22-2008 10:04

Re: How to make a ini file?
 
Bump?

Dores 12-22-2008 10:38

Re: How to make a ini file?
 
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)?

GoGoGo 12-22-2008 12:01

Re: How to make a ini file?
 
The same with .ini...

Dores 12-22-2008 13:06

Re: How to make a ini file?
 
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.

GoGoGo 12-22-2008 13:18

Re: How to make a ini file?
 
fclose( fopen( g_szFile, "x" )

can be

fclose( fopen( g_szFile, "" )

? Don't write anything?

hleV 12-22-2008 13:39

Re: How to make a ini file?
 
"x" is a flag. It will create an empty file.

Bugsy 12-22-2008 13:40

Re: How to make a ini file?
 
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.

Dores 12-22-2008 14:05

Re: How to make a ini file?
 
Quote:

Originally Posted by GoGoGo (Post 731507)
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. :crab:

Exolent[jNr] 12-22-2008 14:14

Re: How to make a ini file?
 
Using this:
fclose(fopen("filename.ini", "wt"));

Makes an empty file.


All times are GMT -4. The time now is 23:12.

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