Raised This Month: $51 Target: $400
 12% 

[API] CS Reward v6.1 (21 Rewards)


Post New Thread Reply   
 
Thread Tools Display Modes
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-03-2014 , 12:22   Re: [API] CS Core + Reward v5.0 (18 Rewards + 4 Forwards)
Reply With Quote #111

HamletEagle, I got it. ;)

I appreciate your help. I will use this method for other fowards also.
zmd94 is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-03-2014 , 21:51   Re: [API] CS Core + Reward v5.1 (18 Rewards + 4 Forwards)
Reply With Quote #112

New update!
Quote:
v5.1
- [FIXED] Now, all the forwards for the rewards will only being registered when needed. In previous version, all of forwards will be called even if no native need them. ;)
- [FIXED] Improve the code in fw_CmdStart. ;)
Below is the comparison of cs_reward plugin in idle state which mean we do not use any natives from it:

v5.0:

Code:
type |                             name |      calls | time / min / max
-------------------------------------------------------------------
   n |                  register_plugin |          1 | 0.000000 / 0.000000 / 0.000000
   n |                   register_event |          2 | 0.000003 / 0.000001 / 0.000002
   n |                      RegisterHam |         53 | 0.000257 / 0.000001 / 0.000020
   n |                   get_weaponname |         25 | 0.000003 / 0.000000 / 0.000000
   n |                 register_forward |          1 | 0.000001 / 0.000001 / 0.000001
   n |                   get_user_msgid |          3 | 0.000000 / 0.000000 / 0.000000
   n |                 register_message |          1 | 0.000000 / 0.000000 / 0.000000
   n |                 register_library |          1 | 0.000000 / 0.000000 / 0.000000
   n |                  register_native |         18 | 0.000032 / 0.000001 / 0.000003
   n |                   precache_model |          2 | 0.000150 / 0.000069 / 0.000081
   n |                    is_user_alive |       3801 | 0.000410 / 0.000000 / 0.000001
   n |                              pev |       2164 | 0.000813 / 0.000000 / 0.000015
   n |               set_user_rendering |         27 | 0.000007 / 0.000000 / 0.000001
   n |                      remove_task |        432 | 0.000195 / 0.000000 / 0.000002
   n |                         set_task |        146 | 0.000178 / 0.000000 / 0.000048
   n |                      get_players |          2 | 0.000002 / 0.000000 / 0.000001
   n |                        read_data |        699 | 0.000020 / 0.000000 / 0.000000
   p |                client_disconnect |          7 | 0.000001 / 0.000000 / 0.000000
   p |                       event_ammo |        420 | 0.000118 / 0.000000 / 0.000002
   p |                  event_new_round |          2 | 0.000002 / 0.000001 / 0.000001
   p |                      fw_CmdStart |     276378 | 0.034196 / 0.000000 / 0.000246
   p |                      fw_HeadShot |        803 | 0.000371 / 0.000000 / 0.000028
   p |                    fw_PlayerJump |        607 | 0.000232 / 0.000000 / 0.000002
   p |                  fw_PlayerKilled |          6 | 0.000001 / 0.000000 / 0.000000
   p |                 fw_PlayerRespawn |         28 | 0.000008 / 0.000000 / 0.000001
   p |                 fw_ResetMaxSpeed |        270 | 0.000063 / 0.000000 / 0.000011
   p |            fw_WeaponPrimary_Post |       1082 | 0.000316 / 0.000000 / 0.000001
   p |             fw_WeaponPrimary_Pre |       1082 | 0.000492 / 0.000000 / 0.000027
   p |               message_cur_weapon |       1527 | 0.000518 / 0.000000 / 0.000002
   p |                      plugin_init |          1 | 0.000013 / 0.000013 / 0.000013
   p |                   plugin_natives |          1 | 0.000002 / 0.000002 / 0.000002
   p |                  plugin_precache |          1 | 0.000000 / 0.000000 / 0.000000
   p |                    refill_bpammo |        146 | 0.000022 / 0.000000 / 0.000001
   f |                        ResetAlls |         48 | 0.000030 / 0.000000 / 0.000002
