1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-11 19:11:07 +02:00
parent f670d97c4e
commit f2de0674c7
15 changed files with 1765 additions and 626 deletions

View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View file

@ -0,0 +1,21 @@
Message['de'] = {
['buyticket'] = "Drücke ~INPUT_CONTEXT~ um ein Metro Ticket zu kaufen",
['press_to_enter'] = "Drücke ~INPUT_CONTEXT~ während du in der Nähe der Metro bist um einzusteigen.",
['los_santos_transit'] = "Los Santos Transit",
['tourist_information'] = "Touristen Information",
['already_got_ticket'] = "Du hast bereits einen gültigen Fahrschein. Bitte gehe zum nächstgelegenen Bahnhof und steige in die Metro ein",
['account_information'] = "Konto Information",
['account_nomoney'] = "Du konntest kein Fahrschein kaufe, du hast nicht genug Geld.",
['ticket_purchased'] = "Vielen Dank für den Kauf, dein Fahrschein ist gültig für diese Sitzung.",
['stop_toolate'] = "Entschuldigung, es scheint du hast zu spät gedrückt. Du musst jetzt bist zum nächsten Bahnhof warten",
['sorry'] = "Entschuldigung",
['exit_metro_random'] = ", Es ist nicht erlaubt den Zug außerhalb einer Haltestelle zu verlassen!",
['Sir'] = "Herr",
['Miss'] = "Frau",
['need_ticket'] = "Entschuldigung, du musst vorher ein LST Metro Ticket kaufen.",
['have_wantedlevel'] = "Leider erlauben wir keine Flüchtlinge in unseren U-Bahnen. Alle Passagiere sollten sicher reisen können!",
['entered_metro'] = "Sie haben die U-Bahn betreten, Ihr Ticket wurde ungültig.",
['terrorist'] = "Wir tolerieren KEIN terroristisches Verhalten in unseren öffentlichen Verkehrsmitteln!",
['no_metro_spawned'] = "Bitte verzeihen Sie, etwas ist furchtbar schief gelaufen, Sie haben eine Freikarte erhalten!",
['travel_metro'] = "Vielen Dank für Ihre Reise mit Los Santos Transit.",
}

View file

@ -0,0 +1,21 @@
Message['en'] = {
['buyticket'] = "Press ~INPUT_CONTEXT~ to to buy a metro ticket",
['press_to_enter'] = "Press ~INPUT_CONTEXT~ while facing (and near) the Metro to enter it.",
['los_santos_transit'] = "Los Santos Transit",
['tourist_information'] = "Tourist Information",
['already_got_ticket'] = "You already have a valid Metro Ticket, please go to one of the stations and board the Metro",
['account_information'] = "Account Information",
['account_nomoney'] = "Transaction failed, you do not have sufficient funds.",
['ticket_purchased'] = "Thank you for your purchase, your ticket will be valid for the current session.",
['stop_toolate'] = "Sorry, it seems that you pressed a little bit to late, you'll have to wait for the next station.",
['sorry'] = "Sorry",
['exit_metro_random'] = ", but it's not allowed to randomly exit the Metro. Please wait for the next station!",
['Sir'] = "Sir",
['Miss'] = "Miss",
['need_ticket'] = "Sorry, You will need to buy a LST Metro Ticket first.",
['have_wantedlevel'] = "Sorry we do not allow futugives in our Metro's. All passengers should be able to travel safely!",
['entered_metro'] = "You've entered the Metro, your ticket has been invalidated.",
['terrorist'] = "We will NOT tolerate terrorist behaviour on our public transport vehicles!",
['no_metro_spawned'] = "Our Appologies, something has gone terribly wrong, you have received a free ticket!",
['travel_metro'] = "Thank you for traveling with Los Santos Transit.",
}

View file

@ -0,0 +1,21 @@
Message['es'] = {
['buyticket'] = "Pulsa ~INPUT_CONTEXT~ comprar un billete de metro",
['press_to_enter'] = "Pulsa ~INPUT_CONTEXT~ enfrente (y cerca) del Metro para entrar.",
['los_santos_transit'] = "Los Santos Transit",
['tourist_information'] = "Información turística",
['already_got_ticket'] = "Ya tiene un boleto de metro válido, vaya a una de nuestras estaciones y suba a un metro",
['account_information'] = "Información de la cuenta",
['account_nomoney'] = "Transacción fallida, saldo insuficiente",
['ticket_purchased'] = "Gracias por su compra, su entrada será válida durante su sesión actual.",
['stop_toolate'] = "Lo siento, parece que presionaste demasiado tarde, tienes que esperar a la siguiente estación.",
['sorry'] = "Lo siento",
['exit_metro_random'] = ", pero no está permitido salir del Metro al azar. Espere la próxima estación !",
['Sir'] = "señor",
['Miss'] = "señorita",
['need_ticket'] = "Lo siento, primero debes comprar un boleto de Metro.",
['have_wantedlevel'] = "Lo sentimos, no toleramos fugitivos en nuestro Metro. Todos los pasajeros deben viajar con seguridad !",
['entered_metro'] = "Has entrado en Metro, tu billete ha sido invalidado.",
['terrorist'] = "NO toleraremos el comportamiento terrorista en nuestros vehículos de transporte público. !",
['no_metro_spawned'] = "Nuestras excusas, algo salió mal, recibiste un boleto gratis!",
['travel_metro'] = "Gracias por viajar con Los Santos Transit.",
}

View file

@ -0,0 +1,21 @@
Message['fr'] = {
['buyticket'] = "Appuyez sur ~INPUT_CONTEXT~ pour acheter un ticket de Metro",
['press_to_enter'] = "Appuyez sur ~INPUT_CONTEXT~ en face (et proche) du Metro pour entrer dedans.",
['los_santos_transit'] = "Los Santos Transit",
['tourist_information'] = "Information Touriste",
['already_got_ticket'] = "Vous avez déjà un ticket de Metro valide, merci de vous rendre dans une de nos stations et monter dans un Metro",
['account_information'] = "Information Compte",
['account_nomoney'] = "Transaction échouée, solde insuffisant",
['ticket_purchased'] = "Merci pour votre achat, votre ticket sera valide pendant votre session actuelle.",
['stop_toolate'] = "Désolé, il semble que vous avez appuyé trop tard, vous devez attendre la prochaine station.",
['sorry'] = "Désolé",
['exit_metro_random'] = ", mais il n'est pas permis de sortir aléatoirement du Metro. Merci d'attendre la prochaine station !",
['Sir'] = "Monsieur",
['Miss'] = "Mademoiselle",
['need_ticket'] = "Désolé, vous devez acheté d'abord un ticket de Metro.",
['have_wantedlevel'] = "Désolé, nous ne tolérons pas les fugitifs dans nos Metro. Tout les passagers doivent voyager en toute sécurité !",
['entered_metro'] = "Vous êtes entré dans le Metro, votre ticket a été invalidé.",
['terrorist'] = "Nous ne tolérerons PAS le comportement terroriste sur nos véhicules de transport public !",
['no_metro_spawned'] = "Nos escuses, quelque chose s'est mal passé, vous avez reçu un billet gratuit!",
['travel_metro'] = "Merci de voyager avec Los Santos Transit.",
}

View file

@ -9,47 +9,58 @@
Original Post: https://forum.fivem.net/t/release-trains/28841
Original Script: https://github.com/Bluethefurry/FiveM-Trains/releases
Reworked by VenomXNL: https://forum.cfx.re/t/release-fivem-freight-train-ai-and-enterable-trams-as-passenger-suited-for-roleplay-to/
Last Updated: 02-01-2024
(Re-) Worked by: Nickoos
License: Use it as you please but do have decency and respect by crediting the original creators :)
What is it?: A very extensive Train and (well mostely) Metro Addon for FiveM
===================================================================================================================================================================
2024 Update:
===================================================================================================================================================================
This script has been updated ONCE now because suddenly lots of people started making requests for it again, this is however a ONE TIME UPDATE!
I don't script/mod/develop for FiveM anymore, but did wanted to help the community out a bit with this update, because the guy who took over from me
also has left FiveM (as it seems).
I will however NOT provide future support on this script, because I REALLY don't have the time for these games (like FiveM etc) lately.
It is intended to configure and adapt a bit for YOUR OWN server, so please read the comments and instruction to do so :)
NOTE: The code might (is) still a bit messy, but that is because (like mentioned) I seriously lack the time to work on projects like this these days,
I have just scrapped and 're-written' large portions of my old version and modified it to a MUCH simpler approach, and had to do this with lots of 'forgotten
knowledge' after not having scripted for FiveM for many years. So please keep that in mind please :)
===================================================================================================================================================================
Basic Functionality list:
- Activates the 'normal game trains'
- Players can WALK AROUND in the moving Metro, just by walking in :)
- Players HAVE to buy a Metro Ticket to enter (With (ATM) animated Ticket machine handling), otherwise they will get a 1 star wanted level for illegal boarding.
- Ticket will 'invalidate' when they have left the metro (even if it's at the same station!) so they will have to buy a new one
- Spawns a 'synced' (and working/driving) Freight train on the railroad tracks of Los Santos
- Spawns (1 or 2) Metro carts which can be entered as passenger by the players ("no passenger limit!")
- Players can WALK AROUND in the moving Metro! :)
- Players HAVE to buy a Metro Ticket to be able to enter (With (ATM) animated Ticket machine handling)
- Ticket will 'invalidate' when they have entered so they will have to buy a new one
- Wanted level handling (refuse passengers from entering when wanted)
- 'terrorist detection', which means if players shoot while on the train they will get a 4 star wanted level
- Easily configurable with basic variables
- Different Bank Messages (for Maze Bank, Bank of Liberty or Fleeca bank)
- Metro's, Freight Train and their drivers are 'invincible' (to prevent others 'ruining' the game/RP)
- Players can only EXIT the Metro at the stations (by Pressing [E] by default)
- Players COULD enter the Metro ANYWHERE (if they have a Ticket Of course), by making it stop (stand in front of it)
Known 'bugs' or 'issues':
- From the inside the doors of the Metro are invisible and you can walk straight through them (and thus also while the train is moving!)
and they even seem to dissapear if you walk through them if they are closed, this seems to be a 'model issue' with the vehicle,
not sure though and don't have time to figure this out sorry!
- When you enter the Metro as passenger the doors 'will dissapear', why? I don't know, but you can NOT walk through it!
NOTE: They CAN still be used as cover though (the bottom part), which means the 'collision info' will remain active though.
- The ticket machines above ground (the green/old ones) DO NOT WORK, I tried for several hours to find them in the archives but
with no luck. I however did find one that looks like it, but that one doesn't respond at all.
I MIGHT update that when someone can tell me the model of that ticket machine object, however for now I have left it at that.
Also because the original game-texture says: "Sorry, this machine will NEVER work", so i thought: lets keep it in lore :P (nice excuse huh? haha)
- When a player puts a vehicle (which doesn't automatically despawns) infront of the Metro, the Metro will wait there till the
vehicle is removed for eternity.
Possible Questions:
Questions I've already got from our server member/crew while we where testing this script:
- Q: Can you make it so you can drive the Freight or Metro?
- A: Yes, I can.
- Q: WILL you make it so we can drive either of them?
- A: Already done it, Let's test it :P
- Q: (Player on the other side while i'm driving the train:) Woaha, why the f*ck is my train tripping so hard?
- A: Well mine isn't, Maybe it's because i'm driving backwards but YOUR game (engine) isn't expecting it.
- Q: So you have now (permanently) removed the feature to drive the trains?
- A: Yes, I have. And I have even DELETED THE CODE, so I will NOT remake it, since it's not stable enough.
Well that's about the 'main question' I expect to show up (since nearly everyone whom tested it did so to)
So my basic answer is: NOPE I will note make it like that sorry.
Maybe there are others whom have managed to do it, and did made a syncing system (server sided or so), I haven't
and I won't, Sorry. Most of my scripts and server are client-sided with minimal network traffic (via scripting),
only statistics, financials and owned matterials (like houses, cars or items) are server sided to prevent cheating.
And since we won't need the train or metro driver missions I can't 'afford' to put to much time in developing something
stable and thoroughly tested while I'm not going to use it anyway ;)
Other Possible Questions:
- Q: Can I use this on my server?
- A: Sure you can that's why I've uploaded it :)
@ -115,4 +126,4 @@
I hope this code/addon is usefull for some people or that they might learn from it by using parts of it :)
Greets,
VenomXNL
VenomXNL & Nickoos

