Skip to content

Commit

Permalink
didn't really change anything but removed derived script from chat cl…
Browse files Browse the repository at this point in the history
…ass. Race still does not work.
  • Loading branch information
Soloman Northrop committed Jul 28, 2016
1 parent bc9f058 commit bb3b61f
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 127 deletions.
13 changes: 9 additions & 4 deletions AdminTools/AdminTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@
<HintPath>..\packages\Colorful.Console.1.0.5\lib\net452\Colorful.Console.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="GTAServer, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\SERVERS\GameServer\Grand Theft Auto\GTA V\GTAServer.exe</HintPath>
<EmbedInteropTypes>False</EmbedInteropTypes>
<Reference Include="GTAServer">
<HintPath>..\..\..\..\Documents\GTA Scripting\Plugins\GTAServer.exe</HintPath>
</Reference>
<Reference Include="Lidgren.Network, Version=2012.1.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lidgren.Network.1.0.2\lib\net451\Lidgren.Network.dll</HintPath>
Expand All @@ -59,6 +57,13 @@
<HintPath>..\packages\MaxMind.GeoIP2.2.6.0\lib\net45\MaxMind.GeoIP2.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="protobuf-net, Version=2.1.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<HintPath>..\packages\protobuf-net.2.1.0\lib\net451\protobuf-net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ScriptHookVDotNet">
<HintPath>..\libs\ScriptHookVDotNet.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
Expand Down
1 change: 1 addition & 0 deletions AdminTools/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<package id="MaxMind.Db" version="2.0.0" targetFramework="net452" />
<package id="MaxMind.GeoIP2" version="2.6.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="protobuf-net" version="2.1.0" targetFramework="net452" />
<package id="System.Net.Http" version="4.1.0" targetFramework="net452" />
</packages>
230 changes: 115 additions & 115 deletions Client/Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,159 +13,159 @@

namespace GTACoOp
{
public class Chat : Script
public class Chat
{
public event EventHandler OnComplete;
public event EventHandler OnComplete;

public Chat()
{
CurrentInput = "";
_mainScaleform = new Scaleform(0);
_mainScaleform.Load("multiplayer_chat");
}
public Chat()
{
CurrentInput = "";
_mainScaleform = new Scaleform(0);
_mainScaleform.Load("multiplayer_chat");
}

public bool HasInitialized;
public bool HasInitialized;

public void Init()
{
_mainScaleform.CallFunction("SET_FOCUS", 2, 2, "ALL");
_mainScaleform.CallFunction("SET_FOCUS", 1, 2, "ALL");
HasInitialized = true;
}
public void Init()
{
_mainScaleform.CallFunction("SET_FOCUS", 2, 2, "ALL");
_mainScaleform.CallFunction("SET_FOCUS", 1, 2, "ALL");
HasInitialized = true;
}

public bool IsFocused
public bool IsFocused
{
get { return _isFocused; }
set
{
get { return _isFocused; }
set
if (value && !_isFocused)
{
_mainScaleform.CallFunction("SET_FOCUS", 2, 2, "ALL");
}
else if (!value && _isFocused)
{
if (value && !_isFocused)
{
_mainScaleform.CallFunction("SET_FOCUS", 2, 2, "ALL");
}
else if (!value && _isFocused)
{
_mainScaleform.CallFunction("SET_FOCUS", 1, 2, "ALL");
}
_mainScaleform.CallFunction("SET_FOCUS", 1, 2, "ALL");
}

_isFocused = value;
_isFocused = value;

}
}
}

private Scaleform _mainScaleform;
private Scaleform _mainScaleform;

public string CurrentInput;
public string CurrentInput;

private int _switch = 1;
private Keys _lastKey;
private bool _isFocused;
private int _switch = 1;
private Keys _lastKey;
private bool _isFocused;

public void Tick()
{
if (!Main.IsOnServer()) return;
public void Tick()
{
if (!Main.IsOnServer()) return;

_mainScaleform.Render2D();
_mainScaleform.Render2D();


if (!IsFocused) return;
Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, 0);
}
if (!IsFocused) return;
Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, 0);
}

