Raised This Month: $ Target: $400
 0% 

Solved Better way to optimized this code?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 06-20-2017 , 01:06   Better way to optimized this code?
Reply With Quote #1

I am trying to make Glock's based weapon don't have the same ammo with MP5 Navy.
I used CurWeapon. it work well but I think i bad for server and I want to find another way
Can I anyone help me?

PHP Code:
public plugin_init()
{
    
register_event("CurWeapon""Event_CurWeapon""be""1=1")

    
RegisterHam(Ham_Weapon_Reloadweapon_infinity"fw_Weapon_Reload_Post"1)
}

public 
Event_CurWeapon(id)
{
    if(!
is_alive(id))
        return
       
    static 
CSWCSW read_data(2)
 
    if((
CSW == CSW_INFINITY && g_OldWeapon[id] != CSW_INFINITY) && Get_BitVar(g_Had_Infinityid))
    {
        
g_PreAmmo[id] = cs_get_user_bpammo(idCSW_INFINITY)
        
cs_set_user_bpammo(idCSW_INFINITYg_InfinityBPAmmo[id])
    } else if((
CSW == CSW_INFINITY && g_OldWeapon[id] == CSW_INFINITY) && Get_BitVar(g_Had_Infinityid)) {
        
cs_set_user_bpammo(idCSW_INFINITYg_InfinityBPAmmo[id])
    } else if((
CSW != CSW_INFINITY && g_OldWeapon[id] == CSW_INFINITY) && Get_BitVar(g_Had_Infinityid)) {
        
g_InfinityBPAmmo[id] = cs_get_user_bpammo(idCSW_INFINITY)
        
cs_set_user_bpammo(idCSW_INFINITYg_PreAmmo[id])
    }
   
    
g_OldWeapon[id] = CSW
}

public 
fw_Weapon_Reload_Post(ent)
{
    static 
idid pev(entpev_owner)
    if(!
is_user_alive(id))
        return 
HAM_IGNORED
    
if(!Get_BitVar(g_Had_Infinityid))
        return 
HAM_IGNORED    
    
    
if((get_pdata_int(ent544) == 1))
    { 
// Reload
        
if(g_Clip[id] == -1)
            return 
HAM_IGNORED
        
        set_pdata_int
(ent51g_Clip[id], 4)
        
Set_WeaponAnim(idANIME_RELOAD)
        
        
Set_PlayerNextAttack(idTIME_RELOAD)
        
g_InfinityBPAmmo[id] -= (CLIP g_Clip[id])
    }
    
    return 
HAM_HANDLED


Last edited by Celena Luna; 06-21-2017 at 10:29. Reason: Solved
Celena Luna is offline
 


Thread Tools
Display Modes

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 23:08.


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