View file

@ -0,0 +1,830 @@
--===================================================
-- Variables used BY the script, do NOT modify them
-- unless you know what you are doing!
-- Modifying these might/will result in undesired
-- behaviour and/or script breaking!
--===================================================
local IsPlayerNearMetro = false
local IsPlayerInMetro = false
local PlayerHasMetroTicket = false
local IsPlayerUsingTicketMachine = false
local ShowingExitMetroMessage = false
local EverythingisK = false
local Train = nil
local MetroTrain = nil
local MetroTrain2 = nil
local Driver1 = nil
local Driver2 = nil
local Driver3 = nil
local MetroTrainStopped = {}
--===================================================
-- These are radius locations (multiple per station)
-- to detect if the player can exit the Metro
--===================================================
local XNLMetroScanPoints = {
{XNLStationid=0, x=230.82389831543, y=-1204.0643310547, z=38.902523040771},
{XNLStationid=0, x=249.59216308594, y=-1204.7095947266, z=38.92488861084},
{XNLStationid=0, x=270.33166503906, y=-1204.5366210938, z=38.902912139893},
{XNLStationid=0, x=285.96697998047, y=-1204.2261962891, z=38.929733276367},
{XNLStationid=0, x=304.13528442383, y=-1204.3720703125, z=38.892612457275},
{XNLStationid=1, x=-294.53421020508, y=-353.38571166992, z=10.063089370728},
{XNLStationid=1, x=-294.96997070313, y=-335.69766235352, z=10.06309223175},
{XNLStationid=1, x=-294.66772460938, y=-318.29565429688, z=10.063152313232},
{XNLStationid=1, x=-294.73403930664, y=-303.77200317383, z=10.063160896301},
{XNLStationid=1, x=-294.84133911133, y=-296.04568481445, z=10.063159942627},
{XNLStationid=2, x=-795.28063964844, y=-126.3436050415, z=19.950298309326},
{XNLStationid=2, x=-811.87170410156, y=-136.16409301758, z=19.950319290161},
{XNLStationid=2, x=-819.25689697266, y=-140.25764465332, z=19.95037651062},
{XNLStationid=2, x=-826.06652832031, y=-143.90898132324, z=19.95037651062},
{XNLStationid=2, x=-839.2587890625, y=-151.32421875, z=19.950378417969},
{XNLStationid=2, x=-844.77874755859, y=-154.31440734863, z=19.950380325317},
{XNLStationid=3, x=-1366.642578125, y=-440.04803466797, z=15.045327186584},
{XNLStationid=3, x=-1361.4998779297, y=-446.50497436523, z=15.045324325562},
{XNLStationid=3, x=-1357.4061279297, y=-453.40963745117, z=15.045320510864},
{XNLStationid=3, x=-1353.4593505859, y=-461.88238525391, z=15.045323371887},
{XNLStationid=3, x=-1346.1264648438, y=-474.15142822266, z=15.045383453369},
{XNLStationid=3, x=-1338.1717529297, y=-488.97756958008, z=15.045383453369},
{XNLStationid=3, x=-1335.0261230469, y=-493.50796508789, z=15.045380592346},
{XNLStationid=4, x=-530.67529296875, y=-673.33935546875, z=11.808959960938},
{XNLStationid=4, x=-517.35559082031, y=-672.76635742188, z=11.808965682983},
{XNLStationid=4, x=-499.44836425781, y=-673.37664794922, z=11.808973312378},
{XNLStationid=4, x=-483.1321105957, y=-672.68438720703, z=11.809024810791},
{XNLStationid=4, x=-468.05545043945, y=-672.74371337891, z=11.80902671814},
{XNLStationid=5, x=-206.90379333496, y=-1014.9454345703, z=30.138082504272},
{XNLStationid=5, x=-212.65534973145, y=-1031.6101074219, z=30.208702087402},
{XNLStationid=5, x=-212.65534973145, y=-1031.6101074219, z=30.208702087402},
{XNLStationid=5, x=-217.0216217041, y=-1042.4768066406, z=30.573789596558},
{XNLStationid=5, x=-221.29409790039, y=-1054.5914306641, z=30.13950920105},
{XNLStationid=6, x=101.89681243896, y=-1714.7589111328, z=30.112174987793},
{XNLStationid=6, x=113.05246734619, y=-1724.7247314453, z=30.111650466919},
{XNLStationid=6, x=122.72943878174, y=-1731.7276611328, z=30.54141998291},
{XNLStationid=6, x=132.55198669434, y=-1739.7276611328, z=30.109527587891},
{XNLStationid=7, x=-532.24133300781, y=-1263.6896972656, z=26.901586532593},
{XNLStationid=7, x=-539.62115478516, y=-1280.5207519531, z=26.908163070679},
{XNLStationid=7, x=-545.18548583984, y=-1290.9525146484, z=26.901586532593},
{XNLStationid=7, x=-549.92230224609, y=-1302.8682861328, z=26.901605606079},
{XNLStationid=8, x=-872.75714111328, y=-2289.3198242188, z=-11.732793807983},
{XNLStationid=8, x=-875.53247070313, y=-2297.67578125, z=-11.732793807983},
{XNLStationid=8, x=-880.05035400391, y=-2309.1235351563, z=-11.732788085938},
{XNLStationid=8, x=-883.25482177734, y=-2321.3303222656, z=-11.732738494873},
{XNLStationid=8, x=-890.087890625, y=-2336.2553710938, z=-11.732738494873},
{XNLStationid=8, x=-894.92395019531, y=-2350.4128417969, z=-11.732727050781},
{XNLStationid=9, x=-1062.7882080078, y=-2690.7492675781, z=-7.4116077423096},
{XNLStationid=9, x=-1071.6839599609, y=-2701.8503417969, z=-7.410071849823},
{XNLStationid=9, x=-1079.0869140625, y=-2710.7033691406, z=-7.4100732803345},
{XNLStationid=9, x=-1086.8758544922, y=-2720.0673828125, z=-7.4101362228394},
{XNLStationid=9, x=-1095.3796386719, y=-2729.8442382813, z=-7.4101347923279},
{XNLStationid=9, x=-1103.7401123047, y=-2740.369140625, z=-7.4101300239563}
}
-- These are the 'exit points' to where the player is teleported with the short fade-out / fade-in
-- NOTE: XNLStationid is NOT used in this table, it's just here for user refrence!
local XNLMetroEXITPoints = {
{XNLStationid=0, x=294.46011352539, y=-1203.5991210938, z=38.902496337891, h=90.168075561523},
{XNLStationid=1, x=-294.76913452148, y=-303.44619750977, z=10.063159942627, h=185.19216918945},
{XNLStationid=2, x=-839.20843505859, y=-151.43312072754, z=19.950380325317, h=298.70877075195},
{XNLStationid=3, x=-1337.9787597656, y=-488.36145019531, z=15.045375823975, h=28.487064361572},
{XNLStationid=4, x=-474.07037353516, y=-673.10729980469, z=11.809032440186, h=81.799621582031},
{XNLStationid=5, x=-222.13038635254, y=-1054.5043945313, z=30.139930725098, h=155.81954956055},
{XNLStationid=6, x=133.13328552246, y=-1739.5617675781, z=30.109495162964, h=231.40335083008},
{XNLStationid=7, x=-550.79998779297, y=-1302.4467773438, z=26.901605606079, h=155.53070068359},
{XNLStationid=8, x=-891.87664794922, y=-2342.6486816406, z=-11.732737541199, h=353.59387207031},
{XNLStationid=9, x=-1099.6376953125, y=-2734.8957519531, z=-7.410129070282, h=314.91424560547}
}
-- This is all our "Stop" station for the metro.
local MetroTrainstops = {
-- Los Santos AirPort (airport front door entrance)
{x=-1088.627, y=-2709.362, z=-7.137033},
{x=-1081.309, y=-2725.259, z=-7.137033},
-- Los Santos AirPort (car park/highway entrance)
{x=-889.2755, y=-2311.825, z=-11.45941},
{x=-876.7512, y=-2323.808, z=-11.45609},
-- Little Seoul (near los santos harbor)
{x=-545.3138, y=-1280.548, z=27.09238},
{x=-536.8082, y=-1286.096, z=27.08238},
-- Strawberry (near strip club)
{x=270.2029, y=-1210.818, z=39.25398},
{x=265.3616, y=-1198.051, z=39.23406},
-- Rockford Hills (San Vitus Blvd)
{x=-286.3837, y=-318.877, z=10.33625},
{x=-302.6719, y=-322.995, z=10.33629},
-- Rockford Hills (Near golf club)
{x=-826.3845, y=-134.7151, z=20.22362},
{x=-816.7159, y=-147.4567, z=20.2231},
-- Del Perro (Near beach)
{x=-1351.282, y=-481.2916, z=15.318},
{x=-1341.085, y=-467.674, z=15.31838},
-- Little Seoul
{x=-496.0209, y=-681.0325, z=12.08264},
{x=-495.8456, y=-665.4668, z=12.08244},
-- Pillbox Hill (Downtown)
{x=-218.2868, y=-1031.54, z=30.51112},
{x=-209.6845, y=-1037.544, z=30.50939},
-- Davis (Gang / hood area)
{x=112.3714, y=-1729.233, z=30.24097},
{x=120.0308, y=-1723.956, z=30.31433},
}
local TicketMachines = {'prop_train_ticket_02', 'prop_train_ticket_02_tu', 'v_serv_tu_statio3_'}
local anim = "mini@atmenter"
Citizen.CreateThread(function()
function LoadTrainModels() -- f*ck your rails, too!
tempmodel = GetHashKey("freight")
RequestModel(tempmodel)
while not HasModelLoaded(tempmodel) do
RequestModel(tempmodel)
Citizen.Wait(0)
end
tempmodel = GetHashKey("freightcar")
RequestModel(tempmodel)
while not HasModelLoaded(tempmodel) do
RequestModel(tempmodel)
Citizen.Wait(0)
end
tempmodel = GetHashKey("freightgrain")
RequestModel(tempmodel)
while not HasModelLoaded(tempmodel) do
RequestModel(tempmodel)
Citizen.Wait(0)
end
tempmodel = GetHashKey("freightcont1")
RequestModel(tempmodel)
while not HasModelLoaded(tempmodel) do
RequestModel(tempmodel)
Citizen.Wait(0)
end
tempmodel = GetHashKey("freightcont2")
RequestModel(tempmodel)
while not HasModelLoaded(tempmodel) do
RequestModel(tempmodel)
Citizen.Wait(0)
end
tempmodel = GetHashKey("freighttrailer")
RequestModel(tempmodel)
while not HasModelLoaded(tempmodel) do
RequestModel(tempmodel)
Citizen.Wait(0)
end
tempmodel = GetHashKey("tankercar")
RequestModel(tempmodel)
while not HasModelLoaded(tempmodel) do
RequestModel(tempmodel)
Citizen.Wait(0)
end
tempmodel = GetHashKey("metrotrain")
RequestModel(tempmodel)
while not HasModelLoaded(tempmodel) do
RequestModel(tempmodel)
Citizen.Wait(0)
end
tempmodel = GetHashKey("s_m_m_lsmetro_01")
RequestModel(tempmodel)
while not HasModelLoaded(tempmodel) do
RequestModel(tempmodel)
Citizen.Wait(0)
end
if Debug then
if Debug then print("FiveM-Trains: Train Models Loaded" ) end
end
end
LoadTrainModels()
RegisterNetEvent("StartTrain")
function StartTrain()
randomSpawn = math.random(#TrainLocations)
x,y,z = TrainLocations[randomSpawn][1], TrainLocations[randomSpawn][2], TrainLocations[randomSpawn][3] -- get some random locations for our spawn
-- For those whom are interested: The yesorno variable determines the direction of the train ;)
yesorno = math.random(0,100)
if yesorno >= 50 then -- untested, but seems to work /shrug
yesorno = true
elseif yesorno < 50 then
yesorno = false
end
Wait(100)
Train = CreateMissionTrain(math.random(0,22), x,y,z,yesorno)
if Debug then print("FiveM-Trains: Train 1 created (Freight)." ) end
while not DoesEntityExist(Train) do
Wait(800)
if Debug then print("FiveM-Trains: Waiting for Freight to be created" ) end
end
if ShowTrainBlips then
local TrainBlip = AddBlipForEntity(Train)
SetBlipSprite (TrainBlip, 660)
SetBlipDisplay(TrainBlip, 4)
SetBlipScale (TrainBlip, 0.8)
SetBlipColour (TrainBlip, 2)
SetBlipAsShortRange(TrainBlip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Train")
EndTextCommandSetBlipName(TrainBlip)
end
SetTrainCruiseSpeed(Train, 20.0)
Wait(200) -- Added a small 'waiting' while the train is loaded (to prevent the)
-- random unexplained spawning of the freight train on the Metro Rails
MetroTrain = CreateMissionTrain(24,40.2,-1201.3,31.0,true) -- these ones have pre-defined spawns since they are a pain to set up
if Debug then print("FiveM-Trains: Train 2 created (Metro)." ) end
while not DoesEntityExist(MetroTrain) do
Wait(800)
if Debug then print("FiveM-Trains: Waiting for Metro Train 1 to be created" ) end -- Also wait until the train entity has actually been created
end
if ShowTrainBlips then
local MetroBlip = AddBlipForEntity(MetroTrain)
SetBlipSprite (MetroBlip, 660)
SetBlipDisplay(MetroBlip, 4)
SetBlipScale (MetroBlip, 0.8)
SetBlipColour (MetroBlip, 2)
SetBlipAsShortRange(MetroBlip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Metro")
EndTextCommandSetBlipName(MetroBlip)
end
SetTrainCruiseSpeed(MetroTrain, 15.0)
Wait(200) -- Added a small 'waiting' while the train is loaded (to prevent the)
-- random unexplained spawning of the freight train on the Metro Rails
if UseTwoMetros == 1 then
MetroTrain2 = CreateMissionTrain(24,-618.0,-1476.8,16.2,true)
if Debug then print("FiveM-Trains: Train 3 created (Metro #2)." ) end
while not DoesEntityExist(MetroTrain2) do
Wait(800)
if Debug then print("FiveM-Trains: Waiting for Metro Train 2 to be created" ) end -- Also wait until the train entity has actually been created
end
if ShowTrainBlips then
local Metro2Blip = AddBlipForEntity(MetroTrain2)
SetBlipSprite (Metro2Blip, 660)
SetBlipDisplay(Metro2Blip, 4)
SetBlipScale (Metro2Blip, 0.8)
SetBlipColour (Metro2Blip, 2)
SetBlipAsShortRange(Metro2Blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Metro")
EndTextCommandSetBlipName(Metro2Blip)
end
SetTrainCruiseSpeed(MetroTrain2, 15.0)
end
Wait(200) -- Added a small 'waiting' while the train is loaded (to prevent the)
-- random unexplained spawning of the freight train on the Metro Rails
TrainDriverHash = GetHashKey("s_m_m_lsmetro_01")
-- By making a refrence to the drivers we can call them further on to make them invincible for example.
Driver1 = CreatePedInsideVehicle(Train, 26, TrainDriverHash, -1, 1, true)
Driver2 = CreatePedInsideVehicle(MetroTrain, 26, TrainDriverHash, -1, 1, true)
if UseTwoMetros == 1 then
Driver3 = CreatePedInsideVehicle(MetroTrain2, 26, TrainDriverHash, -1, 1, true) -- create peds for the trains
end
--=========================================================
-- XNL 'Addition': This SHOULD prevent the train driver(s)
-- from getting shot or fleeing out of the train/tram when
-- being targeted by the player.
-- We have had several instances where the tram driver just
-- teleported out of the tram to attack the player when it
-- it was targeted (even without holding a weapon).
-- I suspect that this behaviour is default in the game
-- unless you override it.
--=========================================================
SetBlockingOfNonTemporaryEvents(driver1, true)
SetPedFleeAttributes(driver1, 0, 0)
SetEntityInvincible(driver1, true)
SetEntityAsMissionEntity(Driver1, true)
SetBlockingOfNonTemporaryEvents(Driver3, true)
SetPedFleeAttributes(Driver3, 0, 0)
SetEntityInvincible(Driver3, true)
SetEntityAsMissionEntity(Driver3, true)
SetEntityAsMissionEntity(Train,true,true) -- dunno if this does anything, just throwing it in for good measure
SetEntityAsMissionEntity(MetroTrain,true,true)
SetEntityInvincible(Train, true)
SetEntityInvincible(MetroTrain, true)
if UseTwoMetros == 1 then
SetBlockingOfNonTemporaryEvents(Driver2, true)
SetPedFleeAttributes(Driver2, 0, 0)
SetEntityInvincible(Driver2, true)
SetEntityAsMissionEntity(Driver2, true)
SetEntityAsMissionEntity(MetroTrain2,true,true)
SetEntityInvincible(MetroTrain2, true)
end
-- Cleanup from memory
SetModelAsNoLongerNeeded(TrainDriverHash)
if Debug then print("FiveM-Trains: Train System Started, you are currently 'host' for the trains." ) end
end
AddEventHandler("StartTrain", StartTrain)
EverythingisK = true -- Added this because the Event isn't fully registered when the Event PlayerSpawned trigger.
end)
Citizen.CreateThread(function()
ShowedBuyTicketHelper = false
ShowedLeaveMetroHelper = false
while true do
Wait(10)
if IsPlayerNearTicketMachine then
if not IsPlayerUsingTicketMachine then
if not ShowedBuyTicketHelper then
DisplayHelpText(Message[Language]['buyticket'].." ($" .. TicketPrice .. ")")
ShowedBuyTicketHelper = true
end
else
ClearAllHelpMessages()
DisableControlAction(0, 201, true)
DisableControlAction(1, 201, true)
end
if IsControlJustPressed(0, 51) and PlayerHasMetroTicket then
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['already_got_ticket'], true)
Wait(3500) -- To avoid people 'spamming themselves' with the message popup (3500ms is 'just enough' to take the fun out of it :P)
end
if IsControlJustPressed(0, 51) and not PlayerHasMetroTicket then
IsPlayerUsingTicketMachine = true
RequestAnimDict("mini@atmbase")
RequestAnimDict(anim)
while not HasAnimDictLoaded(anim) do
Wait(1)
end
SetCurrentPedWeapon(playerPed, GetHashKey("weapon_unarmed"), true)
TaskLookAtEntity(playerPed, currentTicketMachine, 2000, 2048, 2)
Wait(500)
TaskGoStraightToCoord(playerPed, TicketMX, TicketMY, TicketMZ, 0.1, 4000, GetEntityHeading(currentTicketMachine), 0.5)
Wait(2000)
TaskPlayAnim(playerPed, anim, "enter", 8.0, 1.0, -1, 0, 0.0, 0, 0, 0)
RemoveAnimDict(animDict)
Wait(4000)
TaskPlayAnim(playerPed, "mini@atmbase", "base", 8.0, 1.0, -1, 0, 0.0, 0, 0, 0)
RemoveAnimDict("mini@atmbase")
Wait(500)
PlaySoundFrontend(-1, "ATM_WINDOW", "HUD_FRONTEND_DEFAULT_SOUNDSET", true)
RequestAnimDict("mini@atmexit")
while not HasAnimDictLoaded("mini@atmexit") do
Wait(1)
end
TaskPlayAnim(playerPed, "mini@atmexit", "exit", 8.0, 1.0, -1, 0, 0.0, 0, 0, 0)
RemoveAnimDict("mini@atmexit")
Wait(500)
--=====================================================================================
-- Put here the actual 'reader'/function that your server uses
-- to calculate/get the players bank account saldo and cash money!
-- Now they are just set 'hardcoded' to an high amount to make the
-- script work for people whom don't read a single line of code
-- and then instantly post "Hey, i can't even buy a ticket, the script is broken" :P
--
-- Nope it's NOT broken, it just needs a BIT of adapting to your server and it's
-- money handling. Since we use a custom banking system we have much different calls
-- than others might have so i've decided to put it in here like this so that it
-- functions for everyone when they want to test/try the script :)
--=====================================================================================
BankAmount = 10000 --StatGetInt("BANK_BALANCE",-1)
PlayerCashAm = 10000 --StatGetInt("MP0_WALLET_BALANCE",-1)
if PayWithBank == 1 then
XNLUserMoney = BankAmount
else
XNLUserMoney = PlayerCashAm
end
--===================================================================
-- Please note, that despite if you make your players pay with
-- cash or by bank, it will always show the selected bank popup
-- if the player doesn't have enough cash (this is NOT a bug!)
-- if you want/need it differently you can adapt the code bellow ;)
--==================================================================
if XNLUserMoney < TicketPrice then
if UserBankIDi == 1 then -- Maze Bank
BankIcon = "CHAR_BANK_MAZE"
BankName = "Maze Bank"
end
if UserBankIDi == 2 then -- Bank Of Liberty
BankIcon = "CHAR_BANK_BOL"
BankName = "Bank Of Liberty"
end
if UserBankIDi == 3 then -- Fleeca (Default Fallback to!)
BankIcon = "CHAR_BANK_FLEECA"
BankName = "Fleeca Bank"
end
SMS_Message(BankIcon, BankName, Message[Language]['account_information'], Message[Language]['account_nomoney'], true)
else
if PayWithBank == 1 then
-- Put YOUR code to deduct the amount from the players BANK account here
-- 'Basic Example': PlayerBankMoney = PlayerBankMoney - TicketPrice
else
-- Put YOUR code to deduct the amount from the players CASH money account here
-- 'Basic Example': PlayerCash = PlayerCash - TicketPrice
end
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['ticket_purchased'], true)
PlayerHasMetroTicket = true
end
IsPlayerUsingTicketMachine = false
end
else
ShowedBuyTicketHelper = false
end
-- E/Action key (There will only be checked for trains when the player presses the action key)
-- This Section is used to ENTER the Metro
if IsControlJustPressed(0, 51) then
playerPed = PlayerPedId()
x,y,z = table.unpack(GetEntityCoords(playerPed, true))
IsPlayerInVehicle = IsPedInAnyVehicle(playerPed, true)
SkipReEnterCheck = false
if IsPlayerInMetro then
if XNLCanPlayerExitTrain() then
if not XNLTeleportPlayerToNearestMetroExit() then
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['stop_toolate'], true)
end
SkipReEnterCheck = true -- This variable is used to prevent the character from directly trying to re-enter the Metro after leaving it.
else
XNLGenMess = "Sir"
if XNLIsPedFemale(playerPed) then
XNLGenMess = "Miss"
end
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['sorry'].." "..Message[Language][XNLGenMess].." "..Message[Language]['exit_metro_random'], true)
end
end
--===============================================
-- Make sure the player is NOT in a vehicle and
-- NOT already on the Metro
--===============================================
if not IsPlayerNearMetro and not IsPlayerInMetro and not SkipReEnterCheck then
if not IsPlayerInVehicle then
local coordA = GetEntityCoords(GetPlayerPed(-1), 1)
local coordB = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, 3.0, 0.0)
local Metro = getVehicleInDirection(coordA, coordB)
if DoesEntityExist(Metro) then
if GetEntityModel(Metro) == GetHashKey("metrotrain") then
if not PlayerHasMetroTicket then
--==========================================================================
-- Notify the player he/she needs to buy a ticket before entering the metro
--==========================================================================
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['need_ticket'], true)
else
if IsPlayerWantedLevelGreater(PlayerId(), 0) and AllowEnterTrainWanted == 0 then
--==========================================================================
-- If the player's wanted level is greater than 0, he/she will be
-- denied to ENTER the Metro.
-- If he/she GETS WHILE wanted on the train, we will handle that furher on
--==========================================================================
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['have_wantedlevel'], true)
else
CurrentMetro = Metro
IsPlayerNearMetro = true
if FreeWalk then
MetroX, MetroY, MetroZ = table.unpack(GetOffsetFromEntityInWorldCoords(CurrentMetro, 0.0, 0.0, 0.0))
SetEntityCoordsNoOffset(PlayerPedId(), MetroX, MetroY, MetroZ + 2.0)
else
SetPedIntoVehicle(GetPlayerPed(-1), CurrentMetro, 1)
end
IsPlayerInMetro = true
PlayerHasMetroTicket = false
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['entered_metro'], true)
end
end
else
IsPlayerNearMetro = false
end
else
IsPlayerNearMetro = false
end
else
if not DoesEntityExist(CurrentMetro) then
IsPlayerNearMetro = false
else
if GetDistanceBetweenCoords(x,y,z, MetroX, MetroY, MetroZ, true) > 3.5 then
IsPlayerNearMetro = false
end
end
end
end
end
--=============================================================
-- Check if the player is in the Metro AND pressed the [E] key
--=============================================================
if IsPlayerInMetro then
if ReportTerroristOnMetro == true then
if GetPlayerWantedLevel(PlayerId()) < 4 then
if IsPedShooting(GetPlayerPed(-1)) then
SetPlayerWantedLevel(PlayerId(), 4, 0)
SetPlayerWantedLevelNow(PlayerId(), 0)
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['terrorist'], true)
end
end
end
if not DoesEntityExist(CurrentMetro) then
-- Not ANY clue on when this might happen haha, but it's a funny message and error handler in one :Phone_SoundSet_Default
-- we have seen it happen once or so in MANY test rounds of the metro system that the metro just vanished, so this is to
-- 'encounter' that POSSIBLE issue (which I presume has to do with de-syncing or so)
IsPlayerNearMetro = false
IsPlayerInMetro = false
PlayerHasMetroTicket = true
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['no_metro_spawned'], true)
else
if IsPlayerInMetro then
-- This will ensure that it will only show the 'how to leave metro' text while near/at a station
if ShowingExitMetroMessage == true and not ShowedLeaveMetroHelper then
DisplayHelpText("Press ~INPUT_CONTEXT~ to leave the metro")
ShowedLeaveMetroHelper = true
end
-- This part detects if the player is further away than 15.0 units from the Metro he/she used
MetroX, MetroY, MetroZ = table.unpack(GetOffsetFromEntityInWorldCoords(CurrentMetro, 0.0, 0.0, 0.0))
x,y,z = table.unpack(GetEntityCoords(playerPed, true))
if GetDistanceBetweenCoords(x,y,z, MetroX, MetroY, MetroZ, true) > 15.0 then
IsPlayerNearMetro = false
IsPlayerInMetro = false
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['travel_metro'], true)
end
end
end
end
end
end)
Citizen.CreateThread(function()
--=======================================================================================
-- Note only do this 'check' every 550ms to prevent
-- to much load in the game (taking in account many other scripts also running of course)
--=======================================================================================
ShowedEToEnterMetro = false
while true do
Wait(550)
if IsPlayerInMetro then
if XNLCanPlayerExitTrain() then
ShowingExitMetroMessage = true
else
ShowingExitMetroMessage = false
ShowedLeaveMetroHelper = false
end
ShowedEToEnterMetro = false
end
-- We only have to check this part if the player is NOT on the metro.
if not IsPlayerInMetro then
playerPed = PlayerPedId()
IsPlayerInVehicle = IsPedInAnyVehicle(playerPed, true)
-- And then ONLY check it if the player isn't in a vehicle either
-- Note: The way i'm using the metro, the game doesn't recognize it as being
-- on/in a vehicle.
if not IsPlayerInVehicle then
-- Yes, yes I know, the function is called 'XNLCanPlayerEXITTrain', but it
-- is also used to detect if the player is at one of the stations on foot :)
if PlayerHasMetroTicket and XNLCanPlayerExitTrain() then
if not ShowedEToEnterMetro then
DisplayHelpText(Message[Language]['press_to_enter'])
ShowedEToEnterMetro = true
end
else
ShowedEToEnterMetro = false
end
-- Only show the "Press [E] to buy...." message near the ticket machine if the player does NOT own a ticket already
-- Do note that it IS possible to 'activate' the ticket machine again though (but will give a different message ;) )
x,y,z = table.unpack(GetEntityCoords(playerPed, true))
-- And then only need to keep checking (scanning cords) if the player is not near the Ticket Machine (anymore)
if not IsPlayerNearTicketMachine then
for k,v in pairs(TicketMachines) do
TicketMachine = GetClosestObjectOfType(x, y, z, 0.75, GetHashKey(v), false)
if DoesEntityExist(TicketMachine) then
currentTicketMachine = TicketMachine
TicketMX, TicketMY, TicketMZ = table.unpack(GetOffsetFromEntityInWorldCoords(TicketMachine, 0.0, -.85, 0.0))
IsPlayerNearTicketMachine = true
end
end
else
if not DoesEntityExist(currentTicketMachine) then
IsPlayerNearTicketMachine = false -- If for some (weird) reasons the ticked machine (suddenly)
else --doesn't exist anymore, tell the script that the player isn't near one anymore
if GetDistanceBetweenCoords(x,y,z, TicketMX, TicketMY, TicketMZ, true) > 2.0 then
IsPlayerNearTicketMachine = false -- And do the same if the player is more than a radius of 2.0 away from the ticket machine
end
end
end
end
end
end
end)
-- This is the function which is used to display 'SMS Style messages'
-- If you need more/other icons to display, then make sure to check out:
-- https://wiki.gtanet.work/index.php?title=Notification_Pictures
-- YES YES, I KNOW! it's 'a competitor' :P but it's definitly a good
-- resource for fellow modders :)
function SMS_Message(NotiPic, SenderName, Subject, MessageText, PlaySound)
SetNotificationTextEntry("STRING")
AddTextComponentString(MessageText)
SetNotificationBackgroundColor(140)
SetNotificationMessage(NotiPic, NotiPic, true, 4, SenderName, Subject, MessageText)
DrawNotification(false, true)
if PlaySound then
PlaySoundFrontend(GetSoundId(), "Text_Arrive_Tone", "Phone_SoundSet_Default", true)
end
end
-- This is the text 'helper' which is used at the top left for messages like 'Press [E] to buy ticket ($25)'
function DisplayHelpText(str)
SetTextComponentFormat("STRING")
AddTextComponentString(str)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
EndTextCommandDisplayHelp(0, 0, true, 2000)
end
-- Using a RayCast to detect if the player is trying to get into the train
-- This is needed since it's not possible (yet) to detect the train model with
-- the normal native calls
function getVehicleInDirection(coordFrom, coordTo)
local rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, GetPlayerPed(-1), 0)
local a, b, c, d, vehicle = GetRaycastResult(rayHandle)
return vehicle
end
--==============================================
-- Simple yet effective function to check if
-- player is female or male (sine we only use
-- mp_f_freemode_01 and mp_m_freemode_01 on our
-- server) We need(ed) this function because for
-- some weird reason IsPedMale had some issues
-- with some scripts.
--==============================================
function XNLIsPedFemale(ped)
if IsPedModel(ped, 'mp_f_freemode_01') then
return true
else
return false
end
end
function XNLCanPlayerExitTrain()
playerPed = PlayerPedId()
for _, item in pairs(XNLMetroScanPoints) do
Px,Py,Pz = table.unpack(GetEntityCoords(playerPed, true))
if GetDistanceBetweenCoords(Px,Py,Pz, item.x, item.y, item.z, true) < StationsExitScanRadius then
return true -- The function DID detected the player within one of the radius markers at the stations
end
end
return false -- The function did NOT detected the player within one of the radius markers at the stations
end
function XNLTeleportPlayerToNearestMetroExit()
playerPed = PlayerPedId()
for _, item in pairs(XNLMetroScanPoints) do
Px,Py,Pz = table.unpack(GetEntityCoords(playerPed, true))
if GetDistanceBetweenCoords(Px,Py,Pz, item.x, item.y, item.z, true) < StationsExitScanRadius then
for _, item2 in pairs(XNLMetroEXITPoints) do
if item.XNLStationid == item2.XNLStationid then
DoScreenFadeOut(800)
while not IsScreenFadedOut() do
Wait(10)
end
XNLNewX = item2.x -- The 'new' Player X position
XNLNewY = item2.y -- The 'new' Player Y position
XNLNewZ = item2.z -- The 'new' Player Z position
XNLNewH = item2.h -- The 'new' Player Heading Direction
SetEntityCoordsNoOffset(PlayerPedId(), XNLNewX, XNLNewY, XNLNewZ)
SetEntityHeading(PlayerPedId(), XNLNewH)
DoScreenFadeIn(800)
while not IsScreenFadedIn() do
Wait(10)
end
return true
end
end
end
end
return false -- The function did NOT detected the player within one of the radius markers at the stations
end
Citizen.CreateThread(function()
while EverythingisK == false do Citizen.Wait(0) end
while true do
Citizen.Wait(0)
local closest = 10
if DoesEntityExist(MetroTrain) then
if not MetroTrainStopped[MetroTrain] then
local coords = GetEntityCoords(MetroTrain)
if coords then
for k,v in ipairs(MetroTrainstops) do
if GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) <= closest then
StopTrain(MetroTrain)
end
end
end
end
end
if DoesEntityExist(MetroTrain2) then
if not MetroTrainStopped[MetroTrain2] then
local coords = GetEntityCoords(MetroTrain2)
if coords then
for k,v in ipairs(MetroTrainstops) do
if GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) <= closest then
StopTrain(MetroTrain2)
end
end
end
end
end
end
end)
function StopTrain(train)
if (NetworkHasControlOfEntity(train)) then
table.insert(MetroTrainStopped, train)
SetTrainCruiseSpeed(train, 0.0) -- We stop the train
Citizen.Wait(100)
if train ~= nil then
local stoppedTimer = GetGameTimer();
repeat
Citizen.Wait(0)
until GetEntitySpeed(train) <= 0
while (GetGameTimer() - stoppedTimer < (20 * 1000)) do -- We stop the train for 20 sec. With a Citizen.wait, our variable is destroyed. So we need to keep up.
Citizen.Wait(0)
end
end
Citizen.Wait(100)
SetTrainCruiseSpeed(train, 15.0) -- Bye bye train !
local timer = GetGameTimer();
while (GetGameTimer() - timer < 5000) do -- After 5 sec, we can tell that train have "finished" their stop.
removebyKey(MetroTrainStopped, train)
Citizen.Wait(0)
end
end
end
-- Added for OneSync
local firstspawn = 0 -- By default, Its the first spawn of the player. So, I don't recommend to restart the script with already player in the server.
AddEventHandler('playerSpawned', function()
while EverythingisK == false do Citizen.Wait(0) end -- The Event "StartTrain" is fully registered. We can continue now.
if firstspawn == 0 then -- First spawn of the player ? Check if they are already trains
TriggerServerEvent('FiveM-Trains:PlayerSpawned')
firstspawn = 1 -- Just for making not trigger the event if he respawn after die.
end
end)
-- This is added if we restart the ressource.
-- Needed for the dev. May be I will remove it later.
-- This remove all train
AddEventHandler('onResourceStop', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then
return
end
DeleteMissionTrain(MetroTrain)
DeleteMissionTrain(MetroTrain2)
DeleteMissionTrain(Train)
end)

