Skip to content
This repository was archived by the owner on Aug 8, 2024. It is now read-only.

Commit 892d9f0

Browse files
authored
Merge pull request #54 from friendsincode/dev
Fixed dependency issue of copying on build, fixed other script regist…
2 parents fc64293 + fdbebf0 commit 892d9f0

File tree

7 files changed

+164
-73
lines changed

7 files changed

+164
-73
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ config.yml
1515
*.user
1616
*.userosscache
1717
*.sln.docstates
18+
*.sync-conflict*
1819

1920
# User-specific files (MonoDevelop/Xamarin Studio)
2021
*.userprefs

README.md

+23-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# ELS-Plus
22

3-
See: https://github.com/ejb1123/ELS-Plus/issues to submit an issue. It is important that if you test ELS for FiveM that you submit issues so that we may work to resolve these. Here's some things to consider:
3+
See: https://github.com/friendsincode/ELS-Plus/issues to submit an issue or use our discord here: . It is important that if you test ELS Plus for FiveM that you submit issues so that we may work to resolve these. Here's some things to consider:
44

5-
- ELS vehicles are not yet supported.
6-
- Lights are in progress. Currently sync is not working but you are able to use lights.
5+
- ELS vehicles are fully supported.
6+
- Full VCF parsing so you can totally customize vehicles.
77
- Custom cars will require VCF files to be created by following the [How to add custom Vehicles](#how-to-add-els-vehicles-to-els-fivem) section.
88
- You can spawn a vehicle using /elscar {model}
9-
- You can obtain a list of the vehicles ELS has detected by typing /elslist and pressing F8 to view console.
9+
- You can obtain a list of the vehicles ELS has detected by typing /elslist and pressing F8 to view console.(Plans to make menu in progress :D)
1010

1111

1212

@@ -44,24 +44,28 @@ See: https://github.com/ejb1123/ELS-Plus/issues to submit an issue. It is import
4444

4545

4646
### How to install
47-
1. Copy the `ELS-FiveM` folder to `cfx-server\resources\`
48-
2. Add `ELS-FiveM` to `server.cfg`
47+
1. Copy the `els-plus` folder to `cfx-server\resources\`
48+
2. Add `start els-plus` to `server.cfg`
4949
3. Add `add_ace resource.RESOURCE_NAME command.add_ace allow` to `server.cfg`
5050
remember to replace `RESOURCE_NAME` with the name of this resource.
51-
4. Add your user to the `group.admin` principle to allow you to use the elscar commmand to spawn a vehicle
51+
4. Modify settings via ini file how you see fit.
52+
5. If you set AllowAdminOnly to `true` Add your user to the `group.admin`
53+
principal with the following `add_principal identifier.[license||steam]:id# group.admin`
54+
to allow you to use the elscar commmand to spawn a vehicle.
55+
6. You can also add custom groups to els-plus to allow better control on who you wish to use the command.
5256

53-
### How to add ELS Vehicles to ELS-FiveM
57+
58+
### How to add ELS Vehicles to ELS-Plus
5459
1. Create add-on/replace Vehicle with stream folder and relevant files.
55-
2. In `__resource.lua` add the `VCF` xml file to the `files` list.
56-
3. Add `is_els 'true'` to bottom of `__resource.lua`.
57-
4. Restart Server
58-
5. Profit
60+
2. In `__resource.lua` of that add-on/replace vehicle add the `VCF` xml file to the `files` list.
61+
3. Make sure to validate the xml file to avoid issues with vehicle not showing up.
62+
4. Add `is_els 'true'` to bottom of `__resource.lua`.
63+
5. Restart Server
64+
6. Profit
5965

6066
#### Important Notes
6167

62-
- When running the rcon command `restart ELS-FiveM` or `start ELS-FiveM`.
63-
Make sure you restart any resources that have ELS vehicles.
64-
- Make sure ELS-FiveM is located below all ELS enabled vehicle stream resources in the `server.cfg` file.
68+
- When running the rcon command `restart els-plus` or `start els-plus`.
6569

6670
## Contribute
6771
if you are a developer and would like to contribute any help is welcome!
@@ -71,14 +75,14 @@ The contribution guide can be found [here](CONTRIBUTING.md).
7175

7276
1. Add the enviroment variable `FXSERVERDATA` and set its value to the `resources` directory path.
7377

74-
2. `git clone https://github.com/FiveM-Scripts/ELS-FiveM.git`
78+
2. `git clone https://github.com/friendsincode/ELS-Plus.git`
7579

76-
3. Open `ELS-FiveM\src\ELS-for-FiveM.sln` in Visual Studio
80+
3. Open `ELS-Plus\src\elsplus.sln` in Visual Studio
7781

7882
4. Select `Release` and `Any CPU` next to the Start button
7983

8084
5. In the menu bar under Build click on `Build Solution`
8185

82-
6. Copy all the files from `ELS-FiveM\src\bin\Release` to `cfx-server\resources\ELS-FiveM`
86+
6. Copy all the files from `ELS-Plus\src\bin\Release` to `cfx-server\resources\els-plus`
8387

84-
7. Add `ELS-FiveM` to `AutoStartResources` in `cfx-server\citmp-server.yml`
88+
7. Add `start els-plus` to `server.cfg`

server/ELS-Server/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.2.1.0")]
36-
[assembly: AssemblyFileVersion("0.2.1.0")]
35+
[assembly: AssemblyVersion("0.2.2.0")]
36+
[assembly: AssemblyFileVersion("0.2.2.0")]

src/ELS.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<ItemGroup>
8383
<Reference Include="CitizenFX.Core">
8484
<HintPath>..\libs\CitizenFx\CitizenFX.Core.dll</HintPath>
85+
<Private>False</Private>
8586
</Reference>
8687
<Reference Include="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
8788
<Reference Include="PresentationCore" />

src/Manager/VehicleList.cs

+60-18
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ namespace ELS.Manager
1212
{
1313
class VehicleList : Dictionary<int,ELSVehicle>
1414
{
15+
internal Dictionary<int,Tuple<int,int>> VehRegAttempts;
1516
//public new void Add(ELSVehicle veh)
1617
//{
1718
// base.Add(veh);
1819
//}
20+
21+
internal VehicleList()
22+
{
23+
VehRegAttempts = new Dictionary<int,Tuple<int,int>>();
24+
}
1925
public void Add(int NetworkID)
2026
{
2127
var veh = new ELSVehicle(API.NetToVeh(NetworkID));
@@ -38,7 +44,7 @@ public void RunExternalTick([Optional] ELSVehicle vehicle)
3844
}
3945
catch (Exception e)
4046
{
41-
CitizenFX.Core.Debug.WriteLine($"VehicleList Error: {e.Message}");
47+
Utils.DebugWriteLine($"VehicleList Error: {e.Message}");
4248
}
4349
}
4450
public bool MakeSureItExists(int NetworkID, [Optional]out ELSVehicle vehicle)
@@ -52,6 +58,14 @@ public bool MakeSureItExists(int NetworkID, [Optional]out ELSVehicle vehicle)
5258

5359
else if (!ContainsKey(NetworkID))
5460
{
61+
if (VehRegAttempts.ContainsKey(NetworkID))
62+
{
63+
VehRegAttempts[NetworkID] = new Tuple<int, int>(VehRegAttempts[NetworkID].Item1 + 1, Game.GameTime);
64+
}
65+
else
66+
{
67+
VehRegAttempts.Add(NetworkID, new Tuple<int, int>(1, Game.GameTime));
68+
}
5569
try
5670
{
5771
ELSVehicle veh = null;
@@ -65,14 +79,14 @@ public bool MakeSureItExists(int NetworkID, [Optional]out ELSVehicle vehicle)
6579
veh = new ELSVehicle(handle);
6680
}
6781
Add(NetworkID,veh);
82+
//CurrentlyRegisteringVehicle.Remove(NetworkID);
6883
vehicle = veh;
6984
return true;
7085
}
7186
catch (Exception ex)
7287
{
73-
#if DEBUG
74-
CitizenFX.Core.Debug.Write($"Exsits Error: {ex.Message} due to {ex.InnerException}");
75-
#endif
88+
Utils.DebugWriteLine($"Exsits Error: {ex.Message} due to {ex.InnerException}");
89+
//CurrentlyRegisteringVehicle.Remove(NetworkID);
7690
vehicle = null;
7791
return false;
7892
throw ex;
@@ -85,7 +99,7 @@ public bool MakeSureItExists(int NetworkID, [Optional]out ELSVehicle vehicle)
8599
return true;
86100
}
87101
}
88-
public bool MakeSureItExists(int NetworkID, IDictionary<string, object> data, [Optional]out ELSVehicle vehicle)
102+
public bool MakeSureItExists(int NetworkID, IDictionary<string, object> data, [Optional]out ELSVehicle vehicle, int PlayerId = -1)
89103
{
90104
if (NetworkID == 0)
91105
{
@@ -96,30 +110,55 @@ public bool MakeSureItExists(int NetworkID, IDictionary<string, object> data, [O
96110

97111
else if (!ContainsKey(NetworkID))
98112
{
113+
if (VehRegAttempts.ContainsKey(NetworkID))
114+
{
115+
VehRegAttempts[NetworkID] = new Tuple<int, int>(VehRegAttempts[NetworkID].Item1 + 1, Game.GameTime);
116+
}
117+
else
118+
{
119+
VehRegAttempts.Add(NetworkID, new Tuple<int, int>(1, Game.GameTime));
120+
}
99121
try
100122
{
101123
ELSVehicle veh = null;
102-
int handle = API.NetToVeh(NetworkID);
103-
if (handle == 0)
124+
int handle = API.NetworkGetEntityFromNetworkId(NetworkID);
125+
if (handle == 0 && PlayerId != -1)
104126
{
105-
veh = new ELSVehicle(Game.PlayerPed.CurrentVehicle.Handle,data);
127+
Player player = new Player(API.GetPlayerFromServerId(PlayerId));
128+
Utils.DebugWriteLine($"Registering vehicle with netid of {NetworkID} to list from {player.Name}");
129+
if (!player.Character.IsSittingInELSVehicle())
130+
{
131+
Utils.DebugWriteLine($"{player.Name} is not in an Els vehicle");
132+
vehicle = null;
133+
return false;
134+
}
135+
veh = new ELSVehicle(player.Character.CurrentVehicle.Handle, data);
106136
}
107137
else
108138
{
139+
Utils.DebugWriteLine($"Registering vehicle {NetworkID} to list from netid to veh");
109140
veh = new ELSVehicle(handle,data);
110141
}
111-
Add(NetworkID,veh);
112-
#if DEBUG
113-
CitizenFX.Core.Debug.Write($"Adding Vehicle");
114-
#endif
115-
vehicle = veh;
116-
return true;
142+
if (veh != null)
143+
{
144+
//CurrentlyRegisteringVehicle.Remove(NetworkID);
145+
Add(NetworkID, veh);
146+
Utils.DebugWriteLine($"Added {NetworkID} to vehicle list");
147+
vehicle = veh;
148+
return true;
149+
}
150+
else
151+
{
152+
//CurrentlyRegisteringVehicle.Remove(NetworkID);
153+
Utils.DebugWriteLine("Failed to add vehicle to list please try again");
154+
vehicle = null;
155+
return false;
156+
}
117157
}
118158
catch (Exception ex)
119159
{
120-
#if DEBUG
121-
CitizenFX.Core.Debug.Write($"Exsits Error With Data: {ex.Message}");
122-
#endif
160+
//CurrentlyRegisteringVehicle.Remove(NetworkID);
161+
Utils.DebugWriteLine($"Exsits Error With Data: {ex.Message}");
123162
vehicle = null;
124163
return false;
125164
throw ex;
@@ -128,10 +167,13 @@ public bool MakeSureItExists(int NetworkID, IDictionary<string, object> data, [O
128167
}
129168
else
130169
{
131-
vehicle = this[NetworkID];//Find(poolObject => ((ELSVehicle)poolObject).GetNetworkId() == NetworkID);
170+
Utils.DebugWriteLine($"Returning vehicle {NetworkID} from list");
171+
vehicle = this[NetworkID];
132172
return true;
133173
}
134174
}
175+
176+
135177
public void CleanUP()
136178
{
137179
for(int i = 0; i < Count; i++)

0 commit comments

Comments
 (0)