public void AddMessage(string sender, string msg)
public void AddMessage(string sender, string msg)
{
if (string.IsNullOrEmpty(sender))
{
if (string.IsNullOrEmpty(sender))
{
_mainScaleform.CallFunction("ADD_MESSAGE", "", SanitizeString(msg));
System.IO.File.AppendAllText("scripts\\GTACOOP_chat.log", "[" + DateTime.UtcNow + "] " + msg + "\n");
}
else
{
_mainScaleform.CallFunction("ADD_MESSAGE", SanitizeString(sender) + ":", SanitizeString(msg));
System.IO.File.AppendAllText("scripts\\GTACOOP_chat.log", "[" + DateTime.UtcNow + "] " + sender + ": " + msg + "\n");
}
_mainScaleform.CallFunction("ADD_MESSAGE", "", SanitizeString(msg));
System.IO.File.AppendAllText("scripts\\GTACOOP_chat.log", "[" + DateTime.UtcNow + "] " + msg + "\n");
}

public string SanitizeString(string input)
else
{
input = Regex.Replace(input, "~.~", "", RegexOptions.IgnoreCase);
return input;
_mainScaleform.CallFunction("ADD_MESSAGE", SanitizeString(sender) + ":", SanitizeString(msg));
System.IO.File.AppendAllText("scripts\\GTACOOP_chat.log", "[" + DateTime.UtcNow + "] " + sender + ": " + msg + "\n");
}
}

public void OnKeyDown(Keys key)
{
if (key == Keys.PageUp && Main.IsOnServer())
_mainScaleform.CallFunction("PAGE_UP");
public string SanitizeString(string input)
{
input = Regex.Replace(input, "~.~", "", RegexOptions.IgnoreCase);
return input;
}

else if (key == Keys.PageDown && Main.IsOnServer())
_mainScaleform.CallFunction("PAGE_DOWN");
public void OnKeyDown(Keys key)
{
if (key == Keys.PageUp && Main.IsOnServer())
_mainScaleform.CallFunction("PAGE_UP");

if (!IsFocused) return;
else if (key == Keys.PageDown && Main.IsOnServer())
_mainScaleform.CallFunction("PAGE_DOWN");

if ((key == Keys.ShiftKey && _lastKey == Keys.Menu) || (key == Keys.Menu && _lastKey == Keys.ShiftKey))
ActivateKeyboardLayout(1, 0);
if (!IsFocused) return;

_lastKey = key;
if ((key == Keys.ShiftKey && _lastKey == Keys.Menu) || (key == Keys.Menu && _lastKey == Keys.ShiftKey))
ActivateKeyboardLayout(1, 0);

if (key == Keys.Escape)
{
IsFocused = false;
CurrentInput = "";
}
_lastKey = key;

var keyChar = GetCharFromKey(key, Game.IsKeyPressed(Keys.ShiftKey), false);
if (key == Keys.Escape)
{
IsFocused = false;
CurrentInput = "";
}

if (keyChar.Length == 0) return;
var keyChar = GetCharFromKey(key, Game.IsKeyPressed(Keys.ShiftKey), false);

if (keyChar[0] == (char)8)
{
_mainScaleform.CallFunction("SET_FOCUS", 1, 2, "ALL");
_mainScaleform.CallFunction("SET_FOCUS", 2, 2, "ALL");
if (keyChar.Length == 0) return;

if (CurrentInput.Length > 0)
{
CurrentInput = CurrentInput.Substring(0, CurrentInput.Length - 1);
_mainScaleform.CallFunction("ADD_TEXT", CurrentInput);
}
return;
}
if (keyChar[0] == (char)13)
if (keyChar[0] == (char)8)
{
_mainScaleform.CallFunction("SET_FOCUS", 1, 2, "ALL");
_mainScaleform.CallFunction("SET_FOCUS", 2, 2, "ALL");

if (CurrentInput.Length > 0)
{
_mainScaleform.CallFunction("ADD_TEXT", "ENTER");
if (OnComplete != null) OnComplete.Invoke(this, EventArgs.Empty);
CurrentInput = "";
return;
CurrentInput = CurrentInput.Substring(0, CurrentInput.Length - 1);
_mainScaleform.CallFunction("ADD_TEXT", CurrentInput);
}
var str = keyChar;

CurrentInput += str;
_mainScaleform.CallFunction("ADD_TEXT", str);
return;
}
if (keyChar[0] == (char)13)
{
_mainScaleform.CallFunction("ADD_TEXT", "ENTER");
if (OnComplete != null) OnComplete.Invoke(this, EventArgs.Empty);
CurrentInput = "";
return;
}
var str = keyChar;

CurrentInput += str;
_mainScaleform.CallFunction("ADD_TEXT", str);
}

[DllImport("user32.dll")]
public static extern int ToUnicodeEx(uint virtualKeyCode, uint scanCode,
byte[] keyboardState,
[Out, MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
StringBuilder receivingBuffer,
int bufferSize, uint flags, IntPtr kblayout);

[DllImport("user32.dll")]
public static extern int ActivateKeyboardLayout(int hkl, uint flags);

public static string GetCharFromKey(Keys key, bool shift, bool altGr)
[DllImport("user32.dll")]
public static extern int ToUnicodeEx(uint virtualKeyCode, uint scanCode,
byte[] keyboardState,
[Out, MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
StringBuilder receivingBuffer,
int bufferSize, uint flags, IntPtr kblayout);

[DllImport("user32.dll")]
public static extern int ActivateKeyboardLayout(int hkl, uint flags);

public static string GetCharFromKey(Keys key, bool shift, bool altGr)
{
var buf = new StringBuilder(256);
var keyboardState = new byte[256];
if (shift)
keyboardState[(int)Keys.ShiftKey] = 0xff;
if (altGr)
{
var buf = new StringBuilder(256);
var keyboardState = new byte[256];
if (shift)
keyboardState[(int)Keys.ShiftKey] = 0xff;
if (altGr)
{
keyboardState[(int)Keys.ControlKey] = 0xff;
keyboardState[(int)Keys.Menu] = 0xff;
}

ToUnicodeEx((uint)key, 0, keyboardState, buf, 256, 0, InputLanguage.CurrentInputLanguage.Handle);
return buf.ToString();
keyboardState[(int)Keys.ControlKey] = 0xff;
keyboardState[(int)Keys.Menu] = 0xff;
}

ToUnicodeEx((uint)key, 0, keyboardState, buf, 256, 0, InputLanguage.CurrentInputLanguage.Handle);
return buf.ToString();
}
}
}
}
7 changes: 6 additions & 1 deletion Client/GTACoOp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<ItemGroup>
<Reference Include="Colorful.Console, Version=1.0.5.0, Culture=neutral, PublicKeyToken=cc1f2a0d977b1e28, processorArchitecture=MSIL">
<HintPath>..\packages\Colorful.Console.1.0.5\lib\net452\Colorful.Console.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="GTAServer">
<HintPath>..\..\..\..\SERVERS\GameServer\Grand Theft Auto\GTA V\GTAServer.exe</HintPath>
<HintPath>..\..\..\..\Documents\GTA Scripting\Plugins\GTAServer.exe</HintPath>
</Reference>
<Reference Include="Lidgren.Network, Version=2012.1.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lidgren.Network.1.0.2\lib\net451\Lidgren.Network.dll</HintPath>
Expand Down Expand Up @@ -79,6 +83,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
Expand Down
2 changes: 2 additions & 0 deletions Client/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Colorful.Console" version="1.0.5" targetFramework="net452" />
<package id="Lidgren.Network" version="1.0.2" targetFramework="net452" />
<package id="MaxMind.Db" version="2.0.0" targetFramework="net452" />
<package id="MaxMind.GeoIP2" version="2.6.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="protobuf-net" version="2.1.0" targetFramework="net452" />
<package id="System.Net.Http" version="4.1.0" targetFramework="net452" />
</packages>
32 changes: 29 additions & 3 deletions Race/Race.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,37 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Colorful.Console, Version=1.0.5.0, Culture=neutral, PublicKeyToken=cc1f2a0d977b1e28, processorArchitecture=MSIL">
<HintPath>..\packages\Colorful.Console.1.0.5\lib\net452\Colorful.Console.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="GTAServer">
<HintPath>..\Server\bin\Release\GTAServer.exe</HintPath>
<HintPath>..\Server\bin\Debug\GTAServer.exe</HintPath>
</Reference>
<Reference Include="Lidgren.Network, Version=2012.1.7.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Lidgren.Network.dll</HintPath>
<HintPath>..\packages\Lidgren.Network.1.0.2\lib\net451\Lidgren.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MaxMind.Db, Version=2.0.0.0, Culture=neutral, PublicKeyToken=66afa4cc5ae853ac, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.Db.2.0.0\lib\net45\MaxMind.Db.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MaxMind.GeoIP2, Version=2.6.0.0, Culture=neutral, PublicKeyToken=66afa4cc5ae853ac, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.GeoIP2.2.6.0\lib\net45\MaxMind.GeoIP2.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="protobuf-net, Version=2.1.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<HintPath>..\packages\protobuf-net.2.1.0\lib\net451\protobuf-net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -53,6 +75,10 @@
<Compile Include="Race.cs" />
<Compile Include="VehicleHashes.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</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.
Expand Down
Loading

0 comments on commit bb3b61f

Please sign in to comment.