View file

@ -0,0 +1,7 @@
function removebyKey(tab, val)
for i, v in ipairs (tab) do
if (v == val) then
tab[i] = nil
end
end
end

View file

@ -0,0 +1,47 @@
--=============================================================
-- Settings you CAN change and are meant to be changed, YAY :P
-- I do NOT use these on my server but have implemented it for
-- other users to make it more easy to adapt to their roleplay
-- server for example.
--=============================================================
Language = 'en' -- Language used in the script
-- Language available actually :
-- en (English)
-- fr (French)
-- es (Spanish)
ShowTrainBlips = true -- If you want to show Train's Blips on the map
FreeWalk = true -- If you want people can walk around in the train, set true or false if you prefer they sit in the train (experimental)
PayWithBank = 25 -- Change this to 1 if you want users to pay with bank card (NOTE: Do implement your OWN banking system here please!)
UserBankIDi = 3 -- 1 = Maze, 2 = Bank Of Liberty, 3 = Fleeca (This will show the corresponding message when the player doesn't have enoug money)
AllowEnterTrainWanted = 1 -- Change to 1 if you want to allow players to ENTER the train when they have a wanted level
-- The wanted level WILL NOT WORK if you desactivated it (With EssentialMode for example)
TicketPrice = 25 -- Change to any value YOU think is suitable for a Metro Ticket in your (RP) Server
StationsExitScanRadius = 15.0 -- I would RECOMMEND to leave it at 15 for best detection in trains, this variable sets the 'scan radius size' per station marker.
-- NOTE: The StationsExitScanRadius HAS TO BE A FLOAT! (15.0 for example (which is the default!))
UseTwoMetros = 1 -- KEEP IN MIND: When using two Metro's, players on one of the trams CAN be 'thrown out' when the trams pass eachother
-- since the Metro's will PASS THROUGH EACH OTHER at some point! (this is inevitable! since the Metro track is just ONE TRACK!)
-- it looks like they are two tracks in the game, but at both ends it will make a large 'u turn'!
-- so if you do NOT want your players to be thrown out (and POSSIBLY killed) by a Metro, then set this value to 0!
-- When set to 0, the script will only spawn ONE Metro Train instead of two (each in opposite direction)
ReportTerroristOnMetro = true -- When set to true the player will get an INSTANT wanted level of 4 when shooting on the Metro,
-- this to 'contribute' to 'terroristic behavior' realism on (Real-Life) RP servers (where it's not normal either to
-- just (randomly) shoot while on/in public transportation!) if you want to ENABLE shooting from the Metro (as passenger)
-- then change this value to false
Debug = true -- Do you want some debug message ?
-- These are the locations of which 'the host' (well his/her script) will
-- pick a random location to spawn a new (Freight) train
TrainLocations = {
{2533.0,2833.0,38.0},
{2606.0,2927.0,40.0},
{2463.0,3872.0,38.8},
{1164.0,6433.0,32.0},
}
-- You don't need to modify below.
Message = {}

View file

@ -0,0 +1,19 @@
client_scripts {
'config.lua',
'Locales/en.lua',
'Locales/es.lua',
'Locales/fr.lua',
'client/function.lua',
'client/client.lua'
}
server_scripts {
'config.lua',
'server/server.lua'
}
this_is_a_map 'yes'
fx_version 'adamant'
game 'gta5'
description 'FiveM Trains System'

View file

@ -0,0 +1,67 @@
--========================================================================
-- Original from:
-- Original Post: https://forum.fivem.net/t/release-trains/28841
-- Original Script: https://github.com/Bluethefurry/FiveM-Trains/releases
-- Rework : https://forum.cfx.re/t/release-fivem-freight-train-ai-and-enterable-trams-as-passenger-suited-for-roleplay-to/268613
--========================================================================
local trainspawned = false
local trainHost = nil
local choosingRandom = nil
RegisterServerEvent("FiveM-Trains:PlayerSpawned")
AddEventHandler('FiveM-Trains:PlayerSpawned', function()
local _source = source
SpawnTrain(_source)
end)
RegisterServerEvent("playerDropped")
AddEventHandler('playerDropped', function()
local _source = source
if trainHost == _source then -- If the host of the train is the source, the train disapear with him.
local name = GetPlayerName(_source)
if Debug then print(('FiveM-Trains: Player %s with id %i has quit. Looking for another host for the trains...'):format(name,_source)) end
trainspawned = false
trainHost = nil
ChooseRandomPlayer(_source) -- We choose a random player for spawning the train
end
end)
-- Not sure if it will work
-- Need more test
RegisterServerEvent("FiveM-Trains:SelectRandomPlayer")
AddEventHandler('FiveM-Trains:SelectRandomPlayer', function()
if not choosingRandom then
choosingRandom = source
ChooseRandomPlayer(0) -- We choose a random player for spawning the train
end
end)
function ChooseRandomPlayer(leaver)
local hostfound = false
for _, playerId in ipairs(GetPlayers()) do -- Yeah, pretty bad "random". We just take the first player we get in the list
if tonumber(playerId) ~= tonumber(leaver) then -- Actually, the player is still in the list of players, even if he leaved the game, so we ignore him
SpawnTrain(playerId)
hostfound = true
choosingRandom = nil
break -- Don't need to let the for continue. We stop it.
end
end
if not hostfound then
if Debug then print('FiveM-Trains: No host are available for the trains. Waiting for another player to join the server...') end
end
end
function SpawnTrain(player)
if not trainHost then -- If we have a host for the train, trainHost should be not nil
if not trainspawned then -- new session or the host has leave ?
local name = GetPlayerName(player)
if Debug then print(('FiveM-Trains: Player %s with id %i will be the host for the trains'):format(name,player)) end
TriggerClientEvent('StartTrain', tonumber(player))
trainspawned = true
trainHost = player
end
end
end

View file

@ -1,488 +0,0 @@
--[[
=====================================================================================================================================
License, Credits, Basic information, FAQ
=====================================================================================================================================
Based on/inspired by:
Blumlaut (FiveM Community) / Bluethefurry (Github)
Original Post: https://forum.fivem.net/t/release-trains/28841
Original Script: https://github.com/Bluethefurry/FiveM-Trains/releases
Last Updated: 02-01-2024
(Re-)Created by: VenomXNL
License: Use it as you please but do have decency and respect by crediting the original creators :)
What is it?: A very extensive Train and (well mostely) Metro Addon for FiveM
===================================================================================================================================================================
2024 Update:
===================================================================================================================================================================
This script has been updated ONCE now because suddenly lots of people started making requests for it again, this is however a ONE TIME UPDATE!
I don't script/mod/develop for FiveM anymore, but did wanted to help the community out a bit with this update, because the guy who took over from me
also has left FiveM (as it seems).
I will however NOT provide future support on this script, because I REALLY don't have the time for these games (like FiveM etc) lately.
It is intended to configure and adapt a bit for YOUR OWN server, so please read the comments and instruction to do so :)
NOTE: The code might (is) still a bit messy, but that is because (like mentioned) I seriously lack the time to work on projects like this these days,
I have just scrapped and 're-written' large portions of my old version and modified it to a MUCH simpler approach, and had to do this with lots of 'forgotten
knowledge' after not having scripted for FiveM for many years. So please keep that in mind please :)
===================================================================================================================================================================
Basic Functionality list:
- Activates the 'normal game trains'
- Players can WALK AROUND in the moving Metro, just by walking in :)
- Players HAVE to buy a Metro Ticket to enter (With (ATM) animated Ticket machine handling), otherwise they will get a 1 star wanted level for illegal boarding.
- Ticket will 'invalidate' when they have left the metro (even if it's at the same station!) so they will have to buy a new one
- 'terrorist detection', which means if players shoot while on the train they will get a 4 star wanted level
- Easily configurable with basic variables
- Different Bank Messages (for Maze Bank, Bank of Liberty or Fleeca bank)
Known 'bugs' or 'issues':
- From the inside the doors of the Metro are invisible and you can walk straight through them (and thus also while the train is moving!)
and they even seem to dissapear if you walk through them if they are closed, this seems to be a 'model issue' with the vehicle,
not sure though and don't have time to figure this out sorry!
- The ticket machines above ground (the green/old ones) DO NOT WORK, I tried for several hours to find them in the archives but
with no luck. I however did find one that looks like it, but that one doesn't respond at all.
I MIGHT update that when someone can tell me the model of that ticket machine object, however for now I have left it at that.
Also because the original game-texture says: "Sorry, this machine will NEVER work", so i thought: lets keep it in lore :P (nice excuse huh? haha)
Possible Questions:
- Q: Can I use this on my server?
- A: Sure you can that's why I've uploaded it :)
- Q: Can you please help me add or make my money/banking system?
- A: No, sorry. I'm VERY busy with me job and other projects, I decided to share my code's_m_m_lsmetro_01
to public for others to use, possibly adapt and for others to learn from them (hence the massive commenting!).
I have learned it the same way years ago: Looking at other people's codes and trying what would change things or
make it do what I wanted it to do.
- Q: So you're basically saying I "just need to learn" to script/program?
- A: YES, if you would like to run servers and games like this, and thus use mods, it's DEFINITLY a MUST if you can,
it might look hard in the beginning, but trust me: You will be thankful if you learn it yourself :)
- Q: But you also stated that I can adapt your code right?
- A: Sure, adapt, improve, or even 'strip(remove) stuff from it' to make it suit your needs
NOTE: Please do not just 'destroy the code' by randomly doing stuff and then posting stuff like:
'I "changed" this, and now your code doesn't work anymore'. If that happens I suggest you keep trying
till it DOES what you need, investigate about the Native codes, look on other sites for resources and
information, you can ofcourse ask questions, no problem. Just keep in mind that I'm not going to (not even
able to due to my schedule IF I wanted to)) script all kinds of things for everyone randomly ;) :)
- Q: One more question though: If I can adapt your code, am I also allowed to re-upload it?
- A: Yes you are! :) BUT please do give credits to me and the original creator on whom's idea this
scripted was based and inspired on. (AKA: It's NOT allowed to reupload/publish without credits where due)
General adivce (applies to ALL uploading coders):
If this script/addon doesn't do what you wanted it to do, if you think it's "sh*tty" etc, that's all fine, but
just keep that to yourself and find another one that suits your needs (or even better: Make it yourself) ;)
Keep in mind that people upload code to help/provide others in resources and learning matterial, and that doing so
costs (extra) time. Time they took to provide you (and many others) with resources, code, samples and addons.
Contribute, help, share and evolve together, that's the power of a community :)
(Ofcourse doesn't mean that constructive critisim isn't welcome or desired (since we all will always have points of
improvement :) )
=================================== Money Handling Information ===================================
If the rest if TL;DR, fine, your problem ;) :P (Don't nag either if you can't figure it out haha)
But ATLEAST do read this piece for setup! and IF you have questions, or if want to Adapt or
re-publish/upload it: Don't be stubborn, respect other peoples work, and DO read the above ;)
===================================================================================================
IMPORTANT NOTE: Bellow 'somewhere' in the code you will find these two lines:
BankAmount = 10000 --StatGetInt("BANK_BALANCE",-1)
PlayerCashAm = 10000 --StatGetInt("MP0_WALLET_BALANCE",-1)
Make sure that you adapt them to YOUR OWN SERVER, since like stated there (in the script to),
many servers use a different money management system, and thus it's not quite possible to make
one that is 'general in use' for all. We use one that doesn't uses the game stats at all (since thats
to easy to influence with cheat programs for example). To make sure that people could test/try this
script i have set the INTERNAL SCRIPT money values to very high (those DO NOT affect the player itself though!)
This also means that there is no money being taken from the player when he/she buy's a ticket
To make sure that money is taken from the player when buying a ticked you will need to find the following code part:
if PayWithBank == 1 then
-- Put YOUR code to deduct the amount from the players BANK account here
-- 'Basic Example': PlayerBankMoney = PlayerBankMoney - TicketPrice
else
-- Put YOUR code to deduct the amount from the players CASH money account here
-- 'Basic Example': PlayerCash = PlayerCash - TicketPrice
end
And add your OWN SERVER money handling/taking code here
I hope this code/addon is usefull for some people or that they might learn from it by using parts of it :)
Greets,
VenomXNL
=====================================================================================================================================
]]
--===================================================
-- Variables used BY the script, do NOT modify them
-- unless you know what you are doing!
-- Modifying these might/will result in undesired
-- behaviour and/or script breaking!
--===================================================
IsPlayerNearMetro = false
IsPlayerInMetro = false
PlayerHasMetroTicket = false
IsPlayerUsingTicketMachine = false
ShowingExitMetroMessage = false
--===================================================
-- These are radius locations (multiple per station)
-- to detect if the player can exit the Metro
--===================================================
local XNLMetroScanPoints = {
{XNLStationid=0, x=230.82389831543, y=-1204.0643310547, z=38.902523040771},
{XNLStationid=0, x=249.59216308594, y=-1204.7095947266, z=38.92488861084},
{XNLStationid=0, x=270.33166503906, y=-1204.5366210938, z=38.902912139893},
{XNLStationid=0, x=285.96697998047, y=-1204.2261962891, z=38.929733276367},
{XNLStationid=0, x=304.13528442383, y=-1204.3720703125, z=38.892612457275},
{XNLStationid=1, x=-294.53421020508, y=-353.38571166992, z=10.063089370728},
{XNLStationid=1, x=-294.96997070313, y=-335.69766235352, z=10.06309223175},
{XNLStationid=1, x=-294.66772460938, y=-318.29565429688, z=10.063152313232},
{XNLStationid=1, x=-294.73403930664, y=-303.77200317383, z=10.063160896301},
{XNLStationid=1, x=-294.84133911133, y=-296.04568481445, z=10.063159942627},
{XNLStationid=2, x=-795.28063964844, y=-126.3436050415, z=19.950298309326},
{XNLStationid=2, x=-811.87170410156, y=-136.16409301758, z=19.950319290161},
{XNLStationid=2, x=-819.25689697266, y=-140.25764465332, z=19.95037651062},
{XNLStationid=2, x=-826.06652832031, y=-143.90898132324, z=19.95037651062},
{XNLStationid=2, x=-839.2587890625, y=-151.32421875, z=19.950378417969},
{XNLStationid=2, x=-844.77874755859, y=-154.31440734863, z=19.950380325317},
{XNLStationid=3, x=-1366.642578125, y=-440.04803466797, z=15.045327186584},
{XNLStationid=3, x=-1361.4998779297, y=-446.50497436523, z=15.045324325562},
{XNLStationid=3, x=-1357.4061279297, y=-453.40963745117, z=15.045320510864},
{XNLStationid=3, x=-1353.4593505859, y=-461.88238525391, z=15.045323371887},
{XNLStationid=3, x=-1346.1264648438, y=-474.15142822266, z=15.045383453369},
{XNLStationid=3, x=-1338.1717529297, y=-488.97756958008, z=15.045383453369},
{XNLStationid=3, x=-1335.0261230469, y=-493.50796508789, z=15.045380592346},
{XNLStationid=4, x=-530.67529296875, y=-673.33935546875, z=11.808959960938},
{XNLStationid=4, x=-517.35559082031, y=-672.76635742188, z=11.808965682983},
{XNLStationid=4, x=-499.44836425781, y=-673.37664794922, z=11.808973312378},
{XNLStationid=4, x=-483.1321105957, y=-672.68438720703, z=11.809024810791},
{XNLStationid=4, x=-468.05545043945, y=-672.74371337891, z=11.80902671814},
{XNLStationid=5, x=-206.90379333496, y=-1014.9454345703, z=30.138082504272},
{XNLStationid=5, x=-212.65534973145, y=-1031.6101074219, z=30.208702087402},
{XNLStationid=5, x=-212.65534973145, y=-1031.6101074219, z=30.208702087402},
{XNLStationid=5, x=-217.0216217041, y=-1042.4768066406, z=30.573789596558},
{XNLStationid=5, x=-221.29409790039, y=-1054.5914306641, z=30.13950920105},
{XNLStationid=6, x=101.89681243896, y=-1714.7589111328, z=30.112174987793},
{XNLStationid=6, x=113.05246734619, y=-1724.7247314453, z=30.111650466919},
{XNLStationid=6, x=122.72943878174, y=-1731.7276611328, z=30.54141998291},
{XNLStationid=6, x=132.55198669434, y=-1739.7276611328, z=30.109527587891},
{XNLStationid=7, x=-532.24133300781, y=-1263.6896972656, z=26.901586532593},
{XNLStationid=7, x=-539.62115478516, y=-1280.5207519531, z=26.908163070679},
{XNLStationid=7, x=-545.18548583984, y=-1290.9525146484, z=26.901586532593},
{XNLStationid=7, x=-549.92230224609, y=-1302.8682861328, z=26.901605606079},
{XNLStationid=8, x=-872.75714111328, y=-2289.3198242188, z=-11.732793807983},
{XNLStationid=8, x=-875.53247070313, y=-2297.67578125, z=-11.732793807983},
{XNLStationid=8, x=-880.05035400391, y=-2309.1235351563, z=-11.732788085938},
{XNLStationid=8, x=-883.25482177734, y=-2321.3303222656, z=-11.732738494873},
{XNLStationid=8, x=-890.087890625, y=-2336.2553710938, z=-11.732738494873},
{XNLStationid=8, x=-894.92395019531, y=-2350.4128417969, z=-11.732727050781},
{XNLStationid=9, x=-1062.7882080078, y=-2690.7492675781, z=-7.4116077423096},
{XNLStationid=9, x=-1071.6839599609, y=-2701.8503417969, z=-7.410071849823},
{XNLStationid=9, x=-1079.0869140625, y=-2710.7033691406, z=-7.4100732803345},
{XNLStationid=9, x=-1086.8758544922, y=-2720.0673828125, z=-7.4101362228394},
{XNLStationid=9, x=-1095.3796386719, y=-2729.8442382813, z=-7.4101347923279},
{XNLStationid=9, x=-1103.7401123047, y=-2740.369140625, z=-7.4101300239563}
}
local TicketMachines = {'prop_train_ticket_02', 'prop_train_ticket_02_tu', 'v_serv_tu_statio3_'}
local anim = "mini@atmenter"
Citizen.CreateThread(function()
-- All the code now spawns trains (using the normal ingame engine to do it instead of letting it get handled by one player)
SwitchTrainTrack(0, true) -- Main train track(s) around LS and towards Sandy Shores
SwitchTrainTrack(3, true) -- Metro tracks
-- NOTE: You can lower the 120000 numbers bellow to make the trains spawn more often, but this is NOT recommended!
SetTrainTrackSpawnFrequency(0, 120000) -- The Train spawn frequency set for the game engine
SetTrainTrackSpawnFrequency(3, 120000) -- The Metro spawn frequency set for the game engine
SetRandomTrains(true) -- Telling the game we want to use randomly spawned trains end)
-- 22-07-2024: Added this native which was found and reported to me by: BigHE4d
-- on the FixeM CFX.re forum, thanks mate :)
-- https://forum.cfx.re/t/release-fivem-freight-train-ai-and-enterable-trams-as-passenger-suited-for-roleplay-to/268613/255
-- NOTE: Due to me not playing FiveM for quite a while anymore, and might be quite a while until
-- I will (be able) to return, I have NOT tested this native call!
SetTrainsForceDoorsOpen(false)
end)
local PlayerDetectedInMetro = false
local UnpaidPassenger = 0
Citizen.CreateThread(function()
while true do
Wait(3000)
if IsPedOnVehicle(PlayerPedId()) then
local coordA = GetEntityCoords(GetPlayerPed(-1), 1)
local coordB = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, 0.0, -1.0)
local Metro = getVehicleInDirection(coordA, coordB)
if DoesEntityExist(Metro) then
if GetEntityModel(Metro) == GetHashKey("metrotrain") then
if PlayerDetectedInMetro == false then
PlayerDetectedInMetro = true
if PlayerHasMetroTicket == true then
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['travel_metro'], true)
end
end
if PlayerDetectedInMetro == true then
if PlayerHasMetroTicket == false then
if UnpaidPassenger < 3 then
UnpaidPassenger = UnpaidPassenger + 1
-- Warn the player he/she needs a ticket to board and travel the metro
if UnpaidPassenger == 1 then
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['no_ticket_leave'], true)
end
-- At the 'third tick' while traveling (being in the metro) without a ticket the police message will pop up but only once!
if UnpaidPassenger == 3 then
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['we_warned_you'], true)
end
end
-- Making sure the player keeps getting a 1 star wanted level if he/she doesn't have a ticket but keeps traveling with the metro
if UnpaidPassenger == 3 then
if GetPlayerWantedLevel(PlayerId()) < 1 then
SetPlayerWantedLevel(PlayerId(), 1, 0)
SetPlayerWantedLevelNow(PlayerId(), 0)
end
end
end
end
end
end
else
if PlayerDetectedInMetro == true then
UnpaidPassenger = 0
PlayerDetectedInMetro = false
if PlayerHasMetroTicket == true then
PlayerHasMetroTicket = false
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['entered_metro'], true)
end
end
end
end
end)
Citizen.CreateThread(function()
ShowedBuyTicketHelper = false
ShowedLeaveMetroHelper = false
while true do
Wait(10)
if IsPlayerNearTicketMachine then
if not IsPlayerUsingTicketMachine then
if not ShowedBuyTicketHelper then
DisplayHelpText(Message[Language]['buyticket'].." ($" .. TicketPrice .. ")")
ShowedBuyTicketHelper = true
end
else
ClearAllHelpMessages()
DisableControlAction(0, 201, true)
DisableControlAction(1, 201, true)
end
if IsControlJustPressed(0, 51) and PlayerHasMetroTicket then
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['already_got_ticket'], true)
Wait(3500) -- To avoid people 'spamming themselves' with the message popup (3500ms is 'just enough' to take the fun out of it :P)
end
if IsControlJustPressed(0, 51) and not PlayerHasMetroTicket then
IsPlayerUsingTicketMachine = true
RequestAnimDict("mini@atmbase")
RequestAnimDict(anim)
while not HasAnimDictLoaded(anim) do
Wait(1)
end
SetCurrentPedWeapon(playerPed, GetHashKey("weapon_unarmed"), true)
TaskLookAtEntity(playerPed, currentTicketMachine, 2000, 2048, 2)
Wait(500)
TaskGoStraightToCoord(playerPed, TicketMX, TicketMY, TicketMZ, 0.1, 4000, GetEntityHeading(currentTicketMachine), 0.5)
Wait(2000)
TaskPlayAnim(playerPed, anim, "enter", 8.0, 1.0, -1, 0, 0.0, 0, 0, 0)
RemoveAnimDict(animDict)
Wait(4000)
TaskPlayAnim(playerPed, "mini@atmbase", "base", 8.0, 1.0, -1, 0, 0.0, 0, 0, 0)
RemoveAnimDict("mini@atmbase")
Wait(500)
PlaySoundFrontend(-1, "ATM_WINDOW", "HUD_FRONTEND_DEFAULT_SOUNDSET", true)
RequestAnimDict("mini@atmexit")
while not HasAnimDictLoaded("mini@atmexit") do
Wait(1)
end
TaskPlayAnim(playerPed, "mini@atmexit", "exit", 8.0, 1.0, -1, 0, 0.0, 0, 0, 0)
RemoveAnimDict("mini@atmexit")
Wait(500)
--=====================================================================================
-- Put here the actual 'reader'/function that your server uses
-- to calculate/get the players bank account saldo and cash money!
-- Now they are just set 'hardcoded' to an high amount to make the
-- script work for people whom don't read a single line of code
-- and then instantly post "Hey, i can't even buy a ticket, the script is broken" :P
--
-- Nope it's NOT broken, it just needs a BIT of adapting to your server and it's
-- money handling. Since we use a custom banking system we have much different calls
-- than others might have so i've decided to put it in here like this so that it
-- functions for everyone when they want to test/try the script :)
--=====================================================================================
BankAmount = 10000 --StatGetInt("BANK_BALANCE",-1)
PlayerCashAm = 10000 --StatGetInt("MP0_WALLET_BALANCE",-1)
if PayWithBank == 1 then
XNLUserMoney = BankAmount
else
XNLUserMoney = PlayerCashAm
end
--===================================================================
-- Please note, that despite if you make your players pay with
-- cash or by bank, it will always show the selected bank popup
-- if the player doesn't have enough cash (this is NOT a bug!)
-- if you want/need it differently you can adapt the code bellow ;)
--==================================================================
if XNLUserMoney < TicketPrice then
if UserBankIDi == 1 then -- Maze Bank
BankIcon = "CHAR_BANK_MAZE"
BankName = "Maze Bank"
end
if UserBankIDi == 2 then -- Bank Of Liberty
BankIcon = "CHAR_BANK_BOL"
BankName = "Bank Of Liberty"
end
if UserBankIDi == 3 then -- Fleeca (Default Fallback to!)
BankIcon = "CHAR_BANK_FLEECA"
BankName = "Fleeca Bank"
end
SMS_Message(BankIcon, BankName, Message[Language]['account_information'], Message[Language]['account_nomoney'], true)
else
if PayWithBank == 1 then
-- Put YOUR code to deduct the amount from the players BANK account here
-- 'Basic Example': PlayerBankMoney = PlayerBankMoney - TicketPrice
else
-- Put YOUR code to deduct the amount from the players CASH money account here
-- 'Basic Example': PlayerCash = PlayerCash - TicketPrice
end
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['ticket_purchased'], true)
PlayerHasMetroTicket = true
end
IsPlayerUsingTicketMachine = false
end
else
ShowedBuyTicketHelper = false
end
if PlayerDetectedInMetro then
if ReportTerroristOnMetro == true then
if GetPlayerWantedLevel(PlayerId()) < 4 then
if IsPedShooting(GetPlayerPed(-1)) then
SetPlayerWantedLevel(PlayerId(), 4, 0)
SetPlayerWantedLevelNow(PlayerId(), 0)
SMS_Message("CHAR_LS_TOURIST_BOARD", Message[Language]['los_santos_transit'], Message[Language]['tourist_information'], Message[Language]['terrorist'], true)
end
end
end
end
end
end)
Citizen.CreateThread(function()
--=======================================================================================
-- Note only do this 'check' every 550ms to prevent
-- to much load in the game (taking in account many other scripts also running of course)
--=======================================================================================
while true do
Wait(550)
-- We only have to check this part if the player is NOT on the metro.
if not PlayerDetectedInMetro then
playerPed = PlayerPedId()
IsPlayerInVehicle = IsPedInAnyVehicle(playerPed, true)
if not IsPlayerInVehicle then
-- Only show the "Press [E] to buy...." message near the ticket machine if the player does NOT own a ticket already
-- Do note that it IS possible to 'activate' the ticket machine again though (but will give a different message ;) )
x,y,z = table.unpack(GetEntityCoords(playerPed, true))
-- And then only need to keep checking (scanning cords) if the player is not near the Ticket Machine (anymore)
if not IsPlayerNearTicketMachine then
for k,v in pairs(TicketMachines) do
TicketMachine = GetClosestObjectOfType(x, y, z, 0.75, GetHashKey(v), false)
if DoesEntityExist(TicketMachine) then
currentTicketMachine = TicketMachine
TicketMX, TicketMY, TicketMZ = table.unpack(GetOffsetFromEntityInWorldCoords(TicketMachine, 0.0, -.85, 0.0))
IsPlayerNearTicketMachine = true
end
end
else
if not DoesEntityExist(currentTicketMachine) then
IsPlayerNearTicketMachine = false -- If for some (weird) reasons the ticked machine (suddenly)
else --doesn't exist anymore, tell the script that the player isn't near one anymore
if GetDistanceBetweenCoords(x,y,z, TicketMX, TicketMY, TicketMZ, true) > 2.0 then
IsPlayerNearTicketMachine = false -- And do the same if the player is more than a radius of 2.0 away from the ticket machine
end
end
end
end
end
end
end)
-- This is the function which is used to display 'SMS Style messages'
-- If you need more/other icons to display, then make sure to check out:
-- https://wiki.gtanet.work/index.php?title=Notification_Pictures
-- YES YES, I KNOW! it's 'a competitor' :P but it's definitly a good
-- resource for fellow modders :)
function SMS_Message(NotiPic, SenderName, Subject, MessageText, PlaySound)
SetNotificationTextEntry("STRING")
AddTextComponentString(MessageText)
SetNotificationBackgroundColor(140)
SetNotificationMessage(NotiPic, NotiPic, true, 4, SenderName, Subject, MessageText)
DrawNotification(false, true)
if PlaySound then
PlaySoundFrontend(GetSoundId(), "Text_Arrive_Tone", "Phone_SoundSet_Default", true)
end
end
-- This is the text 'helper' which is used at the top left for messages like 'Press [E] to buy ticket ($25)'
function DisplayHelpText(str)
SetTextComponentFormat("STRING")
AddTextComponentString(str)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
EndTextCommandDisplayHelp(0, 0, true, 2000)
end
-- Using a RayCast to detect if the player is trying to get into the train
-- This is needed since it's not possible (yet) to detect the train model with
-- the normal native calls
function getVehicleInDirection(coordFrom, coordTo)
local rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, GetPlayerPed(-1), 0)
local a, b, c, d, vehicle = GetRaycastResult(rayHandle)
return vehicle
end
--==============================================
-- Simple yet effective function to check if
-- player is female or male (sine we only use
-- mp_f_freemode_01 and mp_m_freemode_01 on our
-- server) We need(ed) this function because for
-- some weird reason IsPedMale had some issues
-- with some scripts.
--==============================================
function XNLIsPedFemale(ped)
return IsPedModel(ped, 'mp_f_freemode_01')
end

