login
April 24, 2024, 11:27:51 am

Author Topic: [REL] Stormeus' Extensible Scripts  (Read 2406 times)

0 Members and 1 Guest are viewing this topic.

stormeus

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • Posts: 1755
  • Country: us
  • VC:MP Developer
    • View Profile
    • GTA VICE CITY Respective owner
[REL] Stormeus' Extensible Scripts
« on: January 07, 2012, 06:32:42 am »
As usual, I got bored one night and came up with an interesting concept. Instead of having to edit various functions and files to add code you found or to write in a new, complex feature, you can hook and include files to add functionality.

Stormeus' Extensible Scripts (SES) has two types of "objects" (which is just stuff it can load):
  • Includes
  • Hooks

Includes are useful for adding functions that can be used by any other hooks or includes. They should contain functions, such as getting the speed of a vehicle.

Hooks add functionality to an event, like onServerStart or onPlayerMove. Instead of having to manually edit these functions in whatever file they may be, you can hook them by adding a line to an XML file.

A typical SES XML file will look like this:
Code: (Configuration/SES.xml) [Select]
<ses>
    <hook>DemoHook</hook>
    <hook>BasicAnticheat</hook>
    <hook>JoinMessages</hook>

    <include>GetVehicleVelocity</include>
</ses>

Includes are regular Squirrel files. However, hook files are different. If a function named SES_Init() is found in a hook file, it will be called. You can then use different hooking functions, like hook_onServerStart( functionPointer ), to add functionality to a server. Not only that, but each hook function will return an ID which can be used to unhook later. For example:

Code: (Hooks/Demo.nut) [Select]
function myOnServerStart() { print( "good" ); }

function SES_Init()
{
    local hookID = hook_onServerStart( myOnServerStart );

    if( hooked_onServerStart( hookID ) )
        unhook_onServerStart( hookID );
}

Download
http://stormeus.vicelegends.com/ses.zip

« Last Edit: January 25, 2012, 02:41:24 am by stormeus »
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

<krystianoo> stormeus do good job
<krystianoo> with recent update
<krystianoo> if not agree; jeb yourself in head
<Avenger> yesterday you said death to stormeus
<karan> double standard krystianoo
<karan> he called him fake prophet too
<krystianoo> sure fake prophet
<krystianoo> but with recent updates real

Zeke

  • Crazy Man
  • *****
  • Posts: 935
  • Country: bg
  • VC:MP and LU beta tester
    • View Profile
Re: [WIP] Stormeus' Extensible Scripts
« Reply #1 on: January 07, 2012, 07:29:20 am »
Nice  ;)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

Quote
InstallHook(0x405AC0,(DWORD)CantFindFuckingAnim,0x405A95,
CantFindFuckingAnim_HookJmpCode,sizeof(CantFindFuckingAnim_HookJmpCode));
-------------------------------------------------
Quote
[00:41:12] <~Murdock> actually just transfering files
[00:41:16] <~Murdock> sounds, clientscripts etc
[00:42:05] <heekzs> what transfer method you uses
[00:43:03] <~Murdock> speed of light

Sephiroth

  • Guest
Re: [WIP] Stormeus' Extensible Scripts
« Reply #2 on: January 07, 2012, 10:25:37 am »
This is an excellent concept.

If I get the privilege, I can't wait to see the finished product.


also when did you end up coming up with this?
Cannot rate own posts


Thijn

  • Forum Administrator
  • Crazy Man
  • *
  • *
  • *
  • Posts: 2946
  • Country: nl
    • View Profile
Re: [WIP] Stormeus' Extensible Scripts
« Reply #3 on: January 07, 2012, 11:02:44 am »
I like the idea, but im not sure if im going to use it.
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

I'm not totally useless,
I can be used as an bad example ;)

"Never do Today, What you can do Tomorrow"


Charley

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • Posts: 4751
  • Country: 00
    • View Profile
Re: [WIP] Stormeus' Extensible Scripts
« Reply #4 on: January 07, 2012, 11:02:54 am »
Hmm, I'm not sure I fully understand the concept behind this, perhaps due to my lack of coding knowledge outside of squirrel. Could you give one or two more examples of practical uses?
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

Writer of excessively long posts


stormeus

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • Posts: 1755
  • Country: us
  • VC:MP Developer
    • View Profile
    • GTA VICE CITY Respective owner
Re: [WIP] Stormeus' Extensible Scripts
« Reply #5 on: January 07, 2012, 04:34:53 pm »
Its extensible nature makes it easier to add code snippets made by others, or to remove troublesome scripts. If a hook conflicts with another hook, comment one out in the configuration and reload the server.

It also allows for scripts to be easily interchangeable. You can break each separate feature into their own files, instead of having them all in one file with one function. For example: you script a PingCheck and StatsTracker module. Updating either one becomes easier; you only have to deal with one module instead of an entire onPlayerKill event.

The main goal is having a modular Squirrel script. Think dofile(), except you can have the same callback in a bunch of different functions without fucking up. ::)

Or better yet, think of it as a LEGO set: you can add and take out pieces whenever and wherever you want.

(Also, this was a fun experiment with custom exception handlers and function pointers.)
« Last Edit: January 07, 2012, 04:37:17 pm by stormeus »
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

<krystianoo> stormeus do good job
<krystianoo> with recent update
<krystianoo> if not agree; jeb yourself in head
<Avenger> yesterday you said death to stormeus
<karan> double standard krystianoo
<karan> he called him fake prophet too
<krystianoo> sure fake prophet
<krystianoo> but with recent updates real

Charley

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • Posts: 4751
  • Country: 00
    • View Profile
Re: [WIP] Stormeus' Extensible Scripts
« Reply #6 on: January 07, 2012, 07:38:20 pm »
Got it, nice one. Good idea, though like Thijn I'm not sure I'll use it.
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

Writer of excessively long posts


stormeus

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • Posts: 1755
  • Country: us
  • VC:MP Developer
    • View Profile
    • GTA VICE CITY Respective owner
Re: [WIP] Stormeus' Extensible Scripts
« Reply #7 on: January 07, 2012, 09:21:19 pm »
Uploaded what I have. I'm pretty sure it's good to go. I might use this for myself in later scripts, and if anyone else decides to use it, great.

http://stormeus.vicelegends.com/ses.zip
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

<krystianoo> stormeus do good job
<krystianoo> with recent update
<krystianoo> if not agree; jeb yourself in head
<Avenger> yesterday you said death to stormeus
<karan> double standard krystianoo
<karan> he called him fake prophet too
<krystianoo> sure fake prophet
<krystianoo> but with recent updates real