Raised This Month: $ Target: $400
 0% 

optimisation


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
GhostMan
Senior Member
Join Date: Jun 2012
Old 05-26-2013 , 06:01   optimisation
Reply With Quote #1

I have a bit modified jb shop plugin. One of the modifications is that when player kills somebody it gives him jb packs and shows message in chat fror what and how many does he got jb packs.

Problem is it looks a little bit messy, how could it be optimised?

HTML Code:
public fw_player_killed(victim, attacker, shouldgib)
{
    if(!is_user_connected(victim) || !is_user_connected(attacker) || attacker == victim || get_playersnum() < 4)
        return HAM_IGNORED

    new bool:killvip[32], bool:killct[32], bool:killviphs[32], bool:killhs[32]

    if(get_user_team(attacker) == 1 && get_user_team(victim) == 2)
    {
        if(get_user_flags(attacker) & ADMIN_LEVEL_H)
        {
            new limit = get_pcvar_num(g_maxjbpacks) * 2
                
            if(g_jbpacks[attacker] < limit)
            {
                g_jbpacks[attacker] += get_pcvar_num(g_killjp) * 2
                killvip[attacker] = true
            }
        }
        else
        {
            new limit = get_pcvar_num(g_maxjbpacks)
                
            if(g_jbpacks[attacker] < limit)
            {
                g_jbpacks[attacker] += get_pcvar_num(g_killjp)
                killct[attacker] = true
            }
        }

        if(get_pdata_int(victim, 75) == HIT_HEAD)
        {
            if(get_user_flags(attacker) & ADMIN_LEVEL_H)
            {
                new limit = get_pcvar_num(g_maxjbpacks) * 2
                
                if(g_jbpacks[attacker] < limit)
                {
                    g_jbpacks[attacker] += get_pcvar_num(g_killhsjp) * 2
                    killviphs[attacker] = true
                }
            }
            else
            {
                new limit = get_pcvar_num(g_maxjbpacks)
                
                if(g_jbpacks[attacker] < limit)
                {
                    g_jbpacks[attacker] += get_pcvar_num(g_killhsjp)
                    killhs[attacker] = true
                }
            }
        }

        if(killviphs[attacker]) {
            client_print_color(attacker, Red, "%L", attacker, "PTS_GIVEHS_VIP", get_pcvar_num(g_killjp) * 2, get_pcvar_num(g_killhsjp) * 2)
            killviphs[attacker] = false
        }
        else if(killhs[attacker]) {
            client_print_color(attacker, Red, "%L", attacker, "PTS_GIVEHS", get_pcvar_num(g_killjp), get_pcvar_num(g_killhsjp))
            killhs[attacker] = false
        }
        else if(!(killviphs[attacker]) && killvip[attacker]) {
            client_print_color(attacker, Red, "%L", attacker, "PTS_GIVE_VIP", get_pcvar_num(g_killjp) * 2)
            killvip[attacker] = false
        }
        else if(!(killhs[attacker]) && killct[attacker]) {
            client_print_color(attacker, Red, "%L", attacker, "PTS_GIVE", get_pcvar_num(g_killjp))
            killct[attacker] = false
        }
    }
    return HAM_IGNORED
}
GhostMan is offline
 



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 16:20.


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