 |
|
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
|

10-08-2021
, 13:37
Re: [Request] Block Usp Damage
|
#7
|
I feel like I'm talking to a wall, but I'll say it again, ignore the fact that you wrote everything in one line and used && to glue everything together. This isn't about that. If you do not see the difference between calling a native 4 times for literally no benefit vs only doing it once then I don't know what to tell you.
Doing #define ent create_entity("") and new ent = create_entity("") are 2 completely different things.
The first one does a textual replacement, changing "ent" in every place inside the code with create_entity(""). If you wanted to create an entity, give it a model, make it solid, it wouldn't work. At every line where you wanted to set those properties, you would be creating a DIFFERENT entity, instead of only one entity with all the needed properties. Your code would end up with multiple ents where each ent has only one of the properties you were trying to set.
The second code allocates memory on the stack for 4 bytes of memory. create_entity() return value is placed at that memory location. From now on, inside that function, when you use "ent" you refer to that one entity that was created, which will be the same entity.
And static is wrong, it should be new. precache is called only once, you don't need to remember the value between function calls, therefore you do not need a global like variable with local scope.
__________________
Last edited by HamletEagle; 10-08-2021 at 13:49.
|
|
|
|