Sound
++ add comment to:
PHP Code:
RequestFrame(OnNextFrame); // some arguments can be optional, even if case is not mentioned in docs
"
SetTransmit" section
Quote:
Originally Posted by Silvers
Hiding particles might not work for all games or might only work on Windows. This is an engine limitation.
|
or not work for specific entity classes (like prop_glowing_object).
Links fixes:
"Entity Properties" section:
(since you already mentioned on "classes" format), here is about "datamaps" log:
Quote:
Originally Posted by Dragokas
"datamaps" log presented in format "property name" ("offset") ("type") ("size") - "KeyValue" (applicable for DispatchKeyValue* functions).
|
(actually, last part was not so obvious, until you have indicated that for me explicitly).
Sound Hooks section:
"
AmbientHook" prototype is wrong. Also code will not compile until you re-tag:
PHP Code:
AddAmbientSoundHook(view_as<AmbientSHook>(AmbientHook));
Actually, I was always surprise about that. Same "fix" is not required for AddNormalSoundHook callback.
Also, your "
SoundHook" prototype mentioned in SM API as deprecated.
PHP Code:
// The following two lines are used to hide the particles
// This might only work for some games or windows servers only.
if( GetEdictFlags(entity) & FL_EDICT_ALWAYS )
SetEdictFlags(entity, GetEdictFlags(entity) ^ FL_EDICT_ALWAYS);
I think better to &~ here, so not need to explain people what XOR mean, moreover, it is not required here.
Also, why is it used in callback and not set once on spawn? I'm not familiar, can particle change flags itself / or by specific update ?
"
Memory" section:
please add next to 1st link a little additional link -
https://2010kohtep.blogspot.com/2017/08/sourcepawn.html - this is official translation into Russian from author.
"
Good Coding Practices:"
Use TIMER_FLAG_NO_MAPCHANGE - make bold, also:
- and unless timer contains important code for resetting flags or cleaning some global things, not applicable in Round Start/End event.
Quote:
Originally Posted by Silvers
Initializing all the variables in an array with the same value: int test[32] = {1, ...};
|
You mean zeroes array? Is it required?
I think it is applicable for old syntax with "decl" keyword only:
Quote:
Originally Posted by psychonic
As a small optimization, you may use "decl" (rather than "new") when creating arrays (including strings and vectors).
This is only safe to do if you are populating the array before accessing it (filling it with values or a string, rather than assuming it will start as 0/blank).
|
Quote:
Originally Posted by Silvers
switch instead of multiple if else statements. This is probably faster too. More info here.
|
add notice that, only constant values are supported.
"
Good Coding Practices:"
add
- (optimiz) No sense in using if IsClientConnected(client) && IsClientInGame(client) together since IsClientInGame is already include IsClientConnected check.
P.S. Ahh, I see you already mentioned similar. Think, better split it into separate sentence (new item).
Debug section additions:
-
LogStackTrace() - useful to view the last chain of function calls.
- Use
ac_debug plugin (attached) to measure performance of each plugin using valve profiler (not working in L4D1/L4D2 at the moment).
For high skilled:
http://pawn-wiki.ru/index.php?/topic...preprocessora/ (Russian), perhaps, need translate and re-publish.
L4D2 start: batch file, after
@echo off, I would suggest:
SetLocal EnableExtensions
if not, rare "bug" can happen,
SET /P is not available when processor extensions set to disabled state. Sometimes meet so.
Speed optimiz:
- strcmp() instead of StrEqual.
- c[0] == 'a' instead of full comparison in specific cases.
- Need to test what version of checking string for zero is more efficient, like strlen(s) == 0 (or !strlen(s) ), s[0] == '\0', s[0] == 0
- Format (v, sizeof v, "%i", i) faster than StringToInt. Need additional test to prove.
- srncmp - I saw than in your code... need to look closely.
- create one timer for all players instead of separate timer for each one (example: hp regen plugins).
- FormatEx instead of Format (only, when input and output buffers are differ)
- todo: show you example of recurse call error of static char, like in my 'Message Filter', func DoReplace() var sPreserve.
Sorry, crash is possible only in even more specific cfg, like combination static char + FormatEx(),
todo: show example on 'Cvar Anomaly Fixer' ProcessConfigA() func, var sPath.
- if(X == true) unnecessary
- if(i != 0) or if(i) - check
- mistake: FakeClientCommand() for calling function from own plugin instead of just directly calling this function. LOL
- todo: what is faster - find method in ArrayList or in StringMap? Or to be correct, isn't ArrayList slower than StringMap.
- Allocate memory size that divides by 4, e.g. char a[4], char a[8], char a[64] ...
https://hlmod.ru/threads/kak-skormit...20/post-440997
- Try not use dynamically allocated arrays, like a[] = new [16][16]; - IIRC, memory is not de-allocated here.
- you have to prefer hooks (like SDKHook OnThink) instead of OnGameFrame().
Common mistakes addition:
- mistake: return Plugin_Handled in OnPlayerRunCmd() - in most cases.
Also, I found people that was scary to use OnPlayerRunCmd() func at all, saing it is even more CPU loading than OnGameFrame() lol. Just insert correct bit check and client check, that's all.
Here is a classical plugin with loooot of errors (keep in private please).
TeamPanel.sp - almost original version (edited with xxx...)
TeamPanel-fix1.sp - first fix by me.
TeamPanel-fix2.sp - last fix by me, though, I removed some versus features.
Fast overview:
- (error) client crash with "Reliable buffer overflow" AFAIK. This is due to overflow of user messages, in our case - from server side (I think, SendPanelToClient()). You can surely notice here about ProcessCmd (well known in Russian segment) or SMAC protection, speaking than these plugins will instantly drop client from server thinking they ddos-ing the chat.
- (error) wrong check order in IsValidPlayer() stock.
- (optimiz) replacing [ by cycle - instead of just inserting space " [" once in menu title to solve (sm?) or game bug with menu not appearing.
- (optimiz) correct: use less CPU loading func - like "bitwise math." BEFORE more CPU cycles consumption function like IsValidPlayer() - in cycles, especially such as OnPlayerRunCmd(), OnGameFrame().
- (optimiz) cache handles instead of retrieving them each time again, like FindConVar().
- checking GetGameFolderName instead of GetEngineVersion().
Additional link for "Various" section: "Translation in menus" -
https://wiki.alliedmods.net/Menu_API...)#Translations
I suggest hightligh (bold or color) these parts:
- install and update a CS:GO
- start a CS:GO
- start an L4D2