From dde519dbe0c1f1f0145287606a9e074c6179a2f5 Mon Sep 17 00:00:00 2001 From: Jordan Dalton Date: Mon, 18 Sep 2017 19:07:57 +0100 Subject: [PATCH] feat: add blip helper Technically this doesn't fix #2 but, I have added all the available blips to the UI and this. So.. closes #2 --- README.md | 89 +++++----------------- client/blip_helper.lua | 163 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+), 72 deletions(-) create mode 100644 client/blip_helper.lua diff --git a/README.md b/README.md index 12bfd20..06eacaf 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,26 @@ # fivem-live_map -This is the "backend" code for the live_map addon for FiveM. +This is the "backend" code for the live_map addon for FiveM that is ran on the +game server. +It creates a websocket server so that it can communicate to the +web interface. ## How to install Download the ZIP file. And extract the contents into `resources/live_map/`. -Add `live_map` to your `AutoStartResources` list in the "citmp-server.yml" file. - + ## Configuration -At the moment you don't need to configure much to get this addon working. - -#### live.lua - -Inside the `live.lua` file you can change the port the websocket server listen on and whether you want to use SSL (more on how to configure this later). - -```lua -local liveMapPort = 30121 -- Change to the port you want the websocket to listen on (must not be in use) -local useSsl = false -- Set to true if you want to use WSS (secure websocket) -``` - -#### blips.lua - -At the moment, this file contains all the blips you want to appear on the map when it's loaded in the browser. - -All blips in this file __must__ follow the format of `{name="NAME", type="TYPE", x=-0, y=0.000, z=0}`. - -``` -name - The name of the blip (shown when clicked on the map) -description (optional) - Provide a description of what the blip represents -type - The type of the blip (determines the icon shown on the map) -x,y,z = The location of the blip in game -``` - -#### blip_helper.lua -This file is just used to translate the integer blip types to a string which can be used on the web interface. It's recommended that you don't touch this file. - +### Convars +The following convars are available or you to change -#### Using SSL -You cannot use SSL straight a way, you need to recompile the source code of the library to use it. Below you can find a brief description of how to do this. - -If you're not using Windows and you want to use SSL, please ask a developer to do this for you. They will know how to compile the source code on your system. __Do not ask me to do it for you__. - -You're going to need a valid SSL certificate signed by a certificate authority. If you do not have one or, know how to get one. __DO NOT USE SSL__. I can't tell everyone how to do this. Just look it up on Gooogle or something. - - -Once you have your certificate file and private key file (preferably in PEM format), you will need to convert them into PFX (I know, but websockets will only accept PFX files). You can do this by using [this site](https://www.sslshopper.com/ssl-converter.html). Just select "PFX/PKCS#12" in the type to convert to section and give it the files needed. - -Now that you have the PFX file, we need to convert it to Base64 (this is the last step, I promise). You can do this by going to [this site](https://www.base64encode.org/). It will download a TXT file which, will contain the Base64 encoded certificate. - -Now, open the project (if using Windows, open the `.csproj` file in Visual Studio). - -Paste the Base64 encoded certificate into the `cert` variable in the "LiveMap.cs" file. - -Once you've done that, build the library (`Ctrl + Shift + B` in Visual Studio). Now, drop the DLL file from `bin/Debug/` into the `libs` folder. - -Now you can use secure websockets :grin: +| Name | Type | Default Value | Description | +| ------------- | ------------- | ------------------: | ----------- | +| socket_port | int | 30120 | Sets the port the socket server should listen on | +| livemap_debug | int | 0 | Sets how much information gets printed to the console (0 = none, 1 = basic information, 2 = all) | +| blip_file | string | "server/blips.json" | Sets the file that will contain the generated blips that is exposed via HTTP | ## Events @@ -66,28 +29,10 @@ In an effort to make the addon useful to other developers, I've created a few ev Below you can find some info on the events. ```lua --- Adds a blip to the map at the provided coords. (Can be called from client) -TriggerEvent("live_map:addBlip", blipName --[[ string ]], blipDesc --[[string]], blipType --[[string or int]], x --[[float]], y--[[float]], z--[[float]] ) - ---[[ -Adds custom string data to player object (e.g. player name) -must be called from client. -key = the key of the data (e.g. "name") -str = the data to be stored (e.g. "Havoc") -]] -TriggerServerEvent("live_map:clientAddString", key --[[string]], str--[[string]]) - ---[[ -Add custom number data to the player object (e.g. player coords) -must be called from client -key = the key of the data (e.g. "x") -flt = the data to be stored (e.g. 10 or 4.4848) -]] -TriggerServerEvent("live_map:clientAddFloat", key --[[string]], flt--[[float]]) - --- The above events call the server events below where plrId is the server id of the player - -TriggerEvent("live_map:addString", plrId --[[int]], key --[[string]], s --[[string]]) -TriggerEvent("live_map:addFloat", plrId --[[int]], key --[[string]], f --[[float]]) ``` + +## Built with +* [Hellslicer/WebSocketServer](https://github.com/Hellslicer/WebSocketServer/blob/master/WebSocketEventListener.cs) +* [deniszykov/WebSocketListener](https://github.com/deniszykov/WebSocketListener) +* [JamesNK/Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) diff --git a/client/blip_helper.lua b/client/blip_helper.lua new file mode 100644 index 0000000..aaa0e96 --- /dev/null +++ b/client/blip_helper.lua @@ -0,0 +1,163 @@ +local blip_types = { + Standard = 1, + Jet = 16, + Lift = 36, + RaceFinish = 38, + Safehouse = 40, + PoliceHelicopter = 43, + ChatBubble = 47, + Garage2 = 50, + Drugs = 51, + Store = 52, + PoliceCar = 56, + PoliceStation = 60, + Hospital = 61, + Helicopter = 64, + StrangersAndFreaks = 65, + ArmoredTruck = 66, + TowTruck = 68, + Barber = 71, + LosSantosCustoms = 72, + Clothes = 73, + TattooParlor = 75, + Simeon = 76, + Lester = 77, + Michael = 78, + Trevor = 79, + Rampage = 84, + VinewoodTours = 85, + Lamar = 86, + Franklin = 88, + Chinese = 89, + Airport = 90, + Bar = 93, + BaseJump = 94 + CarWash = 100, + ComedyClub = 102, + Dart = 103, + FIB = 106, + DollarSign = 108, + Golf = 109, + AmmuNation = 110, + Exile = 112, + ShootingRange = 119, + Solomon = 120, + StripClub = 121, + Tennis = 122, + Triathlon = 126, + OffRoadRaceFinish = 128, + Key = 134, + MovieTheater = 135, + Music = 136, + Marijuana = 140, + Hunting = 137, + ArmsTraffickingGround = 147, + Nigel = 149, + AssaultRifle = 150, + Bat = 151, + Grenade = 152, + Health = 153, + Knife = 154, + Molotov = 155, + Pistol = 156, + RPG = 157, + Shotgun = 158, + SMG = 159, + Sniper = 160, + PointOfInterest = 162, + GTAOPassive = 163, + GTAOUsingMenu = 164, + Minigun = 173, + GrenadeLauncher = 174, + Armor = 175, + Castle = 176, + Camera = 184, + Handcuffs = 188, + Yoga = 197, + Cab = 198, + Shrink = 205, + Epsilon = 206, + PersonalVehicleCar = 225, + PersonalVehicleBike = 226, + Custody = 237, + ArmsTraffickingAir = 251, + Fairground = 266, + PropertyManagement = 267, + Altruist = 269, + Chop = 273, + Hooker = 279, + Friend = 280, + GTAOMission = 304, + GTAOSurvival = 305, + CrateDrop =306, + PlaneDrop =307, + Sub = 308, + Race = 309, + Deathmatch = 310, + ArmWrestling = 311, + AmmuNationShootingRange = 313, + RaceAir = 314, + RaceCar = 315, + RaceSea = 316, + GarbageTruck = 318, + SafehouseForSale = 350, + Package = 351, + MartinMadrazo = 352, + Boost = 354, + Devin = 355, + Marina = 356, + Garage = 357, + GolfFlag = 358, + Hangar = 359, + Helipad = 360, + JerryCan = 361, + Masks = 362, + HeistSetup = 364, + PickupSpawn = 365, + BoilerSuit = 366, + Completed = 367, + Rockets = 368, + GarageForSale = 369, + + HelipadForSale = 370, + MarinaForSale = 371, + HangarForSale = 372, + Business = 374, + BusinessForSale = 375 + RaceBike = 376, + Parachute = 377, + TeamDeathmatch = 378, + RaceFoot = 379, + VehicleDeathmatch = 380, + Barry = 381, + Dom = 382, + MaryAnn = 383, + Cletus = 384, + Josh = 385, + Minute = 386, + Omega = 387, + Tonya = 388, + Paparazzo = 389, + Abigail = 400, + Blimp = 401, + Repair = 402, + Testosterone = 403, + Dinghy = 404, + Fanatic = 405, + CaptureBriefcase = 408, + LastTeamStanding = 409, + Boat = 410, + CaptureHouse = 411, + JerryCan2 = 415, + CaptureAmericanFlag = 419, + + CaptureFlag = 420, + Tank = 421, + GunCar = 426, + Speedboat = 427, + Heist = 428, + Stopwatch = 430, + DollarSignCircled = 431, + Crosshair2 = 432, + DollarSignSquared = 434 +}