AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Load config file? (https://forums.alliedmods.net/showthread.php?t=120330)

fixed 03-03-2010 13:51

Load config file?
 
I want to load a .ini file to a client_print how do I do that?

Exolent[jNr] 03-03-2010 15:43

Re: Load config file?
 
http://forums.alliedmods.net/showthread.php?t=46218

fixed 03-03-2010 16:00

Re: Load config file?
 
Thanks, gotta check it out

fixed 03-03-2010 16:08

Re: Load config file?
 
Im new to scripting in amxx so it is hard to convert it to what I want.
I want people to write something in a .ini file and then if u example type /text the text you wrote in the .ini file should show up when u type that.

fysiks 03-03-2010 18:23

Re: Load config file?
 
How many different lines are you looking to have in the .ini file?

fixed 03-04-2010 11:48

Re: Load config file?
 
hmm 3 lines

hleV 03-04-2010 12:17

Re: Load config file?
 
Here's something similar to what you need. You could also provide us with more info, like how often will you load the text and if the text in file can somehow be changed during the game. Your file with text should be located in amxmodx/configs/text.ini by default.
PHP Code:

#include <amxmodx>
#include <amxmisc>
 
new g_szFile[64];
 
public 
plugin_init()
{
        
get_configsdir(g_szFile63);
        
add(g_szFile63"/text.ini"); // Change "text" to whatever your file name is
}
 
public 
fnLoadText() // This is the function you'll use when you want to load the text from your file
{
        new 
pFile fopen(g_szFile"r");
 
        if (!
pFile)
                return;
 
        new 
szText[256]; // Not sure what max length should I use
 
        
while (!feof(pFile))
        {
                
fgets(pFileszText255);
                
trim(szText);
 
                if (!
strlen(szText))
                        continue;
 
                switch (
szText[0])
                {
                        case 
'/':
                                if (
szText[1] == '/')
                                        continue;
                        case 
';':
                                continue;
                }
 
                
client_print(0print_chatszText);
        }
 
        
fclose(pFile);



fixed 03-04-2010 12:55

Re: Load config file?
 
THANKS man but when I type too mush it makes a new line but it isnt in color? Do u know how to fix that?

Exolent[jNr] 03-04-2010 15:09

Re: Load config file?
 
It uses client_print( ), which defaults to the yellow color and cannot change colors.

fixed 03-04-2010 15:20

Re: Load config file?
 
I know but I changed it to colorchat


All times are GMT -4. The time now is 08:43.

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