View Single Post
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-05-2019 , 12:50   Re: No lag nightvision
Reply With Quote #20

Quote:
Originally Posted by DJEarthQuake View Post
[I]Use 8 instead of MSG_ONE_UNRELIABLE.
Use 1 instead of MSG_ONE.
No, this is terrible advice. No one will be able to understand what your code does, not even you. You'll say you understand, but if you come back after 2 weeks and look at your source you will not remember what the heck all these numbers mean.

Look:
PHP Code:
message_begin(596, ..) 
If I look at that I have no idea what it does. I need to check the constants and see what 5 is, what 96 is.

On the other hand:
PHP Code:
message_begin(MSG_ONEget_user_msgid("DeathMsg"), ..) 
I understand instantly that the purpose is to send DeathMsg to one player on the reliable channel.

Quote:
The include file already has it typed out.
It has it typed out for you to use it, not hardcode everything and write terrible code.

Quote:
The replacement makes a smaller file size. That uses less CPU. Every little drop of knowledge is essential for your laggin' war bro.
Except you are giving him bad "knowledge". It will not make the file smaller, and even if it did, what in the world file size has to do with CPU usage?
It will use more memory on the hard to store the file, but not more CPU. Think about it this way:
-you have a string made of letter "a" and you do nothing with it. plugin_init is empty.
-you have a string made of one million "a" and you do nothing with it. Will that consume more cpu? Absolutely not. Is the file bigger? Of course.
file size does not translate in any way to CPU usage.

Quote:
Numbers are easier. I use 0,23 all the time for broadcasting temp ents.
How? With pure numbers you have no idea what's going on.

Look at setting offsets: set_pdata_int(id, 116, 1). Can you tell me without googling anything, what this does? You can't.
But if I give you set_pdata_int(id, m_iTeam, _:CS_TEAM_T)? Of course, it sets the team of the player to 1.

Also, what are you going to do if the constant changes? Are you going to update EVERY SINGLE PLUGIN and change the value? That's just asking for unmaintanable code.

Quote:
Such perspective is reminiscent of spaces vs tabs didactic.
No, it's about writing good code that that doesn't break at the slightest change and that can be updated and understood by other people.
__________________

Last edited by HamletEagle; 05-05-2019 at 12:51.
HamletEagle is offline