View Single Post
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-27-2009 , 08:22   Re: Spawn with Armor
Reply With Quote #23

Quote:
Originally Posted by ConnorMcLeod View Post
Use fakemeta instead of cs_set_user_amor and you have to use 2 natives, 1 to set armor, another one to set armor type, so cstrike native should be 2 times faster or even more.
I don't even consider you need 3 more natives to send a ArmorType message.

-edit-
Seems that i was wrong, when you don't send a message, FM is faster, but you actually need to send the message.
PHP Code:
public profid )
{
    for(new 
ii<10000i++)
    {
        
cs_set_user_armor(id100CS_ARMOR_VESTHELM)
        
fm_set_user_armor(id100.02)
        
fm_cs_set_user_armor(id100.02)
    }
    return 
PLUGIN_HANDLED
}

fm_set_user_armor(idFloat:amounttype)
{
    
set_pev(idpev_armorvalueamount)
    
set_pdata_int(id112type)
}

fm_cs_set_user_armor(idFloat:amounttype)
{
    
set_pev(idpev_armorvalueamount)
    
set_pdata_int(id112type)

    if ( 
type )
    {
        
message_beginMSG_ONE_UNRELIABLE gmsgArmorType id )
        
write_bytetype == )
        
message_end();
    }

Code:
type |                             name |      calls | time / min / max
-------------------------------------------------------------------
   n |                  register_plugin |          1 | 0.000001 / 0.000001 / 0.000001
   n |                   register_clcmd |          1 | 0.000006 / 0.000006 / 0.000006
   n |                   get_user_msgid |          1 | 0.000001 / 0.000001 / 0.000001
   n |                cs_set_user_armor |      10000 | 0.006480 / 0.000001 / 0.000080
   n |                          set_pev |      20000 | 0.003963 / 0.000000 / 0.000001
   n |                    set_pdata_int |      20000 | 0.003909 / 0.000000 / 0.000068
   n |                    message_begin |      10000 | 0.002382 / 0.000000 / 0.000001
   n |                       write_byte |      10000 | 0.002153 / 0.000000 / 0.000000
   n |                      message_end |      10000 | 0.003001 / 0.000000 / 0.000023
   p |                      plugin_init |          1 | 0.000001 / 0.000001 / 0.000001
   p |                             prof |          1 | 0.005654 / 0.005654 / 0.005654
   f |                fm_set_user_armor |      10000 | 0.005802 / 0.000001 / 0.000046
   f |             fm_cs_set_user_armor |      10000 | 0.011227 / 0.000001 / 0.000045
0 natives, 0 public callbacks, 2 function calls were not executed.
Summary
Code:
type |                             name |      calls | time / min / max
-------------------------------------------------------------------
   n |                cs_set_user_armor |      10000 | 0.006480 / 0.000001 / 0.000080
   f |                fm_set_user_armor |      10000 | 0.005802 / 0.000001 / 0.000046
   f |             fm_cs_set_user_armor |      10000 | 0.011227 / 0.000001 / 0.000045
0 natives, 0 public callbacks, 2 function calls were not executed.
There is nothing wrong. You have to add the time taken by the functions called inside fm_set_user_armor. So you have to profile just one of "fm_set..." or "fm_cs_set..." and add the time taken by set_pev and set_pdata_int

Based in your profile results it would be approximately:

fm_set_user_armor + set_pev/2 + set_pdata_int/2 = 0.005802 + 0.003963/2 + 0.003909/2 = 0.005801 + 0.001982 + 0.001954 = 0.009737
__________________

Last edited by joaquimandrade; 04-27-2009 at 08:28.
joaquimandrade is offline