Main Menu
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 - Vortrex

#61
Scripting Help / Re: Where should I start
January 14, 2020, 04:30:11 PM
Start by joining our Discord server if you haven't already. You'll get faster responses on there. The forums aren't used much unfortunately.
The scripting releases section has some scripts available. There aren't any complete game modes available to use yet but plenty of examples can be found there.
I have some basic scripts on my GitHub to help you get started. You're free to use these as you wish.
There are also some modules available (some with source available) if you need them or want to learn how they're made
#62
I have updated this a bit. You can now bind OnPedEnterSphere and OnPedExitSphere with either a sphere or ped object and OnPedEnterVehicle and OnPedExitVehicle with either a vehicle or ped object. Before this update, only ped objects could be used as the binded source.
#63
Scripting Help / Which language should you use?
November 17, 2019, 12:01:06 AM
I've been asked this question several times in the discord so I decided to just write a topic to save time having to re-explain it. Plus nobody likes walls of text and it's a lot cleaner on the forum.

So I'll start by saying that if you have experience with any of the three scripting languages supported by GTAC (JavaScript, Lua, and Squirrel), then the easy answer is to use that. Familiarity is best and you'll probably be more productive with a language you already know. If you don't have any scripting experience, or never tried any of those three languages, continue reading.


JavaScript
Let's start with JavaScript. It has a massive "community" behind it, and usually within the top languages on sites where you can get help or find resources (Stack Overflow, GitHub, etc). JavaScript is everywhere now, handling both back and front end operations, which is a far cry from it's origins as a way to run simple client-side operations within a web page. For future programming aspirations outside of GTA Connected (especially in web development), this is the language to use. JavaScript resources also start and execute faster than the other two languages on GTA Connected.

Sounds too good to be true right? You bet it is. Despite all the advantages, there are some cons to using it. It's the most complex of the three, and it's quirks make it a poor starter language to learn. JS used to be a big mess but gradually becoming more refined thanks to standards like ECMAScript.


Squirrel
Squirrel is barely known outside of GTA multiplayer mods (and even within them) and a couple other tiny projects. However, I find Squirrel's syntax to be the easiest, but I'm already fluent with it and have been for many years. It has a simple table-oriented structure and basically grabs many of the good parts from other languages. Squirrel was used on a couple other GTA multiplayer mods, like Liberty Unleashed and IV-MP, although both are now defunct. VC-MP is the only active mod that supports Squirrel, and you can find many resources there.

The only issue is that very little documentation exists for it and can make the learning curve a bit more complex. This can be alleviated a bit, thanks to many similarities to JavaScript, which has documentation everywhere. If you're not already using another language and don't plan on doing any scripting outside of GTA Connected, then I definitely recommend Squirrel.


Lua
Lua is the language I'm least adept with, so this answer might be a little bias. You'll find no shortage of Lua scripters around GTA multiplayer modifications. On top of that, there are many useful resources in Lua from other GTA MP mods like FiveM and MTA SA. Lua's operators are generally more oriented around words instead of symbols, so sometimes it can look more like something you'd read/write rather than code. If you need help, Mex is our local Lua guru here at GTA Connected, bringing his ample experience from MTA:SA, VCO, and SOL-O (VCO and SOL-O both long gone) and his VLE resource is still the most advanced and sophisticated that I've ever seen in my many years within various GTA multiplayers. If you're coming from MTA:SA or FiveM (or plan to use them now or in the future alongside GTA Connected), this might be the language for you.

But like the other languages it's not without it's shortcomings. It's not widely supported around the web and not many other projects have support for it. The syntax of Lua is the least similar to the others that GTA Connected provides, which makes converting or borrowing code from them (or vice verse) generally difficult and slow.



I hope you found this information useful.
#64
Module Releases / Re: MySQL Module
October 30, 2019, 08:05:02 AM
  • Updated to work with new SDK format

 
