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

Commit

Permalink
Merge pull request #54 from friendsincode/dev
Browse files Browse the repository at this point in the history
Fixed dependency issue of copying on build, fixed other script regist…
  • Loading branch information
ejb1123 authored Mar 9, 2018
2 parents fc64293 + fdbebf0 commit 892d9f0
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 73 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config.yml
*.user
*.userosscache
*.sln.docstates
*.sync-conflict*

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
42 changes: 23 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# ELS-Plus

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:
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:

- ELS vehicles are not yet supported.
- Lights are in progress. Currently sync is not working but you are able to use lights.
- ELS vehicles are fully supported.
- Full VCF parsing so you can totally customize vehicles.
- 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.
- You can spawn a vehicle using /elscar {model}
- You can obtain a list of the vehicles ELS has detected by typing /elslist and pressing F8 to view console.
- 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)



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


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

### How to add ELS Vehicles to ELS-FiveM

### How to add ELS Vehicles to ELS-Plus
1. Create add-on/replace Vehicle with stream folder and relevant files.
2. In `__resource.lua` add the `VCF` xml file to the `files` list.
3. Add `is_els 'true'` to bottom of `__resource.lua`.
4. Restart Server
5. Profit
2. In `__resource.lua` of that add-on/replace vehicle add the `VCF` xml file to the `files` list.
3. Make sure to validate the xml file to avoid issues with vehicle not showing up.
4. Add `is_els 'true'` to bottom of `__resource.lua`.
5. Restart Server
6. Profit

#### Important Notes

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

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

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

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

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

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

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

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

