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

Solved Help Me Optimize?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellmonja
Senior Member
Join Date: Oct 2015
Old 03-03-2017 , 22:33   Help Me Optimize?
Reply With Quote #1

Hi everyone. This has been a project of mine for more than a year now and I humbly seek help optimizing it. It adds an extra weapon in CS 1.6, no surprise there. But I wanted it to behave like a real CS weapon in every way. Now that it's working smoothly in-game I wanted to get it as optimized as possible, something I'm not good at. It's a mish-mash of code I've found around the net so that's why its pretty non-efficient so I hope you could help me.

Please bear with me. I'm not a very good coder and I might ask you to explain things further. For that I apologize in advance.

I think the first order of business is getting rid of fakemeta_util. I know, f*ck me, right? But there's a ton of code relying on that module and I have no idea what to replace some if them with...
Attached Files
File Type: sma Get Plugin or Get Source (csgo_bizon.sma - 465 views - 24.3 KB)
__________________

Last edited by hellmonja; 06-25-2017 at 04:12. Reason: Solved...
hellmonja is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-04-2017 , 04:07   Re: Help Me Optimize?
Reply With Quote #2

Moving on from fakemeta_util is like the best and easiest choice.

Code:
FM_UTIL                      |   FUN          |     ENGINE             |      FAKEMETA                                          |    HAMSANWICH                                   |                |                        |                                                        |    fm_give_item                 |   give_item    |     \                  |      \                                                 |    ExecuteHam(Ham_Item_AddToPlayer..) fm_get_user_weapon_entity    |   \            |      \                 |       \                                                 |    get_pdata_cbase [OFFSET: m_pActiveItem]  fm_find_ent_by_owner         |    \           |     find_ent_by_owner  |      engfunc(EngFunc_FindEntityByString..) + pev_owner |     \

There's obviously a way to convert give_item to engine and Fakemeta but it's harder.
__________________

Last edited by edon1337; 03-04-2017 at 10:55. Reason: fixed
edon1337 is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 03-04-2017 , 05:08   Re: Help Me Optimize?
Reply With Quote #3

Did I do it right?

From:
PHP Code:
static weaponweapon fm_find_ent_by_owner(-1weapon_bizonentity
To:
PHP Code:
static weapon;
new 
entstrtypeclassname;
weapon engfunc(EngFunc_FindEntityByStringentstrtypeclassname
From:
PHP Code:
static entent fm_get_user_weapon_entity(idCSW_BIZON
To:
PHP Code:
const m_pActiveItem 373;
...
static 
ent;
ent get_pdata_cbase(idm_pActiveItem); 
give_item is pretty easy so I didn't include it...
__________________
hellmonja is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-04-2017 , 05:16   Re: Help Me Optimize?
Reply With Quote #4

Quote:
Originally Posted by hellmonja View Post
PHP Code:
static weaponweapon fm_find_ent_by_owner(-1weapon_bizonentity
To:
PHP Code:
static weapon;
new 
entstrtypeclassname;
weapon engfunc(EngFunc_FindEntityByStringentstrtypeclassname
From:
I'd suggest engine but anyways.
Code:
engfunc(EngFunc_FindEntityByString, entity, "classname", weapon_bizon)
__________________

Last edited by edon1337; 03-04-2017 at 05:16.
edon1337 is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 03-04-2017 , 05:31   Re: Help Me Optimize?
Reply With Quote #5

Thanks. So that's why it can't change the world model. Would engine be a lot better? Someone told me the fewer modules I use the better.

Hmm, when I switch weapons thirdperson, the Bizon player model doesn't go away. Like if I switch to my knife my player holds both knife and bizon. Same goes with pistols etc...
__________________
hellmonja is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-04-2017 , 05:34   Re: Help Me Optimize?
Reply With Quote #6

Quote:
Originally Posted by hellmonja View Post
Thanks. So that's why it can't change the world model. Would engine be a lot better? Someone told me the fewer modules I use the better.
No difference in performance, you tell me, would you rather type
PHP Code:
engfunc(EngFunc_FindEntityByStringentity"classname"weapon_bizon
instead of just
PHP Code:
find_ent_by_class 
Quote:
Originally Posted by hellmonja View Post
Hmm, when I switch weapons thirdperson, the Bizon player model doesn't go away. Like if I switch to my knife my player holds both knife and bizon. Same goes with pistols etc...
It's because m_pActiveItem checks only the weapon you're using. Try with find_ent_by_owner.
__________________

Last edited by edon1337; 03-04-2017 at 05:34.
edon1337 is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 03-04-2017 , 06:34   Re: Help Me Optimize?
Reply With Quote #7

Hey it works! Player model is now in order. So I guess I'll be using engine as well.

Will come back after dinner. There's still a couple of codes that needs replacing in order for me to get rid of fakemeta_util. All of them with prefix "xs_"...
__________________
hellmonja is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-04-2017 , 06:34   Re: Help Me Optimize?
Reply With Quote #8

Quote:
Originally Posted by hellmonja View Post
Hey it works! Player model is now in order. So I guess I'll be using engine as well.

Will come back after dinner. There's still a couple of codes that needs replacing in order for me to get rid of fakemeta_util. All of them with prefix "xs_"...
xs_ natives are from xs module not fakemeta_util.
__________________
edon1337 is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 03-04-2017 , 07:10   Re: Help Me Optimize?
Reply With Quote #9

Quote:
Originally Posted by edon1337 View Post
xs_ natives are from xs module not fakemeta_util.
Waw. That was stupid of me. Thanks! I removed fakemeta_util and did a quick test and it works fine.

I guess the next stage is the flow of the plugin itself.

Just curious: What's up with fakemeta_util? Why does it have some functions of other modules and why is it avoided like the plague?...
Attached Files
File Type: sma Get Plugin or Get Source (csgo_bizon.sma - 475 views - 24.4 KB)
__________________
hellmonja is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-04-2017 , 07:59   Re: Help Me Optimize?
Reply With Quote #10

Quote:
Originally Posted by hellmonja View Post
Just curious: What's up with fakemeta_util? Why does it have some functions of other modules and why is it avoided like the plague?...
Because it uses the existing natives to do the same thing just in a fakemeta way. So you're basically using 2 natives instead of 1.
__________________
edon1337 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 11:13.


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