v5.1:
Code:
type |                             name |      calls | time / min / max
-------------------------------------------------------------------
   n |                  register_plugin |          1 | 0.000000 / 0.000000 / 0.000000
   n |                   register_event |          1 | 0.000001 / 0.000001 / 0.000001
   n |                      RegisterHam |          2 | 0.000003 / 0.000001 / 0.000001
   n |                   get_user_msgid |          2 | 0.000000 / 0.000000 / 0.000000
   n |                 register_library |          1 | 0.000001 / 0.000001 / 0.000001
   n |                  register_native |         18 | 0.000035 / 0.000001 / 0.000003
   n |                   precache_model |          2 | 0.000151 / 0.000070 / 0.000081
   n |                    is_user_alive |         35 | 0.000001 / 0.000000 / 0.000000
   n |                      remove_task |        558 | 0.000243 / 0.000000 / 0.000004
   n |                      get_players |          3 | 0.000007 / 0.000001 / 0.000003
   p |                client_disconnect |          7 | 0.000001 / 0.000000 / 0.000000
   p |                  event_new_round |          3 | 0.000001 / 0.000000 / 0.000001
   p |                  fw_PlayerKilled |          9 | 0.000005 / 0.000000 / 0.000001
   p |                 fw_PlayerRespawn |         35 | 0.000008 / 0.000000 / 0.000001
   p |                      plugin_init |          1 | 0.000000 / 0.000000 / 0.000000
   p |                   plugin_natives |          1 | 0.000002 / 0.000002 / 0.000002
   p |                  plugin_precache |          1 | 0.000001 / 0.000001 / 0.000001
   f |                        ResetAlls |         62 | 0.000041 / 0.000000 / 0.000001
This new update is to prevent wasting of CPU usage. ;)

Last edited by zmd94; 12-03-2014 at 21:54.
zmd94 is offline
deadflush
Member
Join Date: Mar 2013
Old 12-03-2014 , 21:58   Re: [API] CS Core + Reward v5.1 (18 Rewards + 4 Forwards)
Reply With Quote #113

Very nice!
deadflush is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-03-2014 , 22:07   Re: [API] CS Core + Reward v5.1 (18 Rewards + 4 Forwards)
Reply With Quote #114

Just download and use this new version. ;)
zmd94 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-04-2014 , 09:04   Re: [API] CS Core + Reward v5.1 (18 Rewards + 4 Forwards)
Reply With Quote #115

Read my post again, your vars for deciding when to register the forward will be always 0, you missed the part when you do var = RegisterHam and so on Without that, you will register them on every native call and the if check is useless.
__________________

Last edited by HamletEagle; 12-04-2014 at 09:05.
HamletEagle is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-04-2014 , 10:25   Re: [API] CS Core + Reward v5.1 (18 Rewards + 4 Forwards)
Reply With Quote #116

HamletEagle, when I do as you said, it give tag mismatch error.
zmd94 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-04-2014 , 10:57   Re: [API] CS Core + Reward v5.1 (18 Rewards + 4 Forwards)
Reply With Quote #117

Because for Ham you need to use new HamHook: BlaBlaBla
For Fakemeta you don't need special tags. You need to search or to ask, but please don't do something that is completly useless. Also, you can create a simple bool and set it to true when registering the forward, then check it.
__________________
HamletEagle is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-04-2014 , 11:18   Re: [API] CS Core + Reward v5.1 (18 Rewards + 4 Forwards)
Reply With Quote #118

Alright. So, if I'm using bool, is this the correct way:
PHP Code:
new bool:g_iJumpForward

public native_jump_reward(iPluginiParams)
{
    if(!
g_iJumpForward)
    {
        
RegisterHam(Ham_Player_Jump"player""fw_PlayerJump"0)
        
register_forward(FM_CmdStart"fw_CmdStart")
    }
    
    
g_iJumpForward true
    
    
// Other codes.
    

New update!
Quote:
v5.2
- [FIXED] Prevent the forwards for the rewards from being registered everytime when we want to use it.

Last edited by zmd94; 12-04-2014 at 11:54.
zmd94 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-04-2014 , 12:48   Re: [API] CS Core + Reward v5.2 (18 Rewards + 4 Forwards)
Reply With Quote #119

Set the bool to true inside the if check, to avoid setting it too many times. Also, if it's a bool use b instead of i.
__________________
HamletEagle is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 12-04-2014 , 12:54   Re: [API] CS Core + Reward v5.2 (18 Rewards + 4 Forwards)
Reply With Quote #120

Alright. So, the code will be such below:
PHP Code:
new bool:g_bJumpForward

public native_jump_reward(iPluginiParams)
{
    if(!
g_bJumpForward)
    {
        
RegisterHam(Ham_Player_Jump"player""fw_PlayerJump"0)
        
register_forward(FM_CmdStart"fw_CmdStart")
        
        
g_bJumpForward true
    
}
    
    
// Other codes.
    

I appreciate your help. ;)
zmd94 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 07:33.


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