Skip to content

Commit

Permalink
Updates and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
emcifuntik committed Sep 24, 2023
1 parent 76d89de commit 731fb59
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 51 deletions.
66 changes: 66 additions & 0 deletions freeroam-extended/client/html/index.de.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>alt:V Chat</title>
<link rel="stylesheet" href="style.css" />
</head>

<body>
<div class="stress-test-label">
Public Stress Test - v15. Powered by Avoro.eu
</div>
<div class="info">
<div class="players-online">
Spieler online <div class="info-number players-online-number">xxxx</div>
</div>
<div class="player-id">
Deine ID <div class="info-number player-id-number">xxxx</div>
</div>
<div class="weapons-enabled">
Waffen <div class="info-number weapons-enabled-on">ON</div>
</div>
<div class="voice-server-connection-status">
Sprachchat <div class="info-number voice-connection-status-connected">Connected</div>
</div>
<div class="streamed-in">
Streamed Spieler <div class="info-number streamed-in-players">0</div>
</div>
<div class="streamed-in">
Streamed Fahrzeuge <div class="info-number streamed-in-vehicles">0</div>
</div>
</div>
<div class="help-keys">
<ol>
<li><span class="help-keys-command">F2:</span> HUD umschalten</li>
<li><span class="help-keys-command">T / Eingabe:</span> Chat öffnen</li>

<li><span class="help-keys-command">/tp</span> &lt;1 bis 22&gt; (Teleport)</li>
<li><span class="help-keys-command">/model</span> (wechselt zwischen männlichem und weiblichen Model)</li>
<li><span class="help-keys-command">/outfit [outfit_name]</span> (Ändert Outfit zufällig oder auf gegebenen Wert)</li>
<li><span class="help-keys-command">/veh</span> &lt;modelName&gt; (Erstellt ein Fahrzeug)</li>
<li><span class="help-keys-command">/clearvehicles</span> (Löscht deine Fahrzeuge)</li>
<li><span class="help-keys-command">/tune</span> &lt;index> &lt;value&gt; (Fahrzeug Tuning)</li>
<li><span class="help-keys-command">/weapons</span> (Gibt dir alle Waffen)</li>
<li><span class="help-keys-command">/addcomponent</span> &lt;name&gt; (Waffen Komponenten hinzufügen)</li>
<li><span class="help-keys-command">/removecomponent</span> &lt;name&gt; (Waffen Kompontent entfernen)</li>
<li><span class="help-keys-command">/dm</span> ((De)Aktiviert den Respawn in der DM Zone)</li>
<li><span class="help-keys-command">/revive</span> (Wiederbeleben des Spielers)</li>
</ol>
</div>
<div class="content">
<div class="chatbox">
<div class="msglist">
<div class="messages"></div>
</div>
<div class="msginput">
<form id="message">
<input type="text" spellcheck="false" />
</form>
</div>
</div>
</div>
<script src="app.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion freeroam-extended/client/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<body>
<div class="stress-test-label">
Public Stress Test - v15
Public Stress Test - v15. Powered by Avoro.eu
</div>
<div class="info">
<div class="players-online">
Expand Down
8 changes: 7 additions & 1 deletion freeroam-extended/client/src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ class View extends alt.WebView {
}
}

export const view = new View("http://resource/html/index.html")
const locale = alt.getLocale();

let viewUrl = "http://resource/html/index.html"
if (locale === "de") {
viewUrl = "http://resource/html/index.de.html"
}
export const view = new View(viewUrl)
53 changes: 34 additions & 19 deletions freeroam-extended/server/freeroam-extended/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Commands : IScript
[Command("veh")]
public void SpawnVeh(IAltPlayer player, string vehicleName)
{
if (Misc.BlacklistedVehicle.Contains(Alt.Hash(vehicleName)) && !player.IsAdmin)
if (!Misc.WhitelistedVehicles.Contains(Alt.Hash(vehicleName)))
{
player.SendChatMessage("{FF0000} Vehicle is blacklisted.");
return;
Expand Down Expand Up @@ -105,24 +105,24 @@ public void GetWeapons(IAltPlayer player)
}
}

[Command("model")]
public void ChangeModel(IAltPlayer player)
{
if (player.Model == Alt.Hash("mp_m_freemode_01"))
{
player.Model = Alt.Hash("mp_f_freemode_01");
}
else
{
player.Model = Alt.Hash("mp_m_freemode_01");
}

player.RefreshFace();

player.RefreshClothes();
player.SendChatMessage(
$"{{00FF00}}Your model changed");
}
//[Command("model")]
//public void ChangeModel(IAltPlayer player)
//{
// if (player.Model == Alt.Hash("mp_m_freemode_01"))
// {
// player.Model = Alt.Hash("mp_f_freemode_01");
// }
// else
// {
// player.Model = Alt.Hash("mp_m_freemode_01");
// }

// player.RefreshFace();

// player.RefreshClothes();
// player.SendChatMessage(
// $"{{00FF00}}Your model changed");
//}

[Command("outfit")]
public void Outfit(IAltPlayer player, string outfitUniqueName = "")
Expand Down Expand Up @@ -205,6 +205,9 @@ public void Unban(IAltPlayer player, string rsid)

