Vice City: Multiplayer

VC:MP Discussion => General Discussion => Topic started by: habi on Apr 14, 2022, 01:33 PM

Title: Hi guys a new idea
Post by: habi on Apr 14, 2022, 01:33 PM
I just got this idea and get captivated by it.
It is about making of a program, (an executable for windows and linux), say it's name snippet downloader for vcmp.

You open it and enter a command like
apt-get install speedometer
The 'apt-get' is mimicked from ubuntu style, we can change it to something.

Now, you type this command and then press enter.

The program connects to github and searches for project VCMP_speedometer. It finds it and open the 'direction file', say a file which tells our program
1. Which modules (xx04rel64) to use. If speedometer uses a new module which the creator has created it's name and location in github project.
Instructions to make changes to server.cfg
2. Suppose your snippet wants to add code to onPlayerEnterVehicle, the program reads your main.nut find onPlayerEnterVehicle and codes to it.
It is quite complicated, but possible.
3. Similarly we handle client side scripts and adding objects may also be possible.
4. Most importantly, the program must be able to revert back the changes.

The creators of snippets should make variables with names (if they are using global variables) such that it does not coincide with general variable names used in servers.
Have you got what i am telling. How many people agree with me?

So i will state it once again. i.e. no more script download - copy paste - index does not exist-.
Just open program type the name of the package and done.

So somebody(on our forum) must maintain a file online which contains the name of package and the url to it.
Title: Re: Hi guys a new idea
Post by: DizzasTeR on Apr 15, 2022, 01:34 PM
I get where you're coming from, this is pretty much what package managers do, the problem we have is VCMP has no event bindings or any concept of script modularity/packages/resources whatever you want to call it which is why something like this is going to be painful to implement.

One issue this would have on the current structure of VCMP scripts working is that Snippet A inserts code in onPlayerJoin and Snippet B also inserts code in onPlayerJoin but the code of Snippet B MUST be executed BEFORE the code of Snippet A, there's no way to manage that if someone installs A first and B second.
Title: Re: Hi guys a new idea
Post by: habi on Apr 15, 2022, 06:48 PM
Yes DizzasTer, i am talking about a package manager for vc-mp.

I have a beginning idea. Let us call it 1A.

1A. Creating the vc-pm (Vice City Package Manager)
-------------------------------------------------------------------------
This might consist of a single vc-pm.exe which can be built from C++ with curl libraries plus a abstract machine - squirrel, pawn, lua or anything.
vc-pm-get update
vc-pm-get install anti-spawn-kill
Fetching package 'anti-spawn-kill' ...
Found package 'anti-spawn-kill' by Doom_Kill3R   
Downloading requisite files (Found 2 files: manifest, anti_spawn_kill.nut)
Download complete. Reading manifest.
Performing actions.
Installation Complete
>
Now the manifest will be written in the language of the abstract machine we mentioned earlier. Let us suppose our abstract machine is squirrel. Then manifest will be in squirrel language.
So each snippet will be accompanied by this manifest file.
Contents of manifest file
1. Copy Paste plugins if any( to plugins folder )/ Check if it already exist.
2. Add Proper changes to server.cfg
3. Now the following is highly advanced:

The manifest file will check if squirrel gamemode is used in server.cfg. If not, installation is aborted and error message "This package can only installed on squirrel gamemode. Gamemode found: java. Do you want to add squirrel gamemode along with the gamemode found?" (Next level, maybe )

