An attempt to "refactor" VC:MP Blank Server


  • Newbie
  • Posts: 8
An attempt to "refactor" VC:MP Blank Server
«  »Last edited

I just found VC:MP 0.4 Blank Server and decided to take a look at how to setup a VC:MP server. But while it's good enough for running locally and see if everything runs fine, I felt annoyed with some parts when I was trying to get started. Some of my thoughts:

  • All functions are listed, but there's no description of what they do or what type you expect the arguments to be;
  • I don't like Allman style indentation;
  • I don't like spaces between function arguments either;
  • Some functions are quite hard to understand. SendDataToClient(), for example, may look almost like "magic code" for beginners because of it's indentation issues and excessive use of one-liners;

I also feel that reading documentation in portuguese instead of english would be more comfortable for me, so I decided to look through all the code and try to document, comment and explain the best I could with this language in mind.

And here's my result:
Download Link (reupload)

Here are some of my changes:
  • All functions have documentation written above them. That includes @event tags (to tell what is an event and what isn't),  descriptions (some are vague, some are detailed) and a list of arguments (including it's types);
  • Code has been reindented to Ratliff/K&R style;
  • No more spaces between brackets;
  • I did my best to try understand how some of functions work and decided to comment everything;
  • Portuguese documentation is available in Markdown and HTML on "docs" folder;
  • /pos command added, because why not? It can be used initially to take some positions and play around with XML, learning how to spawn cars, objects, teleport functions, etc;
  • 80 columns per line;

There were at least 3 things I wanted to do, but didn't:
  • Change return 1 to return true;
  • Clean up argument types (some are IDs, some are instances... is hard to describe exactly unless when you try to use the function and find by yourself; not even the Wiki itself explains that very well);
  • Move all color codes to a property list. Color.Yellow seems way easier to understand than "[#FFFF81]";

Everything is written in portuguese, but I encourage anyone else to do the same in english as well. I know there's nothing special about adding a bunch of vague descriptions on top of functions, but it does help, specially for actual working code like SendDataToClient() and SendDataToServer(). When they're commented that way, people can see what everything does straight away. Some functions may also be confusing to differentiate, like onGameResize() and GUI::gameResize().

Some of my thoughs on Blank Server are mostly opinion-based. This is also  basically the same code, just commented out (and in another language).

Even though you don't understand portuguese, please give a look. I hope you like my try on "refactoring" Blank Server's code (more like "rewriting everything specifically for me to understand", but yeah...).

Blank Server is great for what's intended to be: a quick and easy way to test and start a server. It's just a little messy, but good enough to get you started. So thanks to Sebastian for providing it.


  • Hero Member
  • sin^2(x)+cos^2(x) = 1
  • Posts: 890
Infected City Survival Main Dev


  • Wiki Contributor
  • LBR | Co-Leader & Brasil Real RPG | Developer
  • Posts: 469
Code: [Select]
if( !sucess ) tryAgain();


  • VC:MP Beta Tester
  • Something like this: hga hga hga
  • Posts: 1,046
Re: An attempt to "refactor" VC:MP Blank Server
« Reply #3,  »
That's one great thing you have done here.

I used to know what every event is for, so never thought of explaining them.
Seems like newer players didn't need them either, even if they do haha. It is a good add-on.


  • Newbie
  • My name Is markus Persson
  • Posts: 16
Re: An attempt to "refactor" VC:MP Blank Server
« Reply #4,  »Last edited

The link does not work, it takes you to the page, but the file you want to download has been deleted


  • Newbie
  • Posts: 23


  • Newbie
  • Posts: 8