View Single Post
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-13-2020 , 09:44   Re: Advanced GlowMenu v2.0.0 [12/04/2020]
Reply With Quote #20

1.

Code:
#if AMXX_VERSION_NUM < 190 new szTemp[250]; #endif

You're checking if the version is 1.9 here, but check 1.8.3 everywhere else.
I'd suggest you stick to checking it it's 1.9 because the 1.8.3 build that the end-person is using may not have all the necessary functions (older builds).

2. Line 98:

Code:
iMainMenu = menu_create(fmt("%L", id, "MAIN_MENU_HEADER"), "MainMenuHandler");

Like I said, you don't need to do this in 1.9. The proper usage would be:

Code:
iMainMenu = menu_create("MAIN_MENU_HEADER", "MainMenuHandler", true);

Same goes when you're adding the items:

Code:
menu_additem(iRemoveMenu, fmt("%L", id, szRemoveMenuText[i]));

=>

Code:
menu_additem(iRemoveMenu, szRemoveMenuText[i]);

3. Line 128:

Code:
menu_item_getinfo(iColorMenu, item, iAccess, szRGB, charsmax(szRGB));

This still won't compile under 1.8.2. Here's the function's usage in that version:

Code:
native menu_item_getinfo(menu, item, &access, info[], infolen, name[]="", namelen=0, &callback);

As you can see, the "callback" argument is mandatory, so you need to use it as well.

4.

Code:
public GlowTarget(id) {     new iPlayerMenu;     FormatPlayerMenu(id, iPlayerMenu, "%L", "CHOOSE_PLAYER_GLOW", "GlowPlayerHandler");
    bGlowTarget = true;
}

What happens when multiple players use the menu at the same time? This variable should have a separate value for each player - "bGlowTarget[33]". Same goes for "bGlowAll" and "iGlowTarget".

5. Line 188:

Code:
public GlowTarget(id) {
    new iPlayerMenu;
    FormatPlayerMenu(id, iPlayerMenu, "%L", "CHOOSE_PLAYER_GLOW", "GlowPlayerHandler");     bGlowTarget = true; }

This variable is not used in any way here. Same goes for the "RemoveGlowPlayer" function.
If you want to pass the the value from "FormatPlayerMenu" to "iPlayerMenu", you need to assign the argument as "&iPlayerMenu" in the function's body:

Code:
public FormatPlayerMenu(id, &iPlayerMenu, szHeader[], szData[], szHandler[])

But, you don't need to do this because you're not using the local "iPlayerMenu" variable in any function, so just declare it inside "FormatPlayerMenu"'s code block, not inside its body.

6. Line 313:

Code:
new iFilePointer = fopen("addons/amxmodx/configs/GlowMenu.txt", "rt");

Don't hardcode paths. Use "amx_configsdir" to get the "configs" directory, then add the filename to it.

7.

Code:
aColorInfo = ArrayCreate(250); new szColorData[200]; new szLine[64]; new szRGB[50];

Be consistent. You're using different buffer sizes for the exact same strings here. 250 is overkill.

8.

Code:
log_amx("%s", szLine);

=>

Code:
log_amx(szLine);

Should this even be in the code? Pretty sure you forgot to remove it when testing.

9. Line 341:

Code:
for(new i; i < iNum; i++) {         get_user_name(iPlayers[i], szName, charsmax(szName));         num_to_str(get_user_userid(iPlayers[i]), szUserId, charsmax(szUserId));         menu_additem(iPlayerMenu, szName, szUserId);     }

You should cache "iPlayers[i]" since you're using it more than once:

Code:
iPlayer = iPlayers[i]

10. Line 360:

Code:
for(new i; i < ArraySize(aColorInfo); i++) {

The array size won't ever change, so cache it in a global variable after reading the file.

11. Line 368:

Code:
formatex(szTemp, charsmax(szTemp), "%s", szColor); menu_additem(iColorMenu, szTemp, szColorData);

=>

Code:
menu_additem(iColorMenu, szColor, szColorData);
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom