I’ve already told a few people on Steam about it, but now it’s official. I’ve picked up the SourceScript project again. For those who are not yet familiar with it, here’s a summary:
Most of you already know about the integration of Lua in the Half-Life 2 mod Garry’s Mod. What if you could use Lua to mod for other Source games instead of having to learn complicated languages like C++? SourceScript provides a server plugin to take care of just that. It’s aiming to enable Lua in all EP1 and Orange Box based games currently in the Steam Store.
The last time I talked about SourceScript I mentioned really simple hooks and a non-streamlined integration in the Source Dedicated Server. To start off, I’ve completely rewritten the whole thing, since I have a lot more experience with C++ now. Back then, I didn’t even know what the difference between a const char* and char* is. This will ensure a faster and more stable development process.
I’ve decided to first write all the event hooking code, perfect it and then work on the functions with which you respond to said events. It’s still all very rough, by which I mean it’s almost a perfect port of the C++ events, but here’s the implemented hooks:
RoundStart( TimeLimit, FragLimit, Objective )
RoundFreezeEnd()
RoundEnd( Winner, Reason, Message )
PlayerConnect( Nick, IPAddress )
PlayerDisconnect( Nick, UserID, SteamID, IPAddress )
PlayerInitialSpawn( UserID )
PlayerSpawn( UserID )
PlayerDeath( UserID, Attacker )
PlayerDamage( UserID, Attacker, Health, Armor, DmgHealth, DmgArmor, Hitgroup )
PlayerChangedTeam( UserID, Team, OldTeam, Disconnected )
PlayerPickedUpItem( UserID, Item )
PlayerFootstep( UserID )
PlayerJump( UserID ) <- Yes, GMod doesn’t have this!
PlayerShootWeapon( UserID, Weapon )
PlayerWeaponHit( UserID, x, y, z )
PlayerWeaponReload( UserID )
PlayerWeaponZoom( UserID )
PlayerBombPickup( UserID )
PlayerBombDropped( UserID )
PlayerBombBeginPlant( UserID, Site )
PlayerBombPlanted( UserID, Site, x, y )
PlayerBombBeginDefuse( UserID, HasKit )
PlayerBombDefused( UserID, Site )
ConVarChange( name, value )
As you can see, clearly the arguments of some hooks don’t make any sense, like PlayerBombBeginDefuse (What the fuck is up with that name) having a HasKit argument and PlayerBombDefused not. The only actually hooked Source Engine function so far is Msg, which is pretty useless since it does the same as print. When I’ve polished the hooks, I’m first doing global stuff like a server library with GetMap() and all that jazz, and then the entity commands like SetPos()/Ignite(). Polishing the hooks includes using a Vector object instead of X, Y and Z parameters.
Now that we’ve had the wall of text, let’s look at some more exciting (?) stuff. To start off, lua_run, just like in Garry’s Mod:
Also notice ‘Running script hooktest.lua’ at the top which is called from autoexec.cfg as:
lua_openscript hooktest.lua
Here’s a more interesting example:
Yes, it is a little lame, just showing the UserID, but it demonstrates how well the hook and lua_run system already work!
I’d love to hear any argument suggestions for the hooks I’ve shown here, however I’ll probably steal the arguments from Garry’s Mod where appropriate. I hope you guys are just as enthusiastic as I am, looking forward to the outcome of this thing. It might just become a great success and introduce a lot of new people to the great world of Source modding.