Now, if this is squirrel (i.e. squirrel04rel64 ) is found in server. cfg
Also manifest checks if 'server32' is in folder or 'server64'. ie. it should take care of bitness, in case of adding plugins to server.cfg
Now, if squirrel gamemode is found, manifest contain instruction.
1. Adding global variables and dofile. const PROTECTION_TIME = 5000; dofile("packages/anti-spawn-kill/Anti_Spawn_Kill_M.nut
Now, before manifest file doing this it must create Anti_Spawn_Kill_M.nut (M for modified) from original anti_spawn_kill.nut which is stored somewhere( say packages/anti-spawn-kill/raw/anti-spawn-kill.nut). The modified file is a copy of original with event names like onPlayerJoin, onScriptLoad renamed. You will understand about it in next step.
2. Finding function onScriptLoad. If found adds a line onAnti_Spawn_Kill_ScriptLoad(); (to the top or bottom?)
3. Find onPlayerJoin function. Checks if the parameters are correct (i.e. player). Adds a line onAnti_Spawn_Kill_PlayerJoin(player). Parameter 'player' should match with that of onPlayerJoin.
4. In this way it modifies all functions in scripts/main.nut (suppose that is the gamemode file read from server.cfg)
5. manifest file puts objects/skins/weapons/etc if any (this package do not have) into the appropriate folders.
6. Now about client side script, there will be problem. No actually when a scripter releases a snippet, it will not be compiled (cnut files). So we  will edit the client side script also in a similary way. Copying our file to store/scripts and editing main.nut there
Title: Re: Hi guys a new idea
Post by: DizzasTeR on Apr 16, 2022, 06:10 AM
Yeah all of that is definitely do-able but again I can't think of any way to address the issue I mentioned in my first post, how do we get around the issue of priority calls, 2 snippets that use the same event may break if one is not executed first (Check 2nd paragraph in my first post)

Although this can be so so much easier to do with SqMod, since it supports 100% (So far there hasn't been any official squirrel plugin script that SqMod can't run in backward compatibility) and SqMod can easily let you download and run scripts in a package-manager based environment because you simply add 1 line to the config file, no event name changes, no function name changes and you're done.
Title: Re: Hi guys a new idea
Post by: habi on Apr 16, 2022, 02:13 PM
Quote from: DizzasTeR on Apr 15, 2022, 01:34 PMOne issue this would have on the current structure of VCMP scripts working is that Snippet A inserts code in onPlayerJoin and Snippet B also inserts code in onPlayerJoin but the code of Snippet B MUST be executed BEFORE the code of Snippet A, there's no way to manage that if someone installs A first and B second.
Why Snippet B must be executed before Snippet A... Is there any such situation where this should be so. They are two different snippets having nothing in common unless
1. Snippet A kick player
2. In event onPlayerEnterVehicle Snippet A returns 0 which means denying vehicle entry.
function onPlayerEnteringVehicle(player, vehicle, seatid)
{
local var1=onSnippetAPlayerEnteringVehicle(player, vehicle,seatid);
if(var1==0) return 0;
onSnippetBPlayerEnteringVehicle(player, vehicle, seatid);
}
Ha i need to think about it

Edit: This is regarding the mode of announcing snippets.
We create a new topic in forum.vc-mp.org. And our program (using curl or something) reads the topic, browse through the pages.
Each scripter post information regarding his snippet as a 'post' in this topic in a 'specified manner'
The 'specified manner' being something like
VC-PM Package=In-game-Class-Editor ZipFilePath=http://files.thijn.ovh/download/17f27a840acd40dece2b01725bbac219/Class%20Editor.rar Author=MRSK143So our program reads this message, and download the file. All files, let be zip file in the beginning. We can proceed to rar, etc later.

So everybody will be able to contribute without any problem.
Title: Re: Hi guys a new idea
Post by: habi on Apr 20, 2022, 04:56 PM
Some old ideas needed to be abandoned.

I am just posting a new simple way of doing this 'package manager'. In this, the owner of the package has to create a file called 'injector' with the instructions like create global variables from main.nut
create class PlayerClass from main.nut
inject function onScriptLoad from main.nut
inject function onPlayerJoin from main.nut
inject function onPlayerCommand from main.nut
create function GetTok from main.nut
doesexist ReadTextFromFile
create function ReadTextFromFile from FileHandler.addon
doesexist WriteTextToFile
create function WriteTextToFile from FileHandler.addon
create function GetTableCount from FileHandler.addon
So when installing the package, our program does the following.
1. If command is create, it just create a class or function in user's main.nut
2. If command is inject, our program adds the body of 'function' to that of user's function. For example
package function onScriptLoad()
{
   print("My package loaded\n");
}
Now, suppose user already has an onScriptLoad in his main.nut as
function onScriptLoad()
{
     print("My cute little Server started\n");
}
and our command
inject function onScriptLoad will produce exactly the following result
function onScriptLoad()
{
     print("My cute little Server started\n");
     print("My package loaded\n");
}
Title: Re: Hi guys a new idea
Post by: habi on Apr 26, 2022, 06:13 PM
just decided to share something on which i was working today last two hours. the screen area was bit small when recording..

(https://i.imgur.com/GXmNFZ7.gif)

If the above gif is not playing properly on your computer, then right click and save as to your computer. Then open  and see it.

# : i have used UnRAR.dll to extract the rar file.

We can provide support for zip files too.

I am planning it like this: Any scripter after completion of his snippet, will post in Snippet showroom. Our program at the moment cannot read Snippet showroom. but we will add it in future. If he want his snippet to be available under this package manager, he will create a post in topic "8811" in a format (like in video).



Title: Re: Hi guys a new idea
Post by: habi on May 09, 2022, 03:31 PM
Locking this topic because of difficulty in the path.
We were trying to ' inject ' a scripter's snippet into the user's nut files. The program reads the user's file search for a pattern like "function onPlayerJoin( player ){"  ( i have used regex) and try to paste the code at the proper place. The problem is that even if the "function onPlayerJoin" is inside 'comment', it will insert the snippet.

In google, there are some things called 'grammar' . I do not know it. May be after studying it or so we will implement this.

Locking for now.
Title: Re: Hi guys a new idea
Post by: NicusorN5 on Aug 05, 2022, 08:55 AM
You'll have to implement a Squirrel parser to find the "function blablabla()" and paranthesis to properly insert snippets. At this point, you may also write a static analyzer.