Skip to content

Commit

Permalink
v0.1 - Open-beta.2
Browse files Browse the repository at this point in the history
v0.1 - Open-beta.2
  • Loading branch information
LDami authored Aug 9, 2022
2 parents 4972ab4 + eca9024 commit fc078eb
Show file tree
Hide file tree
Showing 26 changed files with 888 additions and 253 deletions.
4 changes: 2 additions & 2 deletions SampSharpGameMode1/Civilisation/PathExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public enum NodeType : byte

public static void Load()
{
string heightmapFile = Directory.GetCurrentDirectory() + "\\scriptfiles\\SAfull.hmap";
string heightmapFile = Directory.GetCurrentDirectory() + "/scriptfiles/SAfull.hmap";
using (FileStream fs = File.Open(heightmapFile, FileMode.Open, FileAccess.Read))
{
long fsLen = fs.Length;
Expand All @@ -220,7 +220,7 @@ public static void Extract(string path, int index)
{
try
{
string filename = path + "\\NODES" + index + ".DAT";
string filename = path + "/NODES" + index + ".DAT";
Random rdm = new Random();
using (FileStream fs = File.Open(filename, FileMode.Open, FileAccess.Read))
{
Expand Down
2 changes: 1 addition & 1 deletion SampSharpGameMode1/Civilisation/RecordCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void AddVehicleBlock(VehicleBlock vehicleBlock)
/// <param name="filename">File name with .rec extension</param>
public void Save(string filename)
{
using (FileStream fs = File.Open(Directory.GetCurrentDirectory() + "\\npcmodes\\recordings\\" + filename, FileMode.Create, FileAccess.Write))
using (FileStream fs = File.Open(Directory.GetCurrentDirectory() + "/npcmodes/recordings/" + filename, FileMode.Create, FileAccess.Write))
{
byte[] buffer;

Expand Down
32 changes: 21 additions & 11 deletions SampSharpGameMode1/Commands/CommonCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,31 @@ namespace SampSharpGameMode1.Commands
{
class CommonCommands
{
[Command("help")]
private static void HelpCommand(Player player)
{
player.SendClientMessage(ColorPalette.Primary.Main + "This is a SA-MP where you can create your own maps, races and derbies !");
player.SendClientMessage($"Type {ColorPalette.Secondary.Main}/event-infos{Color.White} to get more information about how to create a map, a race, or a derby.");
player.SendClientMessage($"Teleport yourself where you want with {ColorPalette.Secondary.Main}/tlps");
player.SendClientMessage($"This server is still in beta, type {ColorPalette.Secondary.Main}/beta{Color.White} to see what is coming soon !");
}
[Command("beta")]
private static void BetaCommand(Player player)
{
player.SendClientMessage(ColorPalette.Primary.Main + "These features are still in development and will be ready to test soon:");
player.SendClientMessage(ColorPalette.Secondary.Main + " - Map creator (in progress)");
player.SendClientMessage(ColorPalette.Secondary.Main + " - Derby creator and Derby events (need to implement Map creator first)");
player.SendClientMessage(ColorPalette.Secondary.Main + " - AI / NPC to play with");
player.SendClientMessage(ColorPalette.Secondary.Main + " - More event types");
player.SendClientMessage(" - AI / NPC to play with");
player.SendClientMessage(" - More event types");
}
[Command("event-infos")]
private static void EventInfosCommand(Player player)
{
player.SendClientMessage(ColorPalette.Primary.Main + "On this server you can create your own races and derbies, so please read the following instructions:");
player.SendClientMessage(ColorPalette.Secondary.Main + " - Use /race to see race creator commands, and /derby for derby creator commands");
player.SendClientMessage(ColorPalette.Secondary.Main + " - Make sure you use a keyboard with numpad (controllers are not supported yet)");
player.SendClientMessage(ColorPalette.Secondary.Main + " - You can only edit your own event");
player.SendClientMessage(ColorPalette.Secondary.Main + " - If you want to add a map to your event, create the map first with /map commands, then load it into your event");
player.SendClientMessage(ColorPalette.Secondary.Main + " - Once your event is playable, everybody can load it and join it");
player.SendClientMessage($" - Use {ColorPalette.Secondary.Main}/race{Color.White} to see race creator commands, and {ColorPalette.Secondary.Main}/derby{Color.White} for derby creator commands");
player.SendClientMessage($" - Make sure you use a keyboard with numpad (controllers are not supported yet)");
player.SendClientMessage($" - You can only edit your own event");
player.SendClientMessage($" - If you want to add a map to your event, create the map first with {ColorPalette.Secondary.Main}/map{Color.White} commands, then load it into your event");
player.SendClientMessage($" - Don't forget to save your creations with {ColorPalette.Secondary.Main}/race save{Color.White}, {ColorPalette.Secondary.Main}/derby save{Color.White} or {ColorPalette.Secondary.Main}/map save{Color.White}");
player.SendClientMessage($" - Once your event is playable, everybody can load it and join it");
}

[Command("s")]
Expand All @@ -44,8 +51,11 @@ private static void RCommand(Player player)
{
if (player.LastSavedPosition.Position != Vector3.Zero)
{
player.Teleport(player.LastSavedPosition.Position + Vector3.UnitZ);
player.Angle = player.LastSavedPosition.Rotation;
if (!player.IsInEvent)
{
player.Teleport(player.LastSavedPosition.Position + Vector3.UnitZ);
player.Angle = player.LastSavedPosition.Rotation;
}
}
else
player.SendClientMessage(ColorPalette.Error.Main + "Set the position with /s first");
Expand Down
65 changes: 60 additions & 5 deletions SampSharpGameMode1/Commands/DerbyCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,61 @@ namespace SampSharpGameMode1.Commands
{
class DerbyCommands
{

/* Display a list of all the player's races */
[Command("myderbies")]
private static void MyDerbiesCommand(Player player)
{
List<string> races = Derby.GetPlayerDerbyList(player);
if (races.Count == 0)
player.SendClientMessage("You don't have any derbies");
else
{
ListDialog list = new ListDialog(player.Name + "'s derbies", "Options", "Close");
list.AddItems(races);
list.Response += (object sender, DialogResponseEventArgs e) =>
{
if (e.DialogButton == DialogButton.Left)
{
ListDialog actionList = new ListDialog("Action", "Select", "Cancel");
actionList.AddItem("Infos ...");
actionList.AddItem("Edit");
actionList.AddItem("Delete");
actionList.Response += (object sender, DialogResponseEventArgs ev) =>
{
if (ev.DialogButton == DialogButton.Left)
{
try
{
int raceid = Convert.ToInt32(races[e.ListItem].Substring(0, races[e.ListItem].IndexOf('_')));
switch (ev.ListItem)
{
case 0: // Infos
DerbyCommandsClass.GetInfo(player, raceid);
break;
case 1: // Edit
DerbyCommandsClass.LoadDerbyCreator(player, raceid);
break;
case 2: // Delete
player.SendClientMessage(Color.Red + "This function is not developped yet");
break;
}
}
catch (Exception ex)
{
MySQLConnector.Instance().CloseReader();
Logger.WriteLineAndClose("DerbyCommands.cs - DerbyCommands.MyDerbiesCommand:E: Exception raised: " + ex.Message);
player.SendClientMessage(Color.Red + "An error occured");
}
}
};
actionList.Show(player);
}
};
list.Show(player);
}
}

[Command("derby")]
private static void DerbyCommandUsage(Player player)
{
Expand All @@ -36,7 +91,7 @@ private static void CreateDerby(Player player)
}

[Command("loadc")]
private static void LoadDerbyCreator(Player player, int id)
public static void LoadDerbyCreator(Player player, int id)
{
if (player.pEvent != null)
return;
Expand Down Expand Up @@ -142,7 +197,7 @@ private static void EditPickup(Player player, int objectid)
[Command("find")]
private static void FindDerby(Player player, string name)
{
Dictionary<string, string> result = DerbyCreator.Find(name);
Dictionary<string, string> result = Derby.Find(name);
if (result.Count == 0)
player.SendClientMessage("No derby found !");
else
Expand All @@ -155,9 +210,9 @@ private static void FindDerby(Player player, string name)
}

[Command("info")]
private static void GetInfo(Player player, int id)
public static void GetInfo(Player player, int id)
{
Dictionary<string, string> result = DerbyCreator.GetInfo(id);
Dictionary<string, string> result = Derby.GetInfo(id);
if (result.Count == 0)
player.SendClientMessage("No derby found !");
else
Expand All @@ -166,7 +221,7 @@ private static void GetInfo(Player player, int id)
string str = "";
foreach (KeyValuePair<string, string> kvp in result)
{
str = new Color(50, 50, 255) + kvp.Key + ": " + new Color(255, 255, 255) + kvp.Value;
str = Display.ColorPalette.Primary.Main + kvp.Key + ": " + new Color(255, 255, 255) + kvp.Value;
if (str.Length >= 64)
{
infoList.AddItem(str.Substring(0, 63));
Expand Down
99 changes: 93 additions & 6 deletions SampSharpGameMode1/Commands/MappingCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,66 @@ namespace SampSharpGameMode1.Commands
{
class MappingCommands
{

/* Display a list of all the player's maps */
[Command("mymaps")]
private static void MyMapsCommands(Player player)
{
List<string> maps = Map.GetPlayerMapList(player);
if (maps.Count == 0)
player.SendClientMessage("You don't have any maps");
else
{
ListDialog list = new ListDialog(player.Name + "'s maps", "Options", "Close");
list.AddItems(maps);
list.Response += (object sender, DialogResponseEventArgs e) =>
{
if (e.DialogButton == DialogButton.Left)
{
ListDialog actionList = new ListDialog("Action", "Select", "Cancel");
actionList.AddItem("Infos ...");
actionList.AddItem("Edit");
actionList.AddItem("Delete");
actionList.Response += (object sender, DialogResponseEventArgs ev) =>
{
if (ev.DialogButton == DialogButton.Left)
{
try
{
int mapid = Convert.ToInt32(maps[e.ListItem].Substring(0, maps[e.ListItem].IndexOf('_')));
switch (ev.ListItem)
{
case 0: // Infos
MappingCommandClass.GetInfo(player, mapid);
break;
case 1: // Edit
MappingCommandClass.LoadCommand(player, mapid);
break;
case 2: // Delete
player.SendClientMessage(Color.Red + "This function is not developped yet");
break;
}
}
catch (Exception ex)
{
MySQLConnector.Instance().CloseReader();
Logger.WriteLineAndClose("MappingCommands.cs - MappingCommands.MyMapsCommands:E: Exception raised: " + ex.Message);
player.SendClientMessage(Color.Red + "An error occured");
}
}
};
actionList.Show(player);
}
};
list.Show(player);
}
}
[Command("mapping", Shortcut = "map")]
private static void MappingCommand(Player player)
{
player.SendClientMessage($"Usage: {ColorPalette.Secondary.Main}/mapping [action]");
player.SendClientMessage($"Global Actions: {ColorPalette.Secondary.Main}help, create, loadc, exit");
player.SendClientMessage($"On map editing Actions: {ColorPalette.Secondary.Main}help, save, exit, list, addo, delo, replace, marker, dist, edit");
player.SendClientMessage($"On map editing Actions: {ColorPalette.Secondary.Main}help, save, exit, info, addo, delo, replace, marker, dist, edit");
}
[CommandGroup("mapping", "map")]
class MappingCommandClass
Expand All @@ -29,15 +83,15 @@ private static void HelpCommand(Player player)
$"{ColorPalette.Primary.Main}/mapping create {ColorPalette.Primary.Darken}Create a new map" + "\n" +
$"{ColorPalette.Primary.Main}/mapping loadc [id] {ColorPalette.Primary.Darken}Load a map" + "\n" +
$"{ColorPalette.Primary.Main}/mapping save {ColorPalette.Primary.Darken}Save the map" + "\n" +
$"{ColorPalette.Primary.Main}/mapping exit {ColorPalette.Primary.Darken}Close the editor without saving the map" + "\n" +
$"{ColorPalette.Primary.Main}/mapping list {ColorPalette.Primary.Darken}List all your races" + "\n" +
$"{ColorPalette.Primary.Main}/mapping exit {ColorPalette.Primary.Darken}Close the editor (save your map first !)" + "\n" +
$"{ColorPalette.Primary.Main}/mapping info [id] {ColorPalette.Primary.Darken}Display the info of a map" + "\n" +
$"{ColorPalette.Primary.Main}/mapping addo [modelid] {ColorPalette.Primary.Darken}Add an object with specified modelid" + "\n" +
$"{ColorPalette.Primary.Main}/mapping delo [objectid] {ColorPalette.Primary.Darken}Delete the object" + "\n" +
$"{ColorPalette.Primary.Main}/mapping replace [objectid] [modelid] {ColorPalette.Primary.Darken}Replace the object by the s modelid" + "\n" +
$"{ColorPalette.Primary.Main}/mapping dupl [objectid] {ColorPalette.Primary.Darken}Duplicate the object" + "\n" +
$"{ColorPalette.Primary.Main}/mapping marker [1-2] {ColorPalette.Primary.Darken}Edit the marker position to get distance" + "\n" +
$"{ColorPalette.Primary.Main}/mapping dist {ColorPalette.Primary.Darken}Displays the distance between the markers" + "\n" +
$"{ColorPalette.Primary.Main}/mapping edit [objectid] {ColorPalette.Primary.Darken}Edit position/rotation of object" + "\n" +
$"{ColorPalette.Primary.Main}/mapping exit {ColorPalette.Primary.Darken}Close the editor"
$"{ColorPalette.Primary.Main}/mapping edit [objectid] {ColorPalette.Primary.Darken}Edit position/rotation of object";
;
MessageDialog dialog = new MessageDialog("Command list", list, "Close");
dialog.Show(player);
Expand All @@ -51,7 +105,7 @@ private static void CreateCommand(Player player)
player.mapCreator.CreateMap();
}
[Command("loadc")]
private static void LoadCommand(Player player, int id)
public static void LoadCommand(Player player, int id)
{
if (player.pEvent != null)
return;
Expand Down Expand Up @@ -189,6 +243,14 @@ private static void ReplaceCommand(Player player, int objectid, int modelid)
else
player.SendClientMessage(Color.Red, $"Map creator is not initialized, create or load a map first");
}
[Command("dupl")]
private static void DuplicateCommand(Player player, int objectid)
{
if (!(player.mapCreator is null))
player.mapCreator.DuplicateObject(objectid);
else
player.SendClientMessage(Color.Red, $"Map creator is not initialized, create or load a map first");
}
[Command("marker")]
private static void MarkerCommand(Player player, int marker)
{
Expand All @@ -213,6 +275,31 @@ private static void EditCommand(Player player, int objectid)
else
player.SendClientMessage(Color.Red, $"Map creator is not initialized, create or load a map first");
}

[Command("info")]
public static void GetInfo(Player player, int id)
{
Dictionary<string, string> result = Map.GetInfo(id);
if (result.Count == 0)
player.SendClientMessage("No map found !");
else
{
var infoList = new ListDialog("Map info", "Ok", "");
string str = "";
foreach (KeyValuePair<string, string> kvp in result)
{
str = Display.ColorPalette.Primary.Main + kvp.Key + ": " + new Color(255, 255, 255) + kvp.Value;
if (str.Length >= 64)
{
infoList.AddItem(str.Substring(0, 63));
infoList.AddItem(str.Substring(63));
}
else
infoList.AddItem(str);
}
infoList.Show(player);
}
}
}
}
}
Loading

0 comments on commit fc078eb

Please sign in to comment.