A small explanation on how to listen to game events. This example is made for CS:GO, but will work on other Source based games too (some event names may be different). The example is meant for class based plugins. So if you are creating static functions you'll have to do things a little bit different.
There is no native function for a unix timestamp in milliseconds, only 'time()' which returns seconds since epoch and 'microtime()', which returns microseconds since the current second. Although you can use 'microtime(true)', but it returns a float that can not guarantee precision. Or just 'microtime()' and explode the string.
In this tutorial I'll demonstrate how to send a file in Go over a TCP connection using a server that sends the file and a client that receives it, I'll try to go into detail as much as possible.
You can download the source code here.
Comments and remarks are more than welcome.
Here is a brief explanation for the 'findAndModify()' equivalent for mgo. Instead of 'findAndModify()' we will use 'mgo.Find().Apply()'. I will demonstrate how to use auto incremented ids instead of random unique generated IDs for documents, since mongdb does not have a native way of doing this (because MongoDB is not a relational database).
It work's like this, we create a collection, insert a document in that collection that contains the last generated ID. Every time we call 'findAndModify()', mongoDB will increment the value and we get that new value back, which you should use to insert a new document with.
In Golang there isn't a native function to convert a character number (!= int number) to int.
An int in bytes is the normal sequence of 0-9 normally, but when you are dealing with number characters, they start of at number 48 (in the ASCII table)
So a character 0 is 48 in bytes, 1 is 49, 2 is 50, and so on...
In previous posts I showed how to make a MD5 hash and a SHA1 hash of a file, generating a CRC checksum on a file is however a bit more complicated since it uses a polynomial table. I'll explain everything in depth.