[Tutorial] How to make your server/script look clean and good.
#1

How to make your server/script look clean and good.


Introduction

In this thread I will explain how to make your players think "Wow, this looks good!".
We will do this by using variation and repeating techniques in a balanced way.
This will give the player the impression that people put effort in the server and script, which is of course a good thing.

Error, Usage and Succeed messages

About 99% of all commands need error and usage messages.
A command like /pm would need to return a usage message if no player Id/name is entered.
Imagine (maybe this is the case in your script) how it would look if every error message on every command looked different?
It would give a messy impression.

First thing to do is make some callbacks for your error and usage messages, so you are sure they will always be the same.
An example is the one I use in my own script,

pawn Код:
forward nal(playerid);
public nal(playerid)
{
    SCM(playerid, COLOR_GREY, "{FFFFFF}[{6B6B6B}ERROR{FFFFFF}] You do not have permission for this command.");
    return 1;
}

forward error(playerid, message[]);
public error(playerid, message[])
{
    new stringz[256];
    format(stringz, sizeof(stringz), "{FFFFFF}[{6B6B6B}ERROR{FFFFFF}] %s.", message);
    SCM(playerid, COLOR_GREY, stringz);
    return 1;
}

forward usage(playerid, message[]);
public usage(playerid, message[])
{
    new string[128];
    format(string, sizeof(string), "{FFFFFF}[{6B6B6B}USAGE{FFFFFF}] %s", message);
    SCM(playerid, COLOR_GREY, string);
    return 1;
}
The "nal" means Not Allowed, and is used by placing code like this.

Example usage of nal
pawn Код:
CMD:togooc(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 3)
    {
        if(oocon == 1)
        {
            SCMA(COLOR_RED, "OOC Chat has been disabled by an Administrator!");
            oocon = 0;
            return 1;
        }
        else if(oocon == 0)
        {
            SCMA(COLOR_GREEN, "OOC Chat has been enabled by an Administrator!");
            oocon = 1;
            return 1;
        }
        return 1;
    }
    else return nal(playerid);
}
This will send the nal error message to the player

Example of the color embedding in Nal



Color Embedding

Colors are important for giving people an impression of your script/server.
Using a 0000 color will give a dark looking color is usually very hard to read.

Example of the bad way
pawn Код:
0x0000FF
Example of the good way
pawn Код:
0x6969FF
Those colors look fairly the same, but the 6969 color will give a softer and much more readable text.
A good way to select your colors is by using http://www.colorpicker.com


Capitals and English

Your server will look ten times better if you use capital letters, comma's and stuff like that.
With capital letters I do not mean that you have to capitalize every single word as some people do.
I saw this mistake on many servers, including big servers like PRRP.

Example from prrp
pawn Код:
this vehicle dosent even have a helmet system
As you see that looks just stupid.
No capitals, no dots, bad English.
This will make you lose a lot of players as it gives the impression that your English isn't good, and that you don't put time and effort in your script.



I hope this helped a bit,

- Milan

Reply
#2

Not exactly sure why you'd need 3 separate functions to simply return messages. Wouldn't it be simpler if you just did something like;

pawn Код:
#define ERROR_GENERAL 1
#define ERROR_USAGE 2
#define ERROR_PERMISSION 3

public exception(playerid, type, msg[])
{
    switch(type)
    {
        case ERROR_GENERAL: {}
        case ERROR_USAGE: {}
        case ERROR_PERMISSION: {}
    }
    return 1;
}
I do agree with the section about the pastel colors and the grammar, though.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Not exactly sure why you'd need 3 separate functions to simply return messages. Wouldn't it be simpler if you just did something like;

pawn Код:
#define ERROR_GENERAL 1
#define ERROR_USAGE 2
#define ERROR_PERMISSION 3

public exception(playerid, type, msg[])
{
    switch(type)
    {
        case ERROR_GENERAL: {}
        case ERROR_USAGE: {}
        case ERROR_PERMISSION: {}
    }
    return 1;
}
I do agree with the section about the pastel colors and the grammar, though.
The Nal message doesn't need to be written in the script.
Its just return nal(playerid);

the usage goes like usage(playerid, "/pm [Player ID] [Message] ");


That's the only difference, apart from the text between the starting [ and ] Tags.
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
If you have to explain what a function does because the name does not cover it, then your script is not "clean and good" pretty much by definition! Better names would be "CommandDeniedMessage" or "ShowNotAllowedMessage".

"SCMA" - "ShowCarlMyAmmo", "SetCarManualAuto", "SpaceCowboysMayAttack"?

The FIRST rule to making a clean script is a clean, consistent, and informative, naming scheme. Everything else is secondary. What you are talking about is how to save half a second when typing something, which is pretty much the exact opposite of writing clean code!
I was talking about making it look clean for the player, not for the other scripters.
The player won't see if I use nal or NotAllowedMessage anyway, so I think you just understood my topic wrong

Writing clean code can be seen as writing clean code to read, or writing clean code to play.
Clean code to play is where you as player have the feeling and experience that everything is organized and looking good, while a scripter would look at the code and would want to understand every line within a second, without thinking of the definition.

But considering I am the only person that ever worked on my own script, I don't think I need to worry about if SCMA means SendClientMessageToAll, ShowCarlMyAmmo, or whatever because I'v defined it myself.

Get what I mean?
Reply
#5

Quote:

That's fine if you want to write your code like that, but don't defend it as fine because only you see it when you have just tried to use it as an example of good coding practice in a tutorial.

True on that, didn't think of that.
Altough the readers here aren't really in need to know what SCMA means, but you'r right about this part.

I still don't agree about everything you said here, but that's okay.
Reply
#6

What I call a clean script, is a script that EVERYTHING is useful. It isn't just 80k loads of shit. It is 80k loads of wonderful, and every function, or system, that you have in it, works good. This isn't really much of a tutorial if you ask me. (Not to be Rude.)
Reply
#7

I use this for usage/syntax messages:

pawn Код:
stock ShowSyntax(playerid, cmd[], func[], example[]="")
{
    new syntax[144];
    format(syntax, sizeof(syntax), "USAGE: {FFFFFF}%s", cmd);
    SendClientMessage(playerid, COLOR_RED, syntax);
    format(syntax, sizeof(syntax), "FUNCTION: {FFFFFF}%s", func);
    SendClientMessage(playerid, COLOR_ORANGE, syntax);

    if(!isnull(example))
    {
    format(syntax, sizeof(syntax), "EXAMPLE: {FFFFFF}%s", func);
    SendClientMessage(playerid, COLOR_DARKGREEN, syntax);
    }
    return 1;
}
(it could probably be made better with string concatenation or something but I made this about a year ago and it works so yeah)

Consistency is good.

Usage of usage:
pawn Код:
CMD:weapon(playerid, params[])
{
    if(isnull(params)) return ShowSyntax(playerid, "/WEAPON [PART OF WEAPON NAME]", "Give yourself a weapon.", "/weapon minigun or /weapon mini");
    // rest of command
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)