In my efforts to actually learn some code, I am trying to start taking the hard coding off my ported plugins to make them compatible. This is all new to me but I am trying to apply logic and need help.
I need to remove hard coded paths (in this example from my latest port, Jedi Theme Punish).
Example:
if(file_exists("addons/amxx/custom/ejl_hud_colors.ini") == 1){
while((line=read_file("addons/amxx/custom/ejl_hud_colors.ini",line,data,100,stxtsize))! =0){
I looked thru other plugins that I know use other files and think I have a clue, but want confirmation.
I see in the Swear Filter Plugin this:
new szWord[MAX_WORD_LENGTH]
format( g_szBadWordFile, 63, "%s/swear/swearwords.ini", g_szCustomDir )
format( g_szGoodWordFile, 63, "%s/swear/goodwords.ini", g_szCustomDir )
get_customdir( g_szCustomDir, 31 )
get_configsdir( g_szConfigDir, 31 )
server_cmd( "exec %s/swear/swear_config.cfg;", g_szCustomDir )
server_cmd("exec %s/mysql.cfg;", g_szConfigDir )
And at the beginning of his code:
// Path to AMXX Custom & Config Directories
new g_szCustomDir[32]
new g_szConfigDir[32]
Looking at these examples I believe I see him establishing the non hard coded paths using the above listed commands. One pointing to the configs folder and the other to the custom folder. I need the custom paths version so I think this should be my code:
new g_szCustomDir[32]
if(file_exists("%s/ejl_hud_colors.ini;", g_szCustomDir ) == 1){
while((line=read_file("%s/ejl_hud_colors.ini",line,data,100,stxtsize))! =0){
Well, here is where logic fails and coding knowledge is needed... the first line "appears" right to me as it was a simple copy his example. The second line has additional commands which make it hard for a non-coder to understand where the "g_szCustomDir" would go without breaking the line.
Am I on the right track on either line, what would I need to fix the second part of it ?
Vic/DT
__________________
|