#65
Module Releases / Re: Hashing Module
October 30, 2019, 08:03:58 AM
  • Updated to work with new SDK format
#66
Module Releases / SQlite Module
October 11, 2019, 11:44:21 PM
This is a simple SQlite module for those who want to use it for their server. This module was created by Jack Powell, but since he's busy working on GTAC updates, he gave me permission to make a topic and provide releases. Original GitHub repo here

Downloads:
https://github.com/VortrexFTW/mod_sqlite/releases

Instructions:
Download and place the module file into your server's "modules" folder and put "<module src="mod_sqlite" />" into the modules section of your server XML. Be sure to include the name of your modules folder (it's relative to the main server directory) and do not include a file extension. It should look similar to this:
<modules>
    <module src="mod_sqlite" />
</modules>

JavaScript Example:
let db = new module.sqlite.Database("test.db");
let query = db.query("SELECT * FROM test_table");
console.log(query);

Available Functions:
databaseHandle module.sqlite.Database(string pathToDBFile);
void databaseHandle.query(string queryString);
void databaseHandle.close(void);
#67
Thanks! I kinda just threw them together. We needed these badly.



Also, I wanted to provide an example of how people can make custom events using resources. Found the perfect opportunity.
#68
ATTENTION: This resource is now obsolete. Please check https://github.com/VortrexFTW/gtac_vortrex/tree/master/v-events for the new version, included in my basic resources.


Here's a few events for entering and exiting vehicles and spheres:
addEvent("OnPedEnterSphere", 2);
addEvent("OnPedExitSphere", 2);
addEvent("OnPedEnterVehicle", 3);
addEvent("OnPedExitVehicle", 2);

addEventHandler("OnEntityProcess", function(event, entity) {
if(entity.isType(ELEMENT_PLAYER) || entity.isType(ELEMENT_CIVILIAN)) {
getElementsByType(ELEMENT_VEHICLE).forEach(function(vehicle) {
if(entity.vehicle == vehicle) {
if(entity.getData("in.vehicle") == null) {
triggerEvent("OnPedEnteredVehicle", entity, entity, vehicle, getPedVehicleSeat(entity));
triggerEvent("OnPedEnteredVehicle", vehicle, entity, vehicle, getPedVehicleSeat(entity));
entity.setData("in.vehicle", vehicle);
}
} else {
if(entity.getData("in.vehicle") == vehicle) {
triggerEvent("OnPedExitedVehicle", entity, entity, entity.getData("in.vehicle"));
triggerEvent("OnPedExitedVehicle", vehicle, entity, entity.getData("in.vehicle"));
entity.removeData("in.vehicle");
}
}
});

getElementsByType(ELEMENT_MARKER).forEach(function(sphere) {
if(sphere.position.distance(entity.position) <= sphere.radius) {
if(entity.getData("in.sphere") == null) {
triggerEvent("OnPedEnterSphere", entity, entity, sphere);
triggerEvent("OnPedEnterSphere", sphere, entity, sphere);
entity.setData("in.sphere", true);
}
} else {
if(entity.getData("in.sphere") != null) {
triggerEvent("OnPedExitSphere", entity, entity, sphere);
triggerEvent("OnPedExitSphere", sphere, entity, sphere);
entity.removeData("in.sphere");
}
}
});
}
});

function getPedVehicleSeat(ped) {
for(let i=0;i<=3;i++) {
if(ped.vehicle.getOccupant(i) == ped) {
return i;
}
}
return 0;
}

Just throw that into any client script. Once in place, you can use event handlers with it like you normally would.

Event names are OnPedEnterSphere and OnPedExitSphere for the spheres and OnPedEnterVehicle and OnPedExitVehicle for vehicles.



These are bindable, so you can use bindEventHandler with any ped object, if you want.



Handler arguments are the same for both sphere events: (Ped, Sphere)

For vehicle events, the enter event is: (Ped, Vehicle, Seat) and the exit event is (Ped, Vehicle)


