View Single Post
OfficialSikari
Junior Member
Join Date: Aug 2017
Location: /dev/null
Old 09-05-2019 , 04:08   Re: [CS:GO] amuJS (better KZTimer Jumpstats)
Reply With Quote #5

Quote:
Originally Posted by hiiamu View Post
Next version(4.0.1) will include the following -
  • Credit to GameChaos
  • CVar to change or disable/enable both adverts, meant to remove those before release...
Could you give me some info on what you mean by leaking the menu handle and how it can be affecting things in negative ways, I would like to improve those. Also could you give some pointers to make my plugin more readable?
Looking better, regarding the leaked menu handles:

PHP Code:
public KeyColorSettingsHandler(Handle menuMenuAction:actionclientselect) {
    if(
action == MenuAction_Select) {
        if(
select == 0)
            
g_iKeyColors[client] = 0;
        if(
select == 1)
            
g_iKeyColors[client] = 8;
        if(
select == 2)
            
g_iKeyColors[client] = 16;
        if(
select == 3)
            
g_iKeyColors[client] = 24;
        if(
select == 4)
            
g_iKeyColors[client] = 32;
        if(
select == 5)
            
g_iKeyColors[client] = 40;
        if(
select == 6)
            
g_iKeyColors[client] = 48;
        if(
select == 7)
            
g_iKeyColors[client] = 56;
        if(
select == 8)
            
g_iKeyColors[client] = 64;
        if(
select == 9)
            
g_iKeyColors[client] = 72;
        if(
select == 10)
            
g_iKeyColors[client] = 80;
        if(
select == 11)
            
g_iKeyColors[client] = 88;
        
KeyColorSettings(client);
        
char sCookie[128];
        
IntToString(g_iKeyColors[client], sCookiesizeof(sCookie));
        
SetClientCookie(clientg_hKeyColorCookiesCookie);
    }
    if(
action == MenuAction_Cancel)
        
SpeedPanelSettings(client);

You're supposed to have a condition for MenuAction_End, and delete the menu handle there, the SourceMod Menu API reference mentions this as well.
Heres an example on how to do that: https://wiki.alliedmods.net/Menu_API...od)#Basic_Menu

P.S. Your if statement madness can be solved by
PHP Code:
g_iKeyColors[client] = (select 8); 
Regarding on how to make the code more readable, this is a highly opinionated thing, but I prefer Allman as an indentation style.
On the other hand, you have mixed new and old syntax. The lack of newlines and consistency makes it hard to read.

Last edited by OfficialSikari; 09-05-2019 at 04:15.
OfficialSikari is offline