// remove banned player from list
Misc.BannedPlayers.Remove(rsid);
string json = JsonSerializer.Serialize(Misc.BannedPlayers);
File.WriteAllText(@"BannedPlayers.json", json);

player.SendChatMessage($"{{00FF00}}Player with hwid {rsid} unbanned!");
}

Expand Down Expand Up @@ -287,6 +290,18 @@ public void Dimension(IAltPlayer player, int dimension = 0)
player.Dimension = dimension;
}

[Command("streamplayers")]
public void StreamPlayers(IAltPlayer player, int count = 128)
{
if (!player.IsAdmin)
{
player.SendChatMessage("{FF0000} No permission!");
return;
}


}

[Command("clearvehicles")]
public void ClearVehicles(IAltPlayer player)
{
Expand Down
72 changes: 45 additions & 27 deletions freeroam-extended/server/freeroam-extended/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,27 @@ public EventHandler()
[AsyncScriptEvent(ScriptEventType.PlayerConnect)]
public async Task OnPlayerConnect(IAltPlayer player, string reason)
{
string cloudId = await player.RequestCloudId();
if (cloudId == "invalid")
try
{
player.Kick("Authorization error");
AltAsync.Log(
$"HWID: {player.HardwareIdHash}, RS ID: {cloudId}. Tried to join the server with invalid RS ID.");
return;
string cloudId = await player.RequestCloudId();
if (cloudId == "NO_LICENSE")
{
player.Kick("Authorization error");
AltAsync.Log(
$"HWID: {player.HardwareIdHash}, RS ID: {cloudId}. Tried to join the server with invalid RS ID.");
return;
}

player.CloudID = cloudId;
}
catch (Exception ex)
{
if (ex.Message != "SERVICE_UNAVAILABLE")
{

player.CloudID = cloudId;
}
}


if (Misc.BannedPlayers.Contains(player.CloudID))
{
Expand All @@ -57,7 +68,7 @@ public async Task OnPlayerConnect(IAltPlayer player, string reason)
return;
}

if (Misc.Operators.Contains(cloudId))
if (Misc.Operators.Contains(player.CloudID))
player.IsAdmin = true;

// select random entry from SpawnPoints
Expand Down Expand Up @@ -89,6 +100,13 @@ public async Task OnPlayerConnect(IAltPlayer player, string reason)
Misc.UniquePlayers.Add(player.CloudID);
File.WriteAllText(@"UniquePlayers.json", JsonSerializer.Serialize(Misc.UniquePlayers));
}

string oldData = $"old auth data: {player.SocialClubId}, {player.SocialClubName}";
if (!Misc.UniquePlayers.Contains(oldData))
{
Misc.UniquePlayers.Add(oldData);
File.WriteAllText(@"UniquePlayers.json", JsonSerializer.Serialize(Misc.UniquePlayers));
}
}

Voice.AddPlayer(player);
Expand Down Expand Up @@ -256,25 +274,25 @@ public bool OnProjectileStart(IAltPlayer player, Position startPosition, Positio
return false;
}

[ClientEvent("chat:message")]
public void OnChatMessage(IAltPlayer player, params string[] args)
{
var message = string.Join("", args);
if (args.Length == 0 || message.Length == 0) return;

if (args[0].StartsWith("/")) return;
if (!Misc.ChatState && !player.IsAdmin)
{
player.SendChatMessage("{FF0000}Chat is disabled!");
return;
}

foreach (var p in Alt.GetAllPlayers())
{
p.SendChatMessage(
$"{(player.IsAdmin ? "{008736}" : "{FFFFFF}")} <b>{player.Name}({player.Id})</b>: {{FFFFFF}}{message}");
}
}
//[ClientEvent("chat:message")]
//public void OnChatMessage(IAltPlayer player, params string[] args)
//{
// var message = string.Join("", args);
// if (args.Length == 0 || message.Length == 0) return;

// if (args[0].StartsWith("/")) return;
// if (!Misc.ChatState && !player.IsAdmin)
// {
// player.SendChatMessage("{FF0000}Chat is disabled!");
// return;
// }

// foreach (var p in Alt.GetAllPlayers())
// {
// p.SendChatMessage(
// $"{(player.IsAdmin ? "{008736}" : "{FFFFFF}")} <b>{player.Name}({player.Id})</b>: {{FFFFFF}}{message}");
// }
//}

[ClientEvent("tp_to_waypoint")]
public void TeleportToWaypoint(IAltPlayer player, int x, int y, int z)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AltV.Net.Async" Version="15.0.161-dev" />
<PackageReference Include="AltV.Net.Resources.Chat.Api" Version="15.0.161-dev" />
<PackageReference Include="AltV.Net.Async" Version="15.0.170-dev" />
<PackageReference Include="AltV.Net.Resources.Chat.Api" Version="15.0.169-dev" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions freeroam-extended/server/freeroam-extended/Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ public static class Misc
3987008919,
};

public static HashSet<uint> WhitelistedVehicles = new ()
{
0xB779A091,
0xAE2BFE94,
0x6322B39A,
0x92EF6E04
};

public static readonly Position[] SpawnPositions = {
new (-1734.69885f,-1108.47033f, 14.05346f ), // Pier
new (-2162.94067f, -398.45275f,14.373657f), // Parking Lot at the beach-highway
Expand Down

0 comments on commit 731fb59

Please sign in to comment.