Menu

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.

Show posts Menu

Messages - jWeb

#61
General Discussion / Re: parachutes
Feb 01, 2017, 12:22 PM
With a bit of work and some math skills probably yes http://forum.vc-mp.org/?topic=1051.0 But for the average VCMP scripter... absolutely not.

For a better performance and accuracy, this should probably be implemented as a native plugin.
#62
Nobody cares when you declare global and/or local variables as long as they're there when you need them.

function A() {
    print(SOMEVAR);
}

function B() {
    SOMEVAR <- "Hello World!";
}

B();
A();

In that particular example. By the time the A() function is compiled, "SOMEVAR" does not even exist. Only when the B() function is called the variable is created.

MakeTimer(this, function() {
    // Must catch the error so the timer won't destroy itself!
    try {
        print(SOMEVAR);
    } catch (e) print(e);
}, 1000, 5);

MakeTimer(this, function() {
    SOMEVAR <- "Hello World!";
}, 3000, 1);

In that particular example "SOMEVAR" does not even exist until the second timer create's it after 3 seconds.

So as you can see. Nobody cares when you create global variables as long as they're there when used. That's one of the issues with Squirrel. Because if you spell the name of a variable wrong. You won't know about it until you execute that code. And most of the times that happens in production environments (which is bad!).

Ideally, you'd want to reduce the number of things that you create in the global table. Because if you create too many then it'll slow down the search for the others. I believe there are some video tutorials around this forum that explain how contexts/scopes and closures work in Squirrel.

And also, that guide from the quote you included in your program should be more than enough to answer all your questions of when to use them when performance is a concern.

In addition to that guide, I'll add this image to further guide anyone in choosing to store their variables in the most optimal location.



EDIT: Further clarification because the given information might be interpreted wrong.

By "globally in the root table" I mean either:
SOMEVAR <- "Hello World!";
// Or manually: getroottable().rawset("SOMEVAR", "Hello World!");

By "locally to the script" I mean local outside of a function:
// myscript.nut

local SOMEVAR = "Hello World!";

function ABC() {
    print(SOMEVAR);
}

function IJK() {
    print(SOMEVAR);
}

function XYZ() {
    print(SOMEVAR);
}

ABC();
IJK();
XYZ();

/* Output:
Hello World!
Hello World!
Hello World!
*/

And by "locally to the function" I mean:
function ABC() {
    local SOMEVAR = "Hello";
    print(SOMEVAR);
}

function IJK() {
    local SOMEVAR = "World";
    print(SOMEVAR);
}

function XYZ() {
    local SOMEVAR = "!";
    print(SOMEVAR);
}

ABC();
IJK();
XYZ();

/* Output:
Hello
World
!
*/

Please note that even though function environments can be altered, you'll still be referring to the variable locally to a script:
SOMEVAR <- "NOT Hello World!"; // global
local SOMEVAR = "Hello World!"; // local

function ABC() {
    print(SOMEVAR);
}

ABC();
::ABC(); // force root table as the environment
ABC.call(getroottable()); // force root table as the environment

/* Output:
Hello World!
Hello World!
Hello World!
*/

This behavior was explained in the quote from the initial post.
#63
General Discussion / Re: Dont delete Rel03
Jan 30, 2017, 03:49 PM
Quote from: KAKAN on Jan 30, 2017, 03:05 PMWell, it might be good, it doesn't suck anyway. Pawno is also used in AMX, so knowing it can make you script CS 1.6 too :D
But, Squirrel is better for me. The best advantage is OOP in Squirrel, which Pawno lacks( though you can use some kind of tables or something to make it work like OO )

The OOP in Squirrel is also based on tables. In fact, class instances are actual tables but they're marked and treated differently.
#64
Servers / Re: [0.4]Romania Cops & Robbers 1.5
Jan 29, 2017, 12:05 PM
Quote from: NicusorN5 on Jan 02, 2017, 02:03 PM- Adding new admins is a lot easier!

I'm pretty sure the players have no use for that feature. You could've omitted it from the list.
#65
Quote from: Xmair on Jan 28, 2017, 07:05 PMI wonder why don't you guys look up the wiki first? :/

I find that to be a good example of a rhetoric question.
#66
Community Plugins / Re: Droproot plugin
Jan 26, 2017, 03:14 PM
Quote from: EK.IceFlake on Jan 26, 2017, 02:14 PMWhat if you feel too lazy to make another acc?

