Quote:
Originally Posted by HamletEagle
Yes, missed that part. Well, some suggestions:
Something like:
PHP Code:
new ConfigsDirPath[128]
public plugin_init() { get_configsdir(ConfigsDirPath, charsmax(ConfigsDirPath)) formatex(filename, charsax(filename), "%s/AutoCommandExec.ini", ConfigsDirPath) }
public file_read(id) { new filepointer = fopen(filename, "rt") if(filepointer) { new TempFile[128] new const FileName[] = "/tempfile.ini" formatex(TempFile, charsmax(TempFile), "%s%s", ConfigsDirPath, FileName) //rest of code
Hope you get what I mean.
|
Hi, I just recently noticed this, and I want to recommend it. Don't use a name like 'ConfigsDirPath' for a global variable, as the code grows, you can end confusing a global with local variable.
Hence, just add a g_ prefix to it (global) and the problem is solved. Keep in mind too, when using cvar pointes, for example, 'gp_weaponPrice' (global pointer).
And I think is good to keep the Object Oriented Programming convention, to start identifiers and functions name with lower case level and each consecutively word with Upper case level, as these days OOP is really in right now.
PHP Code:
new g_configsDirPath[128]
public plugin_init()
{
get_configsdir(ConfigsDirPath, charsmax(g_configsDirPath))
formatex(filename, charsax(filename), "%s/AutoCommandExec.ini", g_configsDirPath)
}
public file_read(id)
{
new filepointer = fopen(filename, "rt")
if(filepointer)
{
new TempFile[128]
new const FileName[] = "/tempfile.ini"
formatex(TempFile, charsmax(TempFile), "%s%s", g_configsDirPath, FileName)
//rest of code