Archived
Private
Public Access
1
0

Update 07.12.2022

This commit is contained in:
2022-12-07 15:35:41 +01:00
parent 771f58073f
commit 840d7ad42f
288 changed files with 148948 additions and 4346 deletions

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?><configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -0,0 +1,10 @@
using System;
using CitizenFX.Core;
namespace Framework.Server.Extensions {
public static class PlayerExtensions {
public static int ServerId(this Player player) => Convert.ToInt32(player.Handle);
}
}

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3B60C431-5ACF-4145-A792-32217A65A445}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Framework.Server</RootNamespace>
<AssemblyName>Framework.Server.net</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>embedded</DebugType>
<Optimize>true</Optimize>
<OutputPath>../Build</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>del Framework.Server.net.dll.config</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core.Server, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CitizenFX.Core.Server.1.0.6086\lib\net45\CitizenFX.Core.Server.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.CSharp">
<HintPath>..\Librarys\Microsoft.CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="MySql.Data">
<HintPath>..\Librarys\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Management" />
<Reference Include="System.Numerics" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Extensions\PlayerExtensions.cs" />
<Compile Include="Handlers\JoinHandler.cs" />
<Compile Include="MySql.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Server.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Framework.Shared\Framework.Shared.csproj">
<Project>{7130f249-1c23-438c-a077-76a2867f8c5e}</Project>
<Name>Framework.Shared</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,33 @@
using System;
using CitizenFX.Core;
using CitizenFX.Core.Native;
using Framework.Server.Extensions;
using Framework.Shared.Models;
namespace Framework.Server.Handlers {
public static class JoinHandler {
public static readonly Vector3 Spawn = new Vector3(258.7932f, -942.7487f, 29.3940f);
public static async void OnPlayerJoining([FromSource] Player player) {
API.SetPlayerRoutingBucket(player.Handle, player.ServerId());
API.SetRoutingBucketPopulationEnabled(player.ServerId(), false);
API.SetRoutingBucketEntityLockdownMode(player.ServerId(), "strict");
API.SetPlayerInvincible(player.Handle, true);
var identifier = "steam:" + player.Identifiers["steam"];
var result = await MySql.FetchAll($"SELECT * FROM players WHERE owner = '{identifier}'");
if (result.Length == 0) player.TriggerEvent("client:spawn:register");
else player.TriggerEvent("client:spawn:choose", result);
}
public static async void OnRegister([FromSource] Player player, dynamic dData) {
var data = new PlayerData(dData);
var identifier = "steam:" + player.Identifiers["steam"];
await MySql.Execute($"INSERT INTO players VALUES ('{identifier}', '{Guid.NewGuid()}', {data.sex}, {data.height}, '{data.firstName}', '{data.lastName}', '{data.birth}', '{data.skin}')");
player.Character.Position = Spawn;
}
}
}

View File

@@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
namespace Framework.Server {
public static class MySql {
private static MySqlConnection _connection;
public static void Initialize(string connectionString) {
_connection = new MySqlConnection(connectionString);
}
public static async Task Execute(string query) {
await _connection.OpenAsync();
var cmd = new MySqlCommand(query, _connection);
await cmd.ExecuteNonQueryAsync();
await _connection.CloseAsync();
}
public static async Task<dynamic[]> FetchAll(string query) {
await _connection.OpenAsync();
var cmd = new MySqlCommand(query, _connection);
var result = await cmd.ExecuteReaderAsync();
List<dynamic> data = new List<dynamic>();
foreach (var record in result) {
data.Add(record);
}
await _connection.CloseAsync();
return data.ToArray();
}
public static async Task<dynamic> FetchOne(string query) {
var result = await FetchAll(query);
return result[0];
}
public static async void CreateTables(params string[] querys) {
var query = string.Join(";", querys);
await Execute(query);
}
}
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Framework.Server")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Framework.Server")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3B60C431-5ACF-4145-A792-32217A65A445")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,19 @@
using System;
using CitizenFX.Core;
using Framework.Server.Handlers;
namespace Framework.Server {
public class Server : ServerScript {
public Server() {
MySql.Initialize("Server=213.136.89.237;Database=FiveM;Uid=FiveM;Pwd=uTwjt1nGX3nf.LHR;");
MySql.CreateTables(
"CREATE TABLE IF NOT EXISTS players (owner VARCHAR(100), charId VARCHAR(100), sex BOOLEAN, height INT(3), firstName VARCHAR(60), lastName VARCHAR(60), birth VARCHAR(10), skin LONGTEXT)"
);
EventHandlers["playerJoining"] += new Action<Player>(JoinHandler.OnPlayerJoining);
EventHandlers["server:spawn:register"] += new Action<Player, dynamic>(JoinHandler.OnRegister);
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]

View File

@@ -0,0 +1 @@
4fed6ec97924c777f9315f8ba3e5430e56649d63

View File

@@ -0,0 +1,8 @@
D:\Programmierstuff\C#\FiveM\Framework\Framework.Server\obj\Release\Framework.Server.csproj.AssemblyReference.cache
D:\Programmierstuff\C#\FiveM\Framework\Framework.Server\obj\Release\Framework.Server.csproj.CoreCompileInputs.cache
D:\Programmierstuff\C#\FiveM\Framework\Framework.Server\obj\Release\Framework.Server.csproj.CopyComplete
D:\Programmierstuff\C#\FiveM\Framework\Build\fxmanifest.lua
D:\Programmierstuff\C#\FiveM\Framework\Build\stream\NativeUI.ytd
D:\Programmierstuff\C#\FiveM\Framework\Build\Framework.Server.net.dll
D:\Programmierstuff\C#\FiveM\Framework\Framework.Server\obj\Release\Framework.Server.net.dll
D:\Programmierstuff\C#\FiveM\Framework\Build\Framework.Server.net.dll.config

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CitizenFX.Core.Server" version="1.0.6086" targetFramework="net481" />
</packages>