[Spec] Default functions
#1

This is a specification, made so that different scripts can handle things in a common yet simple way.
[Spec] is tag for specifications.

This specification will also available on sa-mp wiki.

General data :
Version : 0.1 Alpha
Status : Unaccepted
Target : Codes that are incorporated (Although it may be expanded)
Current developers : RSX
Current usage : <None>


1. Purpose and history
2. General description
3. Definition
4. Examples and defaults
5. Changes and suggestions

Purpose and history

There isn't much of history yet, but purpose is to define basic handling of common tasks in servers. Such as adding information to log or creating a connection between different parts of code.

General description

All codes in future should support certain functionality generally used and needed. Main functions are making logs, reporting errors and communication between scripts (for example, Anti Cheats and RP). The way it's intended is that there are a set of functions - given here, that every script should have. They would be made by script author and had some basic templates. Then, as they are always there, they would be the way of replacing basic output such as printf() and others, which would be controlled by the script author's made functions. So when there's a code, which for example has debug mode (for example - testing code) the code writer would be recommended to use controlled output. (Note that code writer and script author may or may not be the same person)

Definition

These functions are currently defined in these ways both in use and implantation. Where everyone who writes code for someone else should use this syntax and code base should contain it’s implantation.

Debug setting : #define DEBUG
This would inform that script is in debug mode, given that there's only one debug level (suggestions?

The log function : log(variable, comment[])
Or should it be : log(variable, logcode, comment[]) // Depends on which would be more suitable. But I'd say this one.
The purpose of this function is to send common data to server log, for example, a player enters a bank.

The report function : report(info[],description[])
This function is the simple way of giving some information to server (log), for example, reporting test results.

The warning function : warning(info[], reason[], description[], comment[])
Or should it be : warning(warning_code, reason[], description[], comment[])
For reporting warnings, their cause, information and comment, for example, warning server that a file doesn't exist. Description is meant for further data about the warning meaning. The point of splitting possibly one text into 4 pieces is simple - not all warnings are important, and it's up to script author to decide how to handle them (for example, excluding comments).

The error function : error(info[], reason[], description[], comment[])
Or should it be : error(code, reason[], description[], comment[])
Difference here is that warning should be used in cases, when something could be wrong, while error indicates that something has gone wrong. For example, file read error.

Examples and defaults
<When accepted, there will be templates for every function>

Simple way of writing the log function :
pawn Код:
stock log(variable, comment[])
{
    printf("LOG : %d || %s", variable, comment);
}
This function would simply output all log data, without any filters. (But it may need to have multiple tags for "variable")

Logging simple action data:
pawn Код:
OnPlayerConnect(playerid) {
    log(playerid,"Player connected");
}
Here this example calls the log function and informs in comment that the value indicates id of connected player.
Now in examples such as this, I consider that usage of different purpose log codes may be vital for meaning of this function.

Warning simple problems in script : (Please report any mistakes!)
pawn Код:
new pKick[MAX_PLAYERS][128];

OnPlayerDisconnect(playerid, reason) {
    if(reason==PLAYER_KICKED) {
        if(!strlen(pKick[playerid])  // Note that I use here one function and skip { }
          warning("Missing data","Player has left without known reason","Script has detected missing data, this may happen if code isn't incorporated correctly","Always specify reason for kicking players!");
        else {
          new str[128+sizeof("Disconnected: ")];
          format(str,150,"Disconnected: %s",pKick[playerid]);
          log(playerid,str);
        }
    }
Changes and suggestions
<No changes so far>
Reply
#2

Ok, this right now seems pointless, it seems that sa-mp scripting is around learning the basics rather than fucking making something real. Fck this.
Reply
#3

This thread is pointless, you are correct. You should stop raging because nobody wants to conform to your pointless "specifications."
Reply
#4

Quote:
Originally Posted by RSX
Посмотреть сообщение
Ok, this right now seems pointless, it seems that sa-mp scripting is around learning the basics rather than fucking making something real. Fck this.
You ever think it is your post that is bad? I dont know exactly what your expecting out of a post like this, so maybe you should try to edit it with a bit more information?
Reply
#5

Quote:
Originally Posted by Kyosaur
Посмотреть сообщение
You ever think it is your post that is bad? I dont know exactly what your expecting out of a post like this, so maybe you should try to edit it with a bit more information?
What more should I add? Really, I don't want to write a ton of text that will not be used. This specification is my proposal for these certain things, if anyone thinks they should be different then say so. I'll add some more examples of course, but otherwise I've defined what they could be like.
Reply
#6

Ok, I edited the topic, did I make it clear what is the point of possible default functions?
Reply
#7

I like the idea of standardized scripts, but unfortunately most of the scripters around here indeed are just interested in learning the basics (mostly to edit a script for their own RP server). Additionally most released script arent really suitable for common use or editing, but just for other beginners to learn something (in some cases to learn something WRONG).
So scripting specs would only be interesting for advanced scripters and bigger useful scripts, and these are often used to their own style, so they do not really care about specs. But if this WOULD work, it could improve public scripting a lot.
Reply
#8

To ****** : I'm trying to give example of my sight of it, it's up to community to bring up other examples and their ideas about these possibilities of scripts.
To Mauzen : I start to think that maybe, just maybe, creating 1. template and base of a project 2. some standard projects (like maths helpers, weather controls) to make a solid base that is by itself useful for anybody and can inspire others. But I'm not sure about that, your thoughts?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)