7. Add `ELS-FiveM` to `AutoStartResources` in `cfx-server\citmp-server.yml`
7. Add `start els-plus` to `server.cfg`
4 changes: 2 additions & 2 deletions server/ELS-Server/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.1.0")]
[assembly: AssemblyFileVersion("0.2.1.0")]
[assembly: AssemblyVersion("0.2.2.0")]
[assembly: AssemblyFileVersion("0.2.2.0")]
1 change: 1 addition & 0 deletions src/ELS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<ItemGroup>
<Reference Include="CitizenFX.Core">
<HintPath>..\libs\CitizenFx\CitizenFX.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="PresentationCore" />
Expand Down
78 changes: 60 additions & 18 deletions src/Manager/VehicleList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ namespace ELS.Manager
{
class VehicleList : Dictionary<int,ELSVehicle>
{
internal Dictionary<int,Tuple<int,int>> VehRegAttempts;
//public new void Add(ELSVehicle veh)
//{
// base.Add(veh);
//}

internal VehicleList()
{
VehRegAttempts = new Dictionary<int,Tuple<int,int>>();
}
public void Add(int NetworkID)
{
var veh = new ELSVehicle(API.NetToVeh(NetworkID));
Expand All @@ -38,7 +44,7 @@ public void RunExternalTick([Optional] ELSVehicle vehicle)
}
catch (Exception e)
{
CitizenFX.Core.Debug.WriteLine($"VehicleList Error: {e.Message}");
Utils.DebugWriteLine($"VehicleList Error: {e.Message}");
}
}
public bool MakeSureItExists(int NetworkID, [Optional]out ELSVehicle vehicle)
Expand All @@ -52,6 +58,14 @@ public bool MakeSureItExists(int NetworkID, [Optional]out ELSVehicle vehicle)

else if (!ContainsKey(NetworkID))
{
if (VehRegAttempts.ContainsKey(NetworkID))
{
VehRegAttempts[NetworkID] = new Tuple<int, int>(VehRegAttempts[NetworkID].Item1 + 1, Game.GameTime);
}
else
{
VehRegAttempts.Add(NetworkID, new Tuple<int, int>(1, Game.GameTime));
}
try
{
ELSVehicle veh = null;
Expand All @@ -65,14 +79,14 @@ public bool MakeSureItExists(int NetworkID, [Optional]out ELSVehicle vehicle)
veh = new ELSVehicle(handle);
}
Add(NetworkID,veh);
//CurrentlyRegisteringVehicle.Remove(NetworkID);
vehicle = veh;
return true;
}
catch (Exception ex)
{
#if DEBUG
CitizenFX.Core.Debug.Write($"Exsits Error: {ex.Message} due to {ex.InnerException}");
#endif
Utils.DebugWriteLine($"Exsits Error: {ex.Message} due to {ex.InnerException}");
//CurrentlyRegisteringVehicle.Remove(NetworkID);
vehicle = null;
return false;
throw ex;
Expand All @@ -85,7 +99,7 @@ public bool MakeSureItExists(int NetworkID, [Optional]out ELSVehicle vehicle)
return true;
}
}
public bool MakeSureItExists(int NetworkID, IDictionary<string, object> data, [Optional]out ELSVehicle vehicle)
public bool MakeSureItExists(int NetworkID, IDictionary<string, object> data, [Optional]out ELSVehicle vehicle, int PlayerId = -1)
{
if (NetworkID == 0)
{
Expand All @@ -96,30 +110,55 @@ public bool MakeSureItExists(int NetworkID, IDictionary<string, object> data, [O

else if (!ContainsKey(NetworkID))
{
if (VehRegAttempts.ContainsKey(NetworkID))
{
VehRegAttempts[NetworkID] = new Tuple<int, int>(VehRegAttempts[NetworkID].Item1 + 1, Game.GameTime);
}
else
{
VehRegAttempts.Add(NetworkID, new Tuple<int, int>(1, Game.GameTime));
}
try
{
ELSVehicle veh = null;
int handle = API.NetToVeh(NetworkID);
if (handle == 0)
int handle = API.NetworkGetEntityFromNetworkId(NetworkID);
if (handle == 0 && PlayerId != -1)
{
veh = new ELSVehicle(Game.PlayerPed.CurrentVehicle.Handle,data);
Player player = new Player(API.GetPlayerFromServerId(PlayerId));
Utils.DebugWriteLine($"Registering vehicle with netid of {NetworkID} to list from {player.Name}");
if (!player.Character.IsSittingInELSVehicle())
{
Utils.DebugWriteLine($"{player.Name} is not in an Els vehicle");
vehicle = null;
return false;
}
veh = new ELSVehicle(player.Character.CurrentVehicle.Handle, data);
}
else
{
Utils.DebugWriteLine($"Registering vehicle {NetworkID} to list from netid to veh");
veh = new ELSVehicle(handle,data);
}
Add(NetworkID,veh);
#if DEBUG
CitizenFX.Core.Debug.Write($"Adding Vehicle");
#endif
vehicle = veh;
return true;
if (veh != null)
{
//CurrentlyRegisteringVehicle.Remove(NetworkID);
Add(NetworkID, veh);
Utils.DebugWriteLine($"Added {NetworkID} to vehicle list");
vehicle = veh;
return true;
}
else
{
//CurrentlyRegisteringVehicle.Remove(NetworkID);
Utils.DebugWriteLine("Failed to add vehicle to list please try again");
vehicle = null;
return false;
}
}
catch (Exception ex)
{
#if DEBUG
CitizenFX.Core.Debug.Write($"Exsits Error With Data: {ex.Message}");
#endif
//CurrentlyRegisteringVehicle.Remove(NetworkID);
Utils.DebugWriteLine($"Exsits Error With Data: {ex.Message}");
vehicle = null;
return false;
throw ex;
Expand All @@ -128,10 +167,13 @@ public bool MakeSureItExists(int NetworkID, IDictionary<string, object> data, [O
}
else
{
vehicle = this[NetworkID];//Find(poolObject => ((ELSVehicle)poolObject).GetNetworkId() == NetworkID);
Utils.DebugWriteLine($"Returning vehicle {NetworkID} from list");
vehicle = this[NetworkID];
return true;
}
}


public void CleanUP()
{
for(int i = 0; i < Count; i++)
Expand Down
Loading

0 comments on commit 892d9f0

Please sign in to comment.