From f670d97c4eb276be4b840beb1895f89c4dbad97a Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Mon, 11 Aug 2025 18:58:07 +0200 Subject: [PATCH] ed --- .../[freizeit]/XNL-FiveM-Trains-U3/README.md | 118 +++++ .../[freizeit]/XNL-FiveM-Trains-U3/client.lua | 488 ++++++++++++++++++ .../[freizeit]/XNL-FiveM-Trains-U3/config.lua | 100 ++++ .../XNL-FiveM-Trains-U3/fxmanifest.lua | 12 + .../stream/trains_ticket_machine.ymap | Bin 0 -> 1452 bytes 5 files changed, 718 insertions(+) create mode 100644 resources/[freizeit]/XNL-FiveM-Trains-U3/README.md create mode 100644 resources/[freizeit]/XNL-FiveM-Trains-U3/client.lua create mode 100644 resources/[freizeit]/XNL-FiveM-Trains-U3/config.lua create mode 100644 resources/[freizeit]/XNL-FiveM-Trains-U3/fxmanifest.lua create mode 100644 resources/[freizeit]/XNL-FiveM-Trains-U3/stream/trains_ticket_machine.ymap diff --git a/resources/[freizeit]/XNL-FiveM-Trains-U3/README.md b/resources/[freizeit]/XNL-FiveM-Trains-U3/README.md new file mode 100644 index 000000000..8acffe7da --- /dev/null +++ b/resources/[freizeit]/XNL-FiveM-Trains-U3/README.md @@ -0,0 +1,118 @@ + ================================================================================ + IF there are questions, help needed or anything, please use the FiveM FORUM + topic to discuss and help each other. + ================================================================================ + + + 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 + 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 + + 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 diff --git a/resources/[freizeit]/XNL-FiveM-Trains-U3/client.lua b/resources/[freizeit]/XNL-FiveM-Trains-U3/client.lua new file mode 100644 index 000000000..374b2ad13 --- /dev/null +++ b/resources/[freizeit]/XNL-FiveM-Trains-U3/client.lua @@ -0,0 +1,488 @@ +--[[ +===================================================================================================================================== + 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 diff --git a/resources/[freizeit]/XNL-FiveM-Trains-U3/config.lua b/resources/[freizeit]/XNL-FiveM-Trains-U3/config.lua new file mode 100644 index 000000000..af4667f45 --- /dev/null +++ b/resources/[freizeit]/XNL-FiveM-Trains-U3/config.lua @@ -0,0 +1,100 @@ +--============================================================= +-- 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.", +} \ No newline at end of file diff --git a/resources/[freizeit]/XNL-FiveM-Trains-U3/fxmanifest.lua b/resources/[freizeit]/XNL-FiveM-Trains-U3/fxmanifest.lua new file mode 100644 index 000000000..60d797075 --- /dev/null +++ b/resources/[freizeit]/XNL-FiveM-Trains-U3/fxmanifest.lua @@ -0,0 +1,12 @@ +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" +} \ No newline at end of file diff --git a/resources/[freizeit]/XNL-FiveM-Trains-U3/stream/trains_ticket_machine.ymap b/resources/[freizeit]/XNL-FiveM-Trains-U3/stream/trains_ticket_machine.ymap new file mode 100644 index 0000000000000000000000000000000000000000..de672fcd2c3bdff06a8cb2fdfabbc8a355f43f72 GIT binary patch literal 1452 zcmV;d1ylM`Q$sfb00004000aC001EEnr%>2RT#(5A|etZ%G+ud8zin}w!D}tGP-gh z37uG}$QK+XVPJJZ!qpT-Kzt!2G!0lBW+DlxP@$a3R5GNUauRI{ooJH5oN}CLGMV~f zez1Gay>~q<8`B49LI1xycb@&<|K0mscK11)bMEmxzrvs*B8!QU23=gTaSM@P$F?msCz}y(3KN%C~(wK3AaHU?>xs8mnwyuMCQn{7S*c zTxIK;r(t@Od>K!11A~v!=L!%vNxQM=C2r2om%fn+;s$_1SZCuQPonO3{P?y?VeO$R zTYIro-+d{Xuk80k2uWaV!sr3=+>`hJn*WrTKWR&q?NWtfewz3GJq%U;-~KEYeDbSo zH?v%mKjn{dA)}_sc59<+KL2{tUSXD)KRMeq`O6E-gtcP+;8fS-x31eOB#PhvdwH(; z{`VJ`30`9U=(M5D4<1h3?9o$>zH(H{Q6opK9CdQk|9>|L02mT1d1H2`2Rc(!BtqTRj? zIpV*0`+P5pZb!nBE`*hkC#BT9*iFBq| zWpXd3ZU2I#g9UV6;Y9q(^&T#~UjV@1aUtc(1{$l+jlD(df1~Nlj0S;P4w|c_m~eoW2di?Q1`s623IiQjP?d#`OyPsYi z+1yE=2qh~9=dWC`a9j6=+2b|LM{fau5eHY#m%qJmU2E-$qU}Mlga3pqZ+c{PsG0BP z)IS}2;%P1O-TU|fvVY@D$tgYaJ)HXLqT+c8%=hf$E34J?b5i4%GT+Oo-*$9UYZmjp zo%(k_K3uw)`9A;li2(5M;86eRX@M$d^{>=tM1l1YzWx{KCUnz!_mll`DXIBSaT)+H ze2LuNPXArn>pL&&`%HIE`xpLvgSH28vVMik+N9=muF9ia%jwXH%<+0o0|16EN_{Ki z|0U1Ye(23<+8)sHztSGeGG?yz=XCInkZz3_BNe}X=3yPDds{b7F>rcz+?Z@5rMxzvImB7gZz)^zTa05F8is0*#*>z~#;tsJGkvval{ z;_IJ|4>aU{{rVcZ-=Os#CF|K?^|c0ae?A~~+g;x{PJbSLpo@<0{bk+QWBFn+=U-e@ z{f&{+0YUrBFN^UtBCS<>^XQ%p62 zU@Le2N8WR<)e^KXV0hrz|9^eqGpxU_)VDr%p;g1_faxvGwBD8ad_U