Custom Banning Function

I’m new to coding Lua, and I need to figure out how to make a custom ban function that plays a sound. If there are any tutorials you know of, please link them below

Here’s something I give out, it’s TTT End round music. https://dl.dropboxusercontent.com/u/26074909/ttt_end_round.rar

That’ll give you an idea of how to use the net library to network a message to all clients in order to play a sound ( this is needed for the ban function as you’ll need to do the ban and net.Broadcast letting everyone know a user was banned, and in that net.Receive you can play the function, much like the code provided ) Remember, it’s to be used as a guide, there is some TTT specific code ( the hook, the wintype, and the enums used ) which you can get rid of. It shows you how to resource.AddSound / precache the sounds you will use, which is helpful so the users download them.

As for creating a custom function it’s as easy as:
[lua]function FunctionName( argumentsCommaDelimited )
// logic
end[/lua]

Here are some resources which may help you:

The Lua manual, this will definitely help you get started!

The New Garry’s Mod Wiki, has a ton of information, how to use the function calls, how to integrate vgui elements, and more!

Not everything is on the new Garry’s Mod Wiki yet, if it’s not there, it’s here. There is a lot of things that has changed since Garry’s Mod 12, to Garry’s Mod 13. This is primarily for 12.
http://maurits.tv/data/garrysmod/wik...index4875.html

A place to hire coders:
http://www.coderhire.com

One of the best places to start, if by modifying TTT. Start by changing the sweps, more realistic fire-rates, balance the damage, add a feature which changes the cone based on if you’re moving, firing from the hip, aiming down the sights, crouching, holding the walk button, etc etc. Start small, start by doing simple things and work your way up!

Might want to change the IF to IS in the last paragraph.

Why not just modify the ulx ban function?

Here’s an interesting way to do it if you want to make it global for any admin mod:

[lua]local PLAYER = PLAYER or FindMetaTable( “Player” )

PLAYER.oldBan = PLAYER.oldBan or PLAYER.Ban

function PLAYER:Ban( … )

self:oldBan( ... ) -- ban them first in case your sound function fucks up
-- play your sound and junk

end[/lua]