Juts because you're lazy then that doesn't mean other's are lazy as well. And by that I don't mean that other people will not be lazy and secure their servers. I mean that other people who specialize in breaching systems will not be lazy and make you regret it (that is, if you even realize you've been breached).
#67
Quote from: Kewun on Jan 25, 2017, 12:54 PMI just find exploits in people's servers

Using someone else's hack/aim/bot/w/e does not count as "find exploits". Pretty sure you can't even comprehend the definition of the word "exploit". Because if you did, you would knew that driver "booster" exploited you. So there's that.
#68
Quote from: Kewun on Jan 25, 2017, 06:45 AMDon't be stupid it always worked for me and you are a crap you didn't even try it noob

Actually, it's a known fact that most free software which has a pro version is most likely used as a bait.


On the left is the free version and on the right is the pro version. As you can see, they have the right to give only a small portion of what you need.

#69
Quote from: Kewun on Jan 24, 2017, 02:20 PMinstall driver booster and check for driver updates

Don't do that. Those crappy softwares come with more then what you bargain for and you never actually get any driver updates unless you pay for something. Better use drp.su It's free and tends to work well for a huge range of hardware. Although, it has enabled some common software enabled by default. Such as winrar,7zip,chrome,opera,mozilla etc. including a notification system of their own. You might want to disable what you don't need before you click any button to install drivers. Look for a button/label/text about some "Expert" mode or something. Don't let it install things on it's own. As with all software out there. At least with this one you get the option to disable what you don't want. IIRC, was recommended several times here on the forum.
#70
Quote from: EBX78 on Jan 21, 2017, 11:39 PMHello again
I've lose the register the time setting before the Register but the i look the setting there are not setting time for VCMP forum

Help me please


Man, that translator is total jerk for doing this to you.
#71
Off-Topic General / Re: Learning C++
Jan 20, 2017, 05:33 PM
Quote from: KAKAN on Jan 20, 2017, 04:00 PMI'd suggest to use Java and/or C# first, then move to something lower.

From language specification perspective, C is very simple. However, because of that. It can be a real pain in the ass to work with it. It's shares the same story that assembly does. Most people do the same mistake there as well. They think assembly is hard. However, the language isn't hard to understand. What's hard is using the language efficiently (the word 'efficiently' here does not stand for 'performance').
#72
Suit your self. You're the one with the requirements. So you evaluate them.


elFinder seems to be mostly for embedding (probably what you're looking for). I've seen it in several web-hosting panels. I think I've seen Pydio embedded in the development version of Bright Game Panel (never got released officially). eXtplorer seems to be good for personal file-management. And I remember it was easy to add users with individual directories to which they have access. Although it was via a PHP or XML file (which can easily be generated btw).


Quote from: KAKAN on Jan 20, 2017, 08:55 AMuhm, why do you even need one?
Anyway, for free, you won't get much, but you can try 000webhost, be sure to use a random password. That website is hacked many a times.
:edit: A min with google: http://www.hostingadvice.com/how-to/free-web-hosting/

Also, wrong answer.
#73
Off-Topic General / Re: Learning C++
Jan 20, 2017, 11:36 AM
C++ can only be tamed with excessive practice. If you don't have a few good years at your disposal. In which you must include in some serious practice regimen. You should probably stay away from C++.

That language is not for the weak. It will break you. Many came before you, thinking they can tame C++. Now they're crying in a corner somewhere.
#74
Quote from: EK.IceFlake on Jan 19, 2017, 01:57 PMThe math library is very abstracted, which means that you could use all math functions without the 'Math.' prefix
Quote from: KAKAN on Jan 19, 2017, 05:04 PM
Quote from: EK.IceFlake on Jan 19, 2017, 01:57 PMThe math library is very abstracted, which means that you could use all math functions without the 'Math.' prefix
off-topic: This makes the Squirrel in-efficient too :p


Neither one of you are correct!

a) Please refresh you memory on what abstract means in programming or in general.
b) They're efficient because they don't have to push the root table on the stack, push a 'math' string to pop the math table on the stack, then push the function name on the stack then pop the function object from the math table and remove the math table from the stack and finally invoke the actual function. Basically having a man in the middle to slow things down.

math <- {
    abs = ::abs,
    acos = ::acos,
    asin = ::asin,
    atan = ::atan,
    atan2 = ::atan2,
    ceil = ::ceil,
    cos = ::cos,
    exp = ::exp,
    fabs = ::fabs,
    floor = ::floor,
    log = ::log,
    log10 = ::log10,
    pow = ::pow,
    rand = ::rand,
    sin = ::sin,
    sqrt = ::sqrt,
    srand = ::srand,
    tan = ::tan
}
// dummy code to allow the CPU to cache the program
for (local n = 0, x = 1; n < 10000000; ++n) {
    x = (n % (n / x)) + 1;
}
// benchmark scoped math functions
local time_1 = clock();
for (local n = 0; n < 10000000; ++n) {
    n = math.abs(n);
}
local end_1 = clock();
// benchmark global math functions
local time_2 = clock();
for (local n = 0; n < 10000000; ++n) {
    n = abs(n);
}
local end_2 = clock();
// output results
print("Scoped math functions: " + (end_1 - time_1));
print("Global math functions: " + (end_2 - time_2));

[SCRIPT]  Scoped math functions: 2.305
[SCRIPT]  Global math functions: 1.976
#75
Quote from: Eduardovich on Jan 18, 2017, 11:32 PMDevs, are you OMG or what? Why I can't use math library of squirrel?
AN ERROR HAS OCCURED [the index 'math' does not exist]

Because you haven't earned that privilege yet.