View Single Post
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 10-04-2015 , 16:31   Re: Automatic Command Executor [1.0]
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
Yes, missed that part. Well, some suggestions:

Something like:
PHP Code:
new ConfigsDirPath[128]

public 
plugin_init()
{
     
get_configsdir(ConfigsDirPathcharsmax(ConfigsDirPath))
     
formatex(filenamecharsax(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(TempFilecharsmax(TempFile), "%s%s"ConfigsDirPathFileName)
               
//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(ConfigsDirPathcharsmax(g_configsDirPath))
     
formatex(filenamecharsax(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(TempFilecharsmax(TempFile), "%s%s"g_configsDirPathFileName)
               
//rest of code 

Last edited by addons_zz; 10-04-2015 at 16:37.
addons_zz is offline