Raised This Month: $ Target: $400
 0% 

Optymalization code.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoGoGo
Senior Member
Join Date: Apr 2008
Old 12-30-2008 , 07:01   Optymalization code.
Reply With Quote #1

PHP Code:
/* Start menu admin */

public actionTestMenu(idkey)
{
    switch (
key)
    {
        case 
7:
        {
            ++
g_menuOption[id]
            
            
g_menuOption[id] %= ArraySize(g_Testsettings);
            
            
g_menuSettings[id] = ArrayGetCell(g_Testsettingsg_menuOption[id]);
            
            
displayTestMenu(idg_menuPosition[id]);
        }
        case 
8: {
        if(
gr_menu2[id]){
        return 
PLUGIN_HANDLED
        
}
        
displayTestMenu(id, ++g_menuPosition[id])
        }
        case 
9: {
        if(
gr_menu2[id]){
        return 
PLUGIN_HANDLED        
        
}
        
displayTestMenu(id, --g_menuPosition[id])
            }
        default:
        {
        new 
m_player g_menuPlayers[id][g_menuPosition[id] * key
        new 
m_name2[32]
        new 
m_authid[32], m_authid2[32], m_name[32]
            
            
get_user_name(m_playerm_name231)

            if (!
is_user_alive(m_player))
            {
                
client_print(idprint_chat"dead?")
                
displayTestMenu(idg_menuPosition[id])
                return 
PLUGIN_HANDLED
            
}



            
get_user_authid(idm_authid31)
            
get_user_authid(m_playerm_authid231)
            
get_user_name(idm_name31)

            if (!
g_menuOption[id])
            {
            
            
client_cmd(id,"slot10"
            
m_plejer m_player 
            
            
if(!is_user_alive(m_plejer ))
            return 
PLUGIN_HANDLED    
            
            
//do something?
            /*---------*/
            
return PLUGIN_HANDLED            
            
            
            
}

            
displayTestMenu(idg_menuPosition[id])
        }
    }
    
    return 
PLUGIN_HANDLED
}

displayTestMenu(idpos)
{
    if (
pos 0)
        return

    
get_players(g_menuPlayers[id], g_menuPlayersNum[id])

    new 
menuBody[1024]
    new 
0
    
new i
    
new name[32], team[4]
    new 
start pos 7

    
if (start >= g_menuPlayersNum[id])
        
start pos g_menuPosition[id] = 0

    
new len format(menuBody1023,  "\yTest Admin Menu %d/%d\w^n^n"pos 1, (g_menuPlayersNum[id] / + ((g_menuPlayersNum[id] % 7))))
    new 
end start 7
    
new keys MENU_KEY_0|MENU_KEY_8

    
if (end g_menuPlayersNum[id])
        
end g_menuPlayersNum[id]

    for (new 
startend; ++a)
    {
        
g_menuPlayers[id][a]
        
get_user_name(iname31)
        
        
/*if (g_cstrike)
        {
            if (cs_get_user_team(i) == CS_TEAM_T)
            {
                copy(team, 3, "TE")
            }
            else if (cs_get_user_team(i) == CS_TEAM_CT)
            {
                copy(team, 3, "CT")
            } else {
                get_user_team(i, team, 3)
            }
        } else {
            get_user_team(i, team, 3)
        }*/

        
if (is_user_alive(i))
        {
            
            
keys |= (1<<b)
                
            if (
is_user_admin(i))
                
len += format(menuBody[len], 1023-len"\r%d. \w%s \r* \w   ^n", ++bname)
            else
                
len += format(menuBody[len], 1023-len"\r%d. \w%s   ^n", ++bname)
        }else if(!
is_user_alive(i)){

            
            if (
is_user_admin(i))
                
len += format(menuBody[len], 1023-len"\d%d. %s \r* \w   ^n\w", ++bname)
            else
                
len += format(menuBody[len], 1023-len"\d%d. %s    ^n\w", ++bname)
        }
    }
    


    if (
end != g_menuPlayersNum[id])
    {
        
format(menuBody[len], 1023-len"^n9. %L...^n0. %L"id"MORE"idpos "BACK" "EXIT")
        
keys |= MENU_KEY_9
    
}
    else
        
format(menuBody[len], 1023-len"^n0. %L"idpos "BACK" "EXIT")
        
        
    
//menu_setprop(menuBody[len], MPROP_PERPAGE, 7);

    
show_menu(idkeysmenuBody, -1"Admin Menu")
}

public 
cmdTestMenu(idlevelcid)
{
    
//if (!cmd_access(id, level, cid, 1))
        //return PLUGIN_HANDLED

    
g_menuOption[id] = 0

        
// should never happen, but failsafe
    
g_menuSettings[id] = 0
    
//menu_setprop(displayTestMenu, MPROP_PERPAGE, 7);
    
displayTestMenu(idg_menuPosition[id] = 0)

    return 
PLUGIN_HANDLED

Hi,

I have problem, I made code like this but is strange/dirty/unoptymized code can somebody help me to change it? I got this code from some plugin try to do something but you can see it is not good code.
__________________
Aaaaaa!
GoGoGo is offline
Coksnuss
Junior Member
Join Date: Feb 2007
Old 12-30-2008 , 11:56   Re: Optymalization code.
Reply With Quote #2

Maybe you should check out this:
http://forums.alliedmods.net/showthread.php?t=6481
Coksnuss is offline
GoGoGo
Senior Member
Join Date: Apr 2008
Old 01-01-2009 , 14:14   Re: Optymalization code.
Reply With Quote #3

Thakns, but not names are bad but whole code

(I will give you +k )
__________________
Aaaaaa!
GoGoGo is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode