Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - S.L.C

Pages: 1 [2] 3
16
Script Releases / Re: [Snippet]Player Fps
« on: September 20, 2014, 12:14:28 am »
There seems to be a bug in the script module where the player instance is not the same in onPlayerPart the as the one used in onPlayerJoin and causes en error when the player leaves. I'll report this issue and see why this happens. The following works but there's an error when you disconnect and the previous player instance isn't removed:
Code: [Select]
local g_FPS = [];

function DrawFPS()
{
foreach (val in g_FPS)
{
if (val.Text != null) val.Text.Delete();
val.Text = CreateTextdraw("FPS: " + val.Player.FPS, 0, 0, 0xFFB0B0B0);
if (val.Text != null) val.Text.ShowForPlayer(val.Player);
}
}

function onServerStart()
{
NewTimer("DrawFPS", 5000, 0);
}

function onPlayerJoin(i_player)
{
g_FPS.push({Player = i_player, Text = null});
}

function onPlayerPart(i_player, reason)
{
for (local i = g_FPS.len()-1; i >= 0; i--)
{
if (g_FPS[i].Player.ID == i_player.ID)
{
if (g_FPS[i].Text != null) g_FPS[i].Text.Delete();
g_FPS.remove(i);
break;
}
}
}

BTW: The FPS value updates once every 10 seconds internaly, so there's no reason to draw something every second. I've set the draw function to run every 5 seconds instead of 10 to not risk printing an outdated value because the start point of our timer doesn't match with the internal timer on the FPS update function. This should make the draw function have on foot in the previous time lapse and another in the next time lapse but never have both feet in the same time lapse (so to speak).

EDIT: Updated the code to comply with the limitation specified above. Certainly looks more awkward but does the job.

17
Script Releases / Re: [Snippet]Player Fps
« on: September 19, 2014, 10:00:47 pm »
You really need to revise the current implementation. If you require an array element for each second that the server is running then you seriously need to take a look at your code from a different perspective:
Code: [Select]
fps <- array(86400,null);//86400 stand for seconds in a day so if u r going to run server continuously for more than 1 day than change it.

18
Thanks stormeus. I had almost forgot about the execution context and how things are done in Squirrel. Problem solved and this topic can now be locked :)

19
Description
I cannot open SQLite databases inside class member functions.

Reproducible
Always

What you were doing when the bug happened
N/A

What you think caused the bug
I'm too tired to find out right now. Hopefully I'll dig deeper when wake up tomorrow.

Code that can reproduce the error:
Code: [Select]
// ------------------------------------------------------------------------------------------------
DB <- {

}
// ------------------------------------------------------------------------------------------------
class DB.Database
{
// --------------------------------------------------------------------------------------------
_File = null
// --------------------------------------------------------------------------------------------
_Handle = null
// --------------------------------------------------------------------------------------------
constructor(db)
{
// Is this a path to a database?
if (typeof db == "string") _File = db, _Handle = null;
// Is this a handle to an already opened database?
else if (typeof db == "userdata") _File = null, _Handle = db;
// Invalid arguments were passed to the constructor
else return print(format("Database constructor requires parh or handle as it's first argument. Got: %s", typeof db));
}
function Open()
{
// Make sure the previous handle was closed or that there wasn't one to begin with
if (typeof _Handle == "userdata") return print("Database is already opened. Operation will be aborted.");
// Make sure that a database file was specified and that
else if (typeof _File != "string") return print("Unknown or missing database path. Operation will be aborted.");
// Try to open the file as an SQLite database now

print("member: " + _File + " is of type " + typeof _File);

_Handle = ConnectSQL(_File);

// Check if the previous operation succeeded and notify someone in case of failure
if (_Handle == null) return print(format("Unable to open the SQLite database from: %s", _File));
// The database was opened successfully and the operation is complete
else print(format("Successfully opened SQLite database from: %s", _File));
}
}

function onServerStart()
{
local db1 = ConnectSQL("mydb.db");

if (db1 == null) print("Method 1 failed");
else print("Method 1 succeeded");

local file = "mydb.db";
local db2 = ConnectSQL(file);

if (db2 == null) print("Method 2 failed");
else print("Method 2 succeeded");

// Try method

local db = DB.Database("mydb.db");

db.Open();

print("break point.");
}

Code image including line numbers and console output:

20
Script Releases / Re: Dialog System v1.0
« on: September 17, 2014, 08:25:22 pm »
Haha, I was working on a similar system for a mod I was playing with. The concept is similar to the menus in CS 1.6. Although I suggest that you make the dialogs saveable in XML, JSON or any structured format and then load them your self at server startup. This gives you the ability to introduce individual styling and keep the code clean. One more suggestion is to allow users to bind their own functions when a client interacts with a menu item. The function binding process shouldn't be too hard to implement in Squirrel.

Good job  ;)

PS:

This is a menu system and not a  dialog system. A dialog is a simple window that asks you something or requests some simple input. This is a dialog (actually a modal window) and this is a menu. Menu definition: "A menu is a collection of elements showing related user actions"

21
Script Discussion / Re: How to make a "double array" ?
« on: September 16, 2014, 06:49:15 pm »
You mean like a multidimensional array? Like in the following example:

Code: [Select]
arr <- [
["sub array 0", true, 54, 0.45],
["sub array 2", false, 213.6, 32],
["sub array 3", false, 9897, 45.425],
["sub array 4", true, 321.2353, 32]
];

foreach (sub in arr)
{
print(format("\n%s elements are the following:\n", sub[0]));

print(format("\telement 1 is of type %s with the value %s\n", typeof sub[1], sub[1].tostring()));

print(format("\telement 2 is of type %s with the value %s\n", typeof sub[2], sub[2].tostring()));

print(format("\telement 3 is of type %s with the value %s\n", typeof sub[3], sub[3].tostring()));
}

Output should be:
Code: [Select]
sub array 0 elements are the following:
        element 1 is of type bool with the value true
        element 2 is of type integer with the value 54
        element 3 is of type float with the value 0.45

sub array 2 elements are the following:
        element 1 is of type bool with the value false
        element 2 is of type float with the value 213.6
        element 3 is of type integer with the value 32

sub array 3 elements are the following:
        element 1 is of type bool with the value false
        element 2 is of type integer with the value 9897
        element 3 is of type float with the value 45.425

sub array 4 elements are the following:
        element 1 is of type bool with the value true
        element 2 is of type float with the value 321.235
        element 3 is of type integer with the value 32

22
General Discussion / Re: System Requirements for 0.4 ?
« on: September 15, 2014, 10:44:52 pm »
The system requirements are XP SP3 or newer as rwwpl already said. All other system requirements are the same as the base single player game.

And a network connection ;D Just a joke but it's a requirement that the single player doesn't need.

23
General Discussion / Re: System Requirements for 0.4 ?
« on: September 15, 2014, 05:41:49 pm »
The Client or the Server? What OS?

24
Script Discussion / Re: Approximate date of release 0.4 ?
« on: September 14, 2014, 10:54:50 pm »
The 0.4 version was released two months ago. What other version are you referring to? The stable version? The stable version will be released when the developers think no other critical bugs exist in the current release. It's not something where you can give an approximate time and date of the actual release.

25
General Discussion / Re: Single player script on VC-MP
« on: September 13, 2014, 10:32:41 am »
As far as I know... No! If you're actually intending to keep the NPCs and other things found in single player. However, you can host a server on your computer and allow your buddies to connect via LAN. And you can script your game mode for multiplayer.

26
Script Discussion / Re: Database Problems
« on: September 13, 2014, 10:28:11 am »
There's a read only property on the player instance called "FPS". And you can see the player FPS through that variable:
Code: [Select]
function onPlayerJoin(i_player)
{
    print(i_player.FPS);
}

27
General Discussion / Re: Interest towards VC:MP
« on: September 12, 2014, 09:09:27 pm »
I know that.Eh,and what's the problem?He's romanian,as well as me.Why can I spell the word?

What the fffffff**** is wrong with you people? Haven't you ever (in your whole miserable life) happen to not press a key hard enough for it to not be considered a valid keystroke which resulted in a skipped character? Stay on the god damn topic or get the f*** out and annoy someone else.

28
Script Discussion / Re: Database Problems
« on: September 12, 2014, 08:54:49 pm »
There's an issue with your query:
Code: [Select]
CREATE TABLE IF NOT EXISTS Account ( Name TEXT, Password TEXT, IP NUMERIC, Level NUMERIC, Cash NUMERIC, Bank NUMERIC, )Can you see it?
Code: [Select]
Bank NUMERIC, )
There's a comma "," symbol that isn't supposed to be there at the end:
Code: [Select]
CREATE TABLE IF NOT EXISTS Account ( Name TEXT, Password TEXT, IP NUMERIC, Level NUMERIC, Cash NUMERIC, Bank NUMERIC )
EDIT:

But that whole query is wrong and my recommendation is to get rid or it. Try the following example and see if it works:
Code: [Select]
// General global constants
const MAX_NAME_LENGTH = 128;
const MAX_PASSWORD_LENGTH = 128;
const MAX_ADDRESS_LENGTH = 16;

// Global variable holding the database handle
local g_DB = null;

function checkDb(name)
{
// If the database file doesn't exist then try to create one
local fp = file(name, "a");
// Check if the previous action succeeded
if (fp == null)
{
print("Unable to open or create the file: " + name);
// No point in going forward
return false;
}
// Now we know the database file exists and can be opened.
else fp.close();
// Try to open the file as an SQLite database
g_DB = ConnectSQL(name);
// Check if the previous action succeeded
if (g_DB == null)
{
print("Unable to open the SQLite database: " + name);
// No point in going forward
return false;
}
else return true;
}

function onServerStart()
{
if (!checkDb("mydb.db")) return 0;

// Try to create the table
QuerySQL(g_DB, format(@"CREATE TABLE IF NOT EXISTS [Account] (
[Name] VARCHAR(%u)  NOT NULL,
[Password] VARCHAR(%u)  NOT NULL,
[IP] VARCHAR(%u)  NULL,
[Level] NUMERIC DEFAULT '0' NULL,
[Cash] NUMERIC DEFAULT '0' NULL,
[Bank] NUMERIC DEFAULT '0' NULL
);", MAX_NAME_LENGTH, MAX_PASSWORD_LENGTH, MAX_ADDRESS_LENGTH));
}

29
General Discussion / Re: Interest towards VC:MP
« on: September 12, 2014, 04:55:22 pm »
You spelled the word "attitude" wrong,anyway.

That's because in his language attitude is written with a single "t" (atitudine) which makes the mistake understandable. A mistake like this is probably insignificant and as long as the message is received correctly. No reason to be too strict here.

30
General Discussion / Re: Interest towards VC:MP
« on: September 11, 2014, 10:25:55 pm »
I just came here to say that the progress of VC:MP is very slow.You started the beta in august 2013 if I'm not wrong and still we are in this beta period,shall I ask if it's normal ?I've never seen in my life something to be in beta for more than 1 year

You answered that your self.

I wanted to say that there are only 2 devs active and 6 lazy not busy.


I wanted to say that you need to recruit some people in the VC:MP devs group because 2 are not just enough to develop this mod for VC.

As you can see the source is quite protected and I have to (you also have to) believe that it's for the sake of consistency. Making the source public would span dozens of copies and distributions. With probably 1 or 2 lines of code different from the original. But those lines of code could make a huge difference when a server and a client talk differently.

So a new person coming to play this game wouldn't know which client to choose from and on which server does his client work on. Not to mention that you as a server owner will probably have to host a dozen more servers if you want to attract more people because those people will use different clients on their own that each work with their specific server.

Scriptwriters will have to document for every distribution out there and know the differences and bugs in each distribution as well. And as you can see all of this leads to an even bigger chaos with even more serious issues and bugs introduced. There wouldn't be a standard anymore and where there isn't a standard there is chaos.

And I haven't even started on distributions which can contain malware and all kind of viruses that you willingly install on your computer thinking it's legit. An antivirus wouldn't detect that easily because it's embedded into the code instead of being injected or attached to another executable. And even then you would think it's normal behavior and is just another false/positive alert since the client attaches to the game process and does some heavy memory modifications at runtime to control behavior of the game.

Now back to the issue why there are so few developers involved. Because it's hard to trust someone with the source code as already mentioned. Any one of these punks could mess around and release the source which would result in what I've just mentioned above. They just can't trust some anyone with the source code.



You seem to complain that the development doesn't go as fast as you want or as good as you want. But let me just tell you: Why don't you do it your self? Yes you read correct! Why don't you create a VC:MP version of your own and then see how hard it is.

This is free software people. Nobody is getting paid to work on it and nobody earns anything from it. Which means you have to get a real job (one that pays) to be able to make a living. And the real job will be more exhausting then working to maintain VC:MP. And the real job doesn't care that you must also go home to work on your hobby. The real job pays you and you have to deliver or else... And when you finally get home after an exhausting day at work. Coding for VC:MP will be the last of your worries.

Developers have a life too. Just because you don't have a life that doesn't mean they don't either. If you are some some 13 year old kid then you couldn't possibly understand this now. But you will, in a few years you will fully understand it and get to experience it as well. And then you'll see how hard it is.

Pages: 1 [2] 3