View file

@ -1,100 +0,0 @@
--=============================================================
-- Settings you CAN change and are meant to be changed, YAY :P
-- I do NOT use these on my server but have implemented it for
-- other users to make it more easy to adapt to their roleplay
-- server for example.
--=============================================================
PayWithBank = 25 -- Change this to 1 if you want users to pay with bank card (NOTE: Do implement your OWN banking system here please!)
UserBankIDi = 3 -- 1 = Maze, 2 = Bank Of Liberty, 3 = Fleeca (This will show the corresponding message when the player doesn't have enoug money)
AllowEnterTrainWanted = 1 -- Change to 1 if you want to allow players to ENTER the train when they have a wanted level
TicketPrice = 25 -- Change to any value YOU think is suitable for a Metro Ticket in your (RP) Server
-- NOTE: The StationsExitScanRadius HAS TO BE A FLOAT! (15.0 for example (which is the default!))
ReportTerroristOnMetro = true -- When set to true the player will get an INSTANT wanted level of 4 when shooting on the Metro,
-- this to 'contribute' to 'terroristic behavior' realism on (Real-Life) RP servers (where it's not normal either to
-- just (randomly) shoot while on/in public transportation!) if you want to ENABLE shooting from the Metro (as passenger)
-- then change this value to false
Debug = true -- Do you want some debug message ?
-- There is all the messages for every action in this script
-- Language available actually :
-- en (English)
-- fr (Français)
-- es (Spanish)
Language = 'en'
Message = {}
Message['en'] = {
['we_warned_you'] = "We have warned you! Police have been notified of your illegal boarding!",
['no_ticket_leave'] = "You don't have a ticket! please leave the metro or we will need to call the police.",
['buyticket'] = "Press ~INPUT_CONTEXT~ to to buy a metro ticket",
['press_to_enter'] = "Press ~INPUT_CONTEXT~ while facing (and near) the Metro to enter it.",
['los_santos_transit'] = "Los Santos Transit",
['tourist_information'] = "Tourist Information",
['already_got_ticket'] = "You already have a valid Metro Ticket, please go to one of the stations and board the Metro",
['account_information'] = "Account Information",
['account_nomoney'] = "Transaction failed, you do not have sufficient funds.",
['ticket_purchased'] = "Thank you for your purchase, your ticket will be valid for the current session.",
['stop_toolate'] = "Sorry, it seems that you pressed a little bit to late, you'll have to wait for the next station.",
['sorry'] = "Sorry",
['exit_metro_random'] = ", but it's not allowed to randomly exit the Metro. Please wait for the next station!",
['Sir'] = "Sir",
['Miss'] = "Miss",
['need_ticket'] = "Sorry, You will need to buy a LST Metro Ticket first.",
['have_wantedlevel'] = "Sorry we do not allow futugives in our Metro's. All passengers should be able to travel safely!",
['entered_metro'] = "You've exited the Metro, your ticket has been invalidated.",
['terrorist'] = "We will NOT tolerate terrorist behaviour on our public transport vehicles!",
['no_metro_spawned'] = "Our Appologies, something has gone terribly wrong, you have received a free ticket!",
['travel_metro'] = "Thank you for traveling with Los Santos Transit, your ticket has been approved.",
}
Message['fr'] = {
['we_warned_you'] = "Nous vous avons prévenu ! La police a été informée de votre embarquement illégal !",
['no_ticket_leave'] = "Vous n'avez pas de billet ! veuillez quitter le métro ou nous devrons appeler la police.",
['buyticket'] = "Appuyez sur ~INPUT_CONTEXT~ pour acheter un ticket de Metro",
['press_to_enter'] = "Appuyez sur ~INPUT_CONTEXT~ en face (et proche) du Metro pour entrer dedans.",
['los_santos_transit'] = "Los Santos Transit",
['tourist_information'] = "Information Touriste",
['already_got_ticket'] = "Vous avez déjà un ticket de Metro valide, merci de vous rendre dans une de nos stations et monter dans un Metro",
['account_information'] = "Information Compte",
['account_nomoney'] = "Transaction échouée, solde insuffisant",
['ticket_purchased'] = "Merci pour votre achat, votre ticket sera valide pendant votre session actuelle.",
['stop_toolate'] = "Désolé, il semble que vous avez appuyé trop tard, vous devez attendre la prochaine station.",
['sorry'] = "Désolé",
['exit_metro_random'] = ", mais il n'est pas permis de sortir aléatoirement du Metro. Merci d'attendre la prochaine station !",
['Sir'] = "Monsieur",
['Miss'] = "Mademoiselle",
['need_ticket'] = "Désolé, vous devez acheté d'abord un ticket de Metro.",
['have_wantedlevel'] = "Désolé, nous ne tolérons pas les fugitifs dans nos Metro. Tout les passagers doivent voyager en toute sécurité !",
['entered_metro'] = "Vous êtes sorti du métro, votre ticket a été invalidé.",
['terrorist'] = "Nous ne tolérerons PAS le comportement terroriste sur nos véhicules de transport public !",
['no_metro_spawned'] = "Nos escuses, quelque chose s'est mal passé, vous avez reçu un billet gratuit!",
['travel_metro'] = "Merci d'avoir voyagé avec Los Santos Transit, votre billet a été approuvé.",
}
Message['es'] = {
['we_warned_you'] = "¡Te lo hemos advertido! ¡La policía ha sido notificada de su abordaje ilegal!",
['no_ticket_leave'] = "¡No tienes billete! Por favor, salga del metro o tendremos que llamar a la policía.",
['buyticket'] = "Pulsa ~INPUT_CONTEXT~ comprar un billete de metro",
['press_to_enter'] = "Pulsa ~INPUT_CONTEXT~ enfrente (y cerca) del Metro para entrar.",
['los_santos_transit'] = "Los Santos Transit",
['tourist_information'] = "Información turística",
['already_got_ticket'] = "Ya tiene un boleto de metro válido, vaya a una de nuestras estaciones y suba a un metro",
['account_information'] = "Información de la cuenta",
['account_nomoney'] = "Transacción fallida, saldo insuficiente",
['ticket_purchased'] = "Gracias por su compra, su entrada será válida durante su sesión actual.",
['stop_toolate'] = "Lo siento, parece que presionaste demasiado tarde, tienes que esperar a la siguiente estación.",
['sorry'] = "Lo siento",
['exit_metro_random'] = ", pero no está permitido salir del Metro al azar. Espere la próxima estación !",
['Sir'] = "señor",
['Miss'] = "señorita",
['need_ticket'] = "Lo siento, primero debes comprar un boleto de Metro.",
['have_wantedlevel'] = "Lo sentimos, no toleramos fugitivos en nuestro Metro. Todos los pasajeros deben viajar con seguridad !",
['entered_metro'] = "Has salido del Metro, tu billete ha sido invalidado.",
['terrorist'] = "NO toleraremos el comportamiento terrorista en nuestros vehículos de transporte público. !",
['no_metro_spawned'] = "Nuestras excusas, algo salió mal, recibiste un boleto gratis!",
['travel_metro'] = "Gracias por viajar con Los Santos Transit, su boleto ha sido aprobado.",
}

View file

@ -1,12 +0,0 @@
resource_manifest_version '05cfa83c-a124-4cfa-a768-c24a5811d8f9'
resource_version '1.0.0'
author 'VenomXNL'
fx_version 'adamant'
game 'gta5'
client_scripts {
"config.lua",
"client.lua"
}