addEventHandler("OnPedExitSphere", function(event, ped, sphere) {
message("Ped " + String(ped.id) + " entered sphere + " + String(sphere.id), COLOUR_YELLOW);
});

// In this section, "sphere" references an existing sphere in the game world.
bindEventHandler("OnPedEnterSphere", sphere, function(event, ped, sphere) {
message("Ped " + String(ped.id) + " entered sphere + " + String(sphere.id), COLOUR_YELLOW);
});

addEventHandler("OnPedExitVehicle", function(event, ped, vehicle) {
message("Ped " + String(ped.id) + " exited vehicle + " + String(vehicle.id), COLOUR_YELLOW);
});
#69
Scripting Releases / [JS] Police Pursuit
July 15, 2019, 11:59:16 PM
What is it?

Just a couple simple snippets to make police cars chase you if you have a wanted level.



How it works:

If you have a wanted level, and a police car streams in with a police officer NPC driving it, they'll pursue you. Their speed depends on your wanted level. Obviously having a wanted level of 1 will make it easy to escape, while higher levels get more difficult.



Note:

This doesn't spawn any extra vehicles or add higher levels of law enforcement with more vehicles. It only uses what exists to pursue suspects.



Code:

https://pastebin.com/kBeBi72vClient Side[/url]

https://pastebin.com/6xfB1eU6Server Side[/url]
#70
Scripting Releases / [JS] Get Vehicles Within Range
July 06, 2019, 11:56:44 PM
Works both client and server-side.
function getVehiclesInRangeOfPos(pos, distance) {
    return getVehicles().filter(x => x.position.distance(pos) <= range);
}
#71
Scripting Releases / [JS] Get Closest Vehicle
July 06, 2019, 11:54:58 PM
Works both client and server side.function getClosestVehicle(pos) {
    return getVehicles().reduce((i, j) => (i.position.distance(pos) <= j.position.distance(pos)) ? i : j);
}
#72
General Chat / WYSIWYG Editor!
June 30, 2019, 02:48:01 AM
QuoteWow we got a WYSIWYG editor now!


That's so bold

Well I think it's very Italian

That's italics you idiot

Ya'll black.

Careful now, that's a grey area.

http]

https://lipsum.com/That's cute. I link to Lorem Ipsum[/url]
#73
General Chat / What is GTA Connected?
June 14, 2019, 08:03:24 AM
Grand Theft Auto Connected (sometimes called GTA Connected or GTA:C for short) is a scriptable multiplayer modification (MP mod) that supports multiple GTA games, including GTA III, GTA Vice City, GTA San Andreas, and GTA IV.

It's basically the one mod to rule them all.

Before GTA Connected, each GTA game had a different modification to play online. These were created by different teams with a different development process and structure. The problem with that is you have to download each mod separately and you end up with a very different experiences when playing each of them. Also, some mods were more unstable than others, and some have poor sync. For server owners and scripters this also meant you had to completely rewrite your scripts to work on another mod to have a server for another game. Thus, GTA Connected was created under the idea of "why play all these different mods when you only need one?"

It's the same experience across every game. Same amazing sync, same stability and security, same "feel" to the games. No need to deal with different mods. Just download GTAC, choose a game, connect, and play! (You'll need to have a copy of the game you want to play on your PC, of course). For scripters, it's the ultimate dream: You only need to write your scripts once. The functions and structures are identical for every game (with a few minor exceptions). Need an example? Check out "Vortrex's Freeroam Server" on any of the games GTA Connected supports ... It runs the exact same scripts for each game all from the same server directory.
#74
Module Releases / Re: MySQL Module
May 18, 2019, 08:50:09 AM
  • Added query.fetchAssoc() function
#75
Module Releases / Re: Hashing Module
May 15, 2019, 10:48:30 PM
  • Added encodeBase64 function.
  • Added decodeBase64 function.