// Todos:
Explain difference between:
...
Explain most common entity use stuff:
- Entity limits:
https://developer.valvesoftware.com/wiki/Entity_limit
For advanced users (code optimizations):
- do not declare variables as static when you pass them in
recurse function (in most cases it is wrong and can cause crash).
SilverShot, I would suggest you to update installation and all subsequent batch scripts with the following syntax of paths:
Code:
@echo off
set "STEAM=D:\dev\SteamCMD"
set "GAME_DIR=D:\server\l4d2"
set "APP_ID=222860"
set "STEAM_USERNAME=anonymous"
set "STEAM_PASSWORD="
md "%GAME_DIR%"
cd /d "%STEAM%"
start "" steamcmd.exe +login "%STEAM_USERNAME%" "%STEAM_PASSWORD%" +force_install_dir "%GAME_DIR%" +app_update %APP_ID% validate
because when you copy code from forum it automatically insert invisible space at the end of each line causing SteamCMD can't connect due to incorrect login name.
I also added some corrections for reliability (like when script and folder is on different disks).
---
Perhaps, it's good to see listing of short solutions for most common errors in logs, like:
Quote:
* Unable to load plugin (no debug string table) - you need to compile plugin with older version of sm, e.g. 1.9 (or better, update SourceMod version of your server).
* Illegal disk size - smx file is corrupted during ftp uploading. Re-upload it again.
* Client X is not connected or Client X is not in game - missing IsClientInGame() check in source code.
|
Code practice:
- Use
AcceptEntityInput(entity, "Kill") instead of
RemoveEdict(entity). It is much safer.
(I saw it in 1st post, but I think, require hightlighting separately).
- Before using or killing entity, ensure it is valid with
IsValidEntity(),
and necessarily check for zero if(entity != 0) or just if(entity),
because 0 (on dedicated server) is a world and valid, so you can crash server instantly.
- use uniform style for naming the variables. Good start is "
Hungarian notation"
e.g. prepend
g_ if variable is declared in global scope.
- Use
TIMER_FLAG_NO_MAPCHANGE to close handle of timer automatically when map is about to end. It prevent from unexpected consequences.
-
!!iValue - to convert "
int" to "
bool" (somewhere was a better solution(?))
For advanced users (code optimizations):
- declare "
char" type of variables as "
static" if your function called several times. This will optimize speed, because variable is not allocated twice.
Mistakes (for advanced):
- if you use Database's transactions ensure you created table as
Transaction-Safe type, like "InnoDB":
https://www.tutorialspoint.com/mysql...ansactions.htm
(perhaps, need to add this notice directly in sm wiki)
Basics:
- floating point operations specific, like:
incorrect:
PHP Code:
float f = 1.5;
int i = 2;
i += f;
PrintToServer("wrong: %i", i); // Answer: 1080033280
correct is to cast float to int first using
rounding:
PHP Code:
float f = 1.5;
int i = 2;
i += RoundToCeil(f); // or RoundToFloor, RoundToZero, RoundFloat, RoundToNearest
PrintToServer("correct: %i", i); // Answer: 4
For basics section (?), I think:
- list all possible abilities to store config externally (ConVars, Cookies, KeyValues, SMCParser, Database, simple file)
More useful links for appropriate sections:
How to load / reload plugins
Entities list:
L4d:
https://developer.valvesoftware.com/..._Dead_entities
L4d2:
https://developer.valvesoftware.com/..._L4D2_Entities
Particles list:
L4d:
https://developer.valvesoftware.com/..._L4D_Particles
L4d2:
https://developer.valvesoftware.com/...L4D2_Particles
Useful commands:
-
sm_dump_netprops_xml prop_netprops.xml - dump network properties in xml format