Quote:
changed to use only fakemeta.
|
That's not an optimization... Look, because of that now, instead of DispatchKeyValue (one native), you call SetKeyValue (5 natives!). Guess what is the most efficient ? Of course here, it would be called one time, but it won't always the case. You should use intelligently the existing natives/forwards whatever the modules. Remember calling a native cost cpu, that's why there is no reason to use the fakemeta version here.
- You create the entity info_map_parameters, but you forget the situation where the map has already such entity. Since you create in precache time, the entity of the map is not created yet, that's why you need to hook FM_Spawn after creating your entity to block its spawn (the entity integrated to the map). Again, there is snippet about that.
- You call 2 times cs_get_user_team( id ). You should cache the value and you should understand checking 2 times the team is quite pointless. Use simply a switch.
- Oh inside the switch, instead of writting 1 and 2, some defines exist for that, CS_TEAM_CT and CS_TEAM_T, just use them.
- When you do checks, you should make testing first the variables. Like gNewR should be check before get_pcvar_num. You filter better to avoid to check natives.
- You should avoid to make multiple if() when you could do if( condition1 && condition2 && etc.. ). The compiler is idiot and won't optimize. By doing that you will generate less code.
- Your motd is static, therefore it would be appropriate to generate it one time.
- In the player's spawn, is a task really need ? 0.2 is fairly unnoticeable and I'm not how it would be useful.
- I see you use a var to pass the player's id, but as tip, you can pass directly the player's id as the task id. And it will avoid each you use id[0] (where here that's something you should cache from the start hehe)
- A word about readability : please avoid to glue all together. It won't hurt to make some white-spaces. People who will read your code will be happy. For example logevent_round_start, you can make make a new line after the var, cvar, colorchat.
- Just for your information. I see most of time your explicit the return of a function (PLUGIN_CONTINUE, etc..). When no specific value has to be returned, the value by default is anyway the PLUGIN_CONTINUE, or FMRES_IGNORED, etc.., therefore you don't need to explicit the return. It's fine if you do too and it won't matter if you want to keep it, but personally I see no point to explicit, it eats one line for nothing.
__________________