Quote:
Originally Posted by Begineer Programmer
PHP Code:
get_map_maxrounds(szMapname[]) { new szConfigsDir[64], szFilePath[128] get_configsdir(szConfigsDir, charsmax(szConfigsDir)) format(szFilePath, charsmax(szFilePath), "%s/maps/%s.cfg",szConfigsDir, szMapname) new f = fopen(szFilePath, "rt") if( f ) { new szCvar[32], szValue[32], szCfgData[64],iValue; while(fgets(f, szCfgData, charsmax(szCfgData))) { parse(szCfgData, szCvar, charsmax(szCvar), szValue, charsmax(szValue));
if(equali(szCvar, "mp_maxrounds")) { iValue = str_to_num(szValue) return iValue; } } fclose(f) } }
check this one ?
|
An important part of learning to code is to learn how to test and debug your own plugins. There very least that you could do is to test your code on your server to see if it works. It can be done really quickly and will tell you if the basics is working.
Regarding the code, it looks mostly correct. However, I would move the return to the end of the function so that it takes into account for cases where it's defined multiple times.
EDIT: You also can't return before fclose() because it will cause issues if you don't properly close the file (as pointed out by +ARUKARI-).
__________________