-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.1 - Open-beta
- Loading branch information
Showing
76 changed files
with
10,449 additions
and
1,834 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using SampSharp.GameMode.SAMP.Commands.PermissionCheckers; | ||
using SampSharp.GameMode.World; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace SampSharpGameMode1 | ||
{ | ||
public class AdminPermissionChecker : IPermissionChecker | ||
{ | ||
#region Implementation of IPermissionChecker | ||
|
||
/// <summary> | ||
/// Gets the message displayed when the player is denied permission. | ||
/// </summary> | ||
public string Message | ||
{ | ||
get { return "You need to be admin to run this command."; } | ||
} | ||
|
||
/// <summary> | ||
/// Checks the permission for the specified player. | ||
/// </summary> | ||
/// <param name="player">The player.</param> | ||
/// <returns>true if allowed; false if denied.</returns> | ||
public bool Check(BasePlayer player) | ||
{ | ||
Player p = (Player)player; | ||
return p.Adminlevel >= 1; | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using SampSharp.GameMode.Definitions; | ||
using SampSharp.GameMode.SAMP; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace SampSharpGameMode1 | ||
{ | ||
public class AntiCheat | ||
{ | ||
public enum SuspiciousBehavior | ||
{ | ||
UnauthorizedWeaponInEvent = 0 | ||
} | ||
|
||
private Player player; | ||
private Timer routineTimer; | ||
public AntiCheat(Player _player) | ||
{ | ||
this.player = _player; | ||
routineTimer = new Timer(5000, true); | ||
routineTimer.Tick += Routine; | ||
} | ||
|
||
private void Routine(object sender, EventArgs e) | ||
{ | ||
if (this.player.IsDisposed) | ||
{ | ||
this.routineTimer.IsRepeating = false; | ||
this.routineTimer.IsRunning = false; | ||
this.routineTimer.Dispose(); | ||
} | ||
else | ||
{ | ||
if (this.player.IsInEvent) | ||
{ | ||
if (this.player.Weapon != Weapon.None && this.player.pEvent.Status == Events.EventStatus.Running) | ||
{ | ||
// BasePlayer.Weapon returns only the weapon held by the player before he enter in a vehicle | ||
// So the AntiCheat system will only detect the weapon if player leave the vehicle | ||
// See: https://open.mp/fr/docs/scripting/functions/GetPlayerWeapon | ||
OnSuspiciousBehavior(SuspiciousBehavior.UnauthorizedWeaponInEvent); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void OnSuspiciousBehavior(SuspiciousBehavior behavior) | ||
{ | ||
switch(behavior) | ||
{ | ||
case SuspiciousBehavior.UnauthorizedWeaponInEvent: | ||
this.player.Kick("[AntiCheat] You have been kicked for unauthorized used of weapon in event") ; | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<appSettings> | ||
<add key ="gta_basefolder" value="gta_basefolder"/> | ||
<add key="mysql_host" value="database_host"/> | ||
<add key="mysql_port" value="database_port"/> | ||
<add key="mysql_db" value="database_name"/> | ||
<add key="mysql_user" value="database_user"/> | ||
<add key="mysql_pass" value="database_password"/> | ||
</appSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
using SampSharp.GameMode; | ||
using SampSharp.GameMode.Events; | ||
using SampSharp.GameMode.World; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace SampSharpGameMode1 | ||
{ | ||
public class CameraController | ||
{ | ||
public Player player; | ||
private BaseVehicle playerVehicle; // Store the player's vehicle before set spectating | ||
public bool Enabled { get; set; } | ||
public bool LockTarget { get; set; } | ||
public Vector3 LockedTarget { get; set; } | ||
public float LockDistance { get; set; } | ||
private Vector3 lastLookAtPos; | ||
public CameraController(Player player) | ||
{ | ||
this.player = player; | ||
this.player.KeyStateChanged += OnPlayerKeyStateChanged; | ||
this.Enabled = false; | ||
this.LockTarget = false; | ||
this.LockedTarget = Vector3.Zero; | ||
this.LockDistance = 200.0f; | ||
this.lastLookAtPos = Vector3.Zero; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if(this.player != null) | ||
{ | ||
this.player.KeyStateChanged -= OnPlayerKeyStateChanged; | ||
this.player = null; | ||
} | ||
} | ||
|
||
public void SetFree() | ||
{ | ||
if(this.Enabled) | ||
{ | ||
if (player.InAnyVehicle) | ||
playerVehicle = player.Vehicle; | ||
player.ToggleSpectating(true); | ||
System.Threading.Thread.Sleep(100); | ||
player.CameraPosition = player.Position + new Vector3(0.0, 0.0, 5.0); | ||
} | ||
else | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.SetFree:I: CameraController is not enabled"); | ||
} | ||
|
||
public void SetBehindPlayer() | ||
{ | ||
if (this.Enabled) | ||
{ | ||
player.ToggleSpectating(false); | ||
player.PutCameraBehindPlayer(); | ||
if(playerVehicle != null) | ||
player.PutInVehicle(playerVehicle); | ||
} | ||
else | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.SetBehindPlayer:I: CameraController is not enabled"); | ||
} | ||
|
||
public void SetPosition(Vector3 position) | ||
{ | ||
if (this.Enabled) | ||
{ | ||
player.CameraPosition = position; | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.SetPosition:I: New position = " + position.ToString()); | ||
} | ||
else | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.SetPosition:I: CameraController is not enabled"); | ||
} | ||
|
||
public void MoveTo(Vector3 position) | ||
{ | ||
if (this.Enabled) | ||
{ | ||
player.InterpolateCameraPosition(player.CameraPosition, position, 100, SampSharp.GameMode.Definitions.CameraCut.Move); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.MoveTo:I: Moving to = " + position.ToString()); | ||
} | ||
else | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.MoveTo:I: CameraController is not enabled"); | ||
} | ||
|
||
public void SetTarget(Vector3 target, bool locked = false) | ||
{ | ||
if (this.Enabled) | ||
{ | ||
player.SetCameraLookAt(target, SampSharp.GameMode.Definitions.CameraCut.Cut); | ||
lastLookAtPos = target; | ||
if (locked) | ||
{ | ||
LockTarget = true; | ||
LockedTarget = target; | ||
} | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.SetTarget:I: Look at position = " + target.ToString()); | ||
} | ||
else | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.SetTarget:I: CameraController is not enabled"); | ||
} | ||
|
||
public void MoveToTarget(Vector3 target) | ||
{ | ||
if (this.Enabled) | ||
{ | ||
player.InterpolateCameraLookAt(lastLookAtPos, target, 100, SampSharp.GameMode.Definitions.CameraCut.Move); | ||
lastLookAtPos = target; | ||
} | ||
else | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.MoveToTarget:I: CameraController is not enabled"); | ||
} | ||
|
||
private double GetAngle(Vector3 target, double distance) | ||
{ | ||
Vector3 cameraPos = player.CameraPosition; | ||
double xDiff = Math.Abs(cameraPos.X - target.X); | ||
double yDiff = Math.Abs(cameraPos.Y - target.Y); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.GetSinCos:I: xDiff = " + xDiff.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.GetSinCos:I: yDiff = " + yDiff.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.GetSinCos:I: dist = " + distance.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.GetSinCos:I: Math.Acos(xDiff / dist) = " + Math.Acos(xDiff / distance)); | ||
return Math.Acos(xDiff / distance); | ||
} | ||
|
||
private void OnPlayerKeyStateChanged(object sender, KeyStateChangedEventArgs e) | ||
{ | ||
if(player.CameraMode == SampSharp.GameMode.Definitions.CameraMode.Fixed && player.State == SampSharp.GameMode.Definitions.PlayerState.Spawned) | ||
{ | ||
Vector3 cameraPos = player.CameraPosition; | ||
double angle; | ||
switch (e.NewKeys) | ||
{ | ||
case SampSharp.GameMode.Definitions.Keys.AnalogLeft: | ||
if(LockTarget) | ||
{ | ||
angle = GetAngle(LockedTarget, LockDistance); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: LockedTarget = " + LockedTarget.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: dist = " + LockDistance.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: cameraPos = " + cameraPos.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: LockedTarget = " + LockedTarget.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: previous angle = " + angle.ToString()); | ||
angle -= Math.PI/4; | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: next angle = " + angle.ToString()); | ||
double cos = Math.Cos(angle); | ||
double sin = Math.Sin(angle); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: cos = " + cos.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: sin = " + sin.ToString()); | ||
MoveTo(new Vector3( | ||
(cos * LockDistance) + LockedTarget.X, | ||
(sin * LockDistance) + LockedTarget.Y, | ||
cameraPos.Z | ||
)); | ||
MoveToTarget(LockedTarget); | ||
} | ||
else | ||
MoveTo(cameraPos + new Vector3(10.0, 0.0, 0.0)); | ||
break; | ||
case SampSharp.GameMode.Definitions.Keys.AnalogRight: | ||
if (LockTarget) | ||
{ | ||
angle = GetAngle(LockedTarget, LockDistance); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: LockedTarget = " + LockedTarget.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: dist = " + LockDistance.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: cameraPos = " + cameraPos.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: LockedTarget = " + LockedTarget.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: previous angle = " + angle.ToString()); | ||
angle += Math.PI / 4; | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: next angle = " + angle.ToString()); | ||
double cos = Math.Cos(angle); | ||
double sin = Math.Sin(angle); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: cos = " + cos.ToString()); | ||
Logger.WriteLineAndClose($"CameraController.cs - CameraController.OnPlayerKeyStateChanged:I: sin = " + sin.ToString()); | ||
MoveTo(new Vector3( | ||
(cos * LockDistance) + LockedTarget.X, | ||
(sin * LockDistance) + LockedTarget.Y, | ||
cameraPos.Z | ||
)); | ||
MoveToTarget(LockedTarget); | ||
} | ||
else | ||
MoveTo(player.CameraPosition + new Vector3(-10.0, 0.0, 0.0)); | ||
break; | ||
case SampSharp.GameMode.Definitions.Keys.AnalogUp: | ||
MoveTo(player.CameraPosition + new Vector3(0.0, 10.0, 0.0)); | ||
break; | ||
case SampSharp.GameMode.Definitions.Keys.AnalogDown: | ||
MoveTo(player.CameraPosition + new Vector3(0.0, -10.0, 0.0)); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.