Raised This Month: $32 Target: $400
 8% 

grenade_throw


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-15-2017 , 21:06   Re: grenade_throw
Reply With Quote #21

Quote:
Originally Posted by Kowalsky View Post
It is so amazing that one can do with only one module, there is no need to add any other shitty modules when you can replace for instance cs_get_user_money with one line and set_user_health with one line too. I recommend everyone to use just fakemeta and ham
This shows that you don't know what you are talking about. Just because a module has been around longer doesn't make it "shitty". In fact, it's often the opposite because the modules get optimized over time.

Both cs_get_user_money() and set_user_health() are already one line. Also, the number of lines is completely irrelevant.
__________________
fysiks is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-15-2017 , 23:44   Re: grenade_throw
Reply With Quote #22

Quote:
Originally Posted by Kowalsky View Post
It is so amazing that one can do with only one module, there is no need to add any other shitty modules when you can replace for instance cs_get_user_money with one line and set_user_health with one line too. I recommend everyone to use just fakemeta and ham
If you want to do stupid stuff fine, but don't make recommendations when you have no idea what are you talking about. Provide some reasons at least why you think it's better.
__________________

Last edited by HamletEagle; 10-15-2017 at 23:45.
HamletEagle is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 10-16-2017 , 00:36   Re: grenade_throw
Reply With Quote #23

Lol, you think linking a module is less efficient than using setmodel and other per frame forwards instead?

Sometimes I was using additional modules just not to use prethink instead, and server didn't explode..
siriusmd99 is offline
Kowalsky
Senior Member
Join Date: Mar 2015
Location: Poland
Old 10-16-2017 , 01:37   Re: grenade_throw
Reply With Quote #24

Tell me please which one is better. Let’s say you have a case where you are running only one module - fakemeta and you need to change user’s hp to say 150. Would you add fun to do that? Or simply use set_pev .. pev_health?
__________________
I ONLY LOVE STEAM, NON-STEAM IS VERY BAD FOR YOUR HEALTH!
Kowalsky is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 10-16-2017 , 04:52   Re: grenade_throw
Reply With Quote #25

Quote:
Originally Posted by Kowalsky View Post
Tell me please which one is better. Let’s say you have a case where you are running only one module - fakemeta and you need to change user’s hp to say 150. Would you add fun to do that? Or simply use set_pev .. pev_health?
Changing user's HP also includes sending a user message to notify the client that their HP has changed so they can update the health HUD. That includes several more native calls, so a single native call to fun will do that faster.

While PAWN code does run almost as fast as native x86 because of the JIT, native calls are more expensive than C++ code simply calling a function. Also calling into your plugin requires some setup, so one grenade_throw callback is much better than you hooking pfnSetModel which will be called many times for other entities too to do the same thing.

Loading a module just requires some memory (we are talking few megabytes here at most I believe, most often it's in the order of kilobytes). Most modules will do nothing on their own until you do a native call or request it to do something than call back into your plugin. So yes, it's much better to use a module than reinvent the wheel by coding yourself the same thing that the module does.

Last edited by klippy; 10-16-2017 at 04:54.
klippy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-16-2017 , 15:27   Re: grenade_throw
Reply With Quote #26

Quote:
Originally Posted by Kowalsky View Post
Tell me please which one is better. Let’s say you have a case where you are running only one module - fakemeta and you need to change user’s hp to say 150. Would you add fun to do that? Or simply use set_pev .. pev_health?
Stop being so focused on "only one module". Try to understand what happens in the background. Some ways are simply better than others because they require less code to be executed or this code is executed from a better place.
When the difference is trivial it does not matter if you do it with fun or with fakemeta or whatever module you want, but you have to understand where you are crossing the line.
Going as far as porting all modules to fakemeta is crossing the line.
Going as far as refusing to use another module which can do the job better is crossing the line. Why? You are so focused on "optimizing" by running only one module so you never stop and think "does this conversion makes sense? Is it better or I'm actually implementing it in a worse way?"

For example, if you want to hook touch between 2 specific entities you are better by using engine's register_touch than FM_Touch. Why? Because the classname filtering is done inside the module for engine, while with fakemeta you have to do it manually. Same holds true for register_think vs FM_Think.
Of course the difference is not big, but it defeats your argument that using "only one module is better".

Another example: would you use PreThink/CmdStart to detect IN_ATTACK button because you use only fakemeta or would you include hamsandwich and hook Ham_Weapon_PrimaryAttack? Of course ham is better, as the forward is only fired when IN_ATTACK is pressed, not each frame.

3rd example: let's say you don't want to use fun, so you port give_item to fakemeta(we all know the horrible fakemeta_util include). By porting that function to a plugin you have to make several calls to a module(fakemeta in this case), opposed to only one module call if you used fun.
Also, keep in mind that as long as you don't call give_item fun is idle, so it's like it's unloaded.

4rd example: As Klippy said, if you hook FM_SetModel manually it will be called each time a model is applied to an entity. Hooking grenade_throw which will be called only when a grenade is thrown is better as you save some calls.

It does not matter how many modules you use, what matter is to choose the right module for the right task. Again, stop being so focused on only using one module, try to understand how this modules works and how a certain task is achieved by different modules. Then you can compare and decide what you are going to use and when.

At the end, you do what you want. We don't get anything if you do things properly or in a shitty way.
__________________

Last edited by HamletEagle; 10-16-2017 at 15:33.
HamletEagle is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 10-16-2017 , 16:51   Re: grenade_throw
Reply With Quote #27

You try to save 0.10 % (for example) of performance by not initializing a module, but instead you actually loose much more of performance on native calls.

You could say something like : "But i better use fakemeta functions and save 0.05 % of performance"

And now multiply 0.05 by number of your plugins where you replaced all stuff with fakemeta and see the result.
I don't think that would be a better idea.

*I still wonder about some plugins like molotov cocktail or biohazard mod where there are literally everything replaced with fakemeta,even cs_set_user_team, I saw like a bunch of offsets in those plugins... I'm just curious the reason, maybe somebody knows.

Cheap Suit in his Biohazard plugin limited all functions to ham and fakemeta:

PHP Code:
#define fm_get_user_team(%1) get_pdata_int(%1, OFFSET_TEAM)
#define fm_get_user_deaths(%1) get_pdata_int(%1, OFFSET_DEATH)
#define fm_set_user_deaths(%1,%2) set_pdata_int(%1, OFFSET_DEATH, %2)
#define fm_get_user_money(%1) get_pdata_int(%1, OFFSET_CSMONEY)
#define fm_get_user_armortype(%1) get_pdata_int(%1, OFFSET_ARMOR)
#define fm_set_user_armortype(%1,%2) set_pdata_int(%1, OFFSET_ARMOR, %2)
#define fm_get_weapon_id(%1) get_pdata_int(%1, OFFSET_WEAPONTYPE, EXTRAOFFSET_WEAPONS)
#define fm_get_weapon_ammo(%1) get_pdata_int(%1, OFFSET_CLIPAMMO, EXTRAOFFSET_WEAPONS)
#define fm_set_weapon_ammo(%1,%2) set_pdata_int(%1, OFFSET_CLIPAMMO, %2, EXTRAOFFSET_WEAPONS)
#define fm_reset_user_primary(%1) set_pdata_int(%1, OFFSET_PRIMARYWEAPON, 0)
#define fm_lastprimary(%1) get_pdata_cbase(id, OFFSET_LASTPRIM)
#define fm_lastsecondry(%1) get_pdata_cbase(id, OFFSET_LASTSEC)
#define fm_lastknife(%1) get_pdata_cbase(id, OFFSET_LASTKNI)
#define fm_get_user_model(%1,%2,%3) engfunc(EngFunc_InfoKeyValue, engfunc(EngFunc_GetInfoKeyBuffer, %1), "model", %2, %3) 

Last edited by siriusmd99; 10-16-2017 at 17:00.
siriusmd99 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-17-2017 , 19:46   Re: grenade_throw
Reply With Quote #28

Why waste time creating something that already exists? Do you really believe that add more 1000 lines of code in your plugin will improve tonight from your project, rather than using something that is already ready and that was developed for a specific purpose, thinking of all the requests and functionality of particular stock?
__________________









Last edited by CrazY.; 10-17-2017 at 19:47.
CrazY. is offline
Reply


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


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