Skip to content

Commit

Permalink
Plugin by Edspar fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
educatalan02 committed May 11, 2019
1 parent 5190173 commit c6106af
Show file tree
Hide file tree
Showing 23 changed files with 1,275 additions and 0 deletions.
130 changes: 130 additions & 0 deletions CommandAddHouse.cs
@@ -0,0 +1,130 @@
using fr34kyn01535.Uconomy;
using Rocket.API;
using Rocket.Core.Plugins;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using SDG.Unturned;
using Steamworks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using UnityEngine;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Reflection;
using Rocket.Unturned.Permissions;

namespace Edsparr.Houseplugin
{
public class CommandAddHouse : IRocketCommand
{
#region Declarations

public bool AllowFromConsole
{
get
{
return false;
}
}

public List<string> Permissions
{
get
{
return new List<string>()
{
"addhouse"
};
}
}

public AllowedCaller AllowedCaller
{
get
{
return AllowedCaller.Player;
}
}

public bool RunFromConsole
{
get
{
return false;
}
}

public string Name
{
get
{
return "addhouse";
}
}

public string Syntax
{
get
{
return "apartment (create/select)";
}
}

public string Help
{
get

{
return "You assign the sell barricade.";
}
}

public List<string> Aliases
{
get
{
return new List<string>();
}
}

#endregion

public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer player = (UnturnedPlayer)caller;
if(command.Length < 1)
{
UnturnedChat.Say(player, "Invalid syntax: /addhouse <price>", Color.red);
return;
}
decimal cost = 0;
bool IsNumber = decimal.TryParse(command[0], out cost);
var house = Plugin.Instance.getHouseFromObjects(player.Position);
if (!IsNumber)
{
UnturnedChat.Say(player, command[0] + " is not a number!", Color.red);
return;
}
if(house == null)
{
UnturnedChat.Say(player, "Couden't manage to find a level object where you are standing!", Color.red);
return;
}
var incase = (Plugin.Instance.Configuration.Instance.Houses.Find(c => (c.id == house.asset.id)));
if(incase != null)
{
incase.cost = cost;
}
else
{

Plugin.Instance.Configuration.Instance.Houses.Add(new HouseItem(house.asset.id, cost));
}
Plugin.Instance.Configuration.Save();
UnturnedChat.Say(player, "You succesfully added this house to the houselist!", Color.red);
}
}
}
119 changes: 119 additions & 0 deletions CommandBuyHouse.cs
@@ -0,0 +1,119 @@
using fr34kyn01535.Uconomy;
using Rocket.API;
using Rocket.Core.Plugins;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using SDG.Unturned;
using Steamworks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using UnityEngine;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Reflection;
using Rocket.Unturned.Permissions;

namespace Edsparr.Houseplugin
{
public class CommandBuyHouse : IRocketCommand
{
#region Declarations

public bool AllowFromConsole
{
get
{
return false;
}
}

public List<string> Permissions
{
get
{
return new List<string>()
{
"buyhouse"
};
}
}

public AllowedCaller AllowedCaller
{
get
{
return AllowedCaller.Player;
}
}

public bool RunFromConsole
{
get
{
return false;
}
}

public string Name
{
get
{
return "buyhouse";
}
}

public string Syntax
{
get
{
return "apartment (create/select)";
}
}

public string Help
{
get

{
return "You assign the sell barricade.";
}
}

public List<string> Aliases
{
get
{
return new List<string>();
}
}

#endregion

public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer player = (UnturnedPlayer)caller;
Transform house = Plugin.Instance.getHouse(player.Position);
if(house == null)
{
UnturnedChat.Say(player, "Couden't manage to find a house where you're at!", Color.red);
return;
}
if(Plugin.Instance.Configuration.Instance.BoughtHouses.Find(c => (c.house == house.position)) != null)
{
UnturnedChat.Say(player, "This house is already bought!", Color.red);
return;
}
if(Uconomy.Instance.Database.GetBalance(player.CSteamID.ToString()) < Plugin.Instance.getCost(Plugin.Instance.getHouse(player.Position)))
{
UnturnedChat.Say(player, "You can't afford this house! It cost " + Plugin.Instance.getCost(Plugin.Instance.getHouse(player.Position)) + "!", Color.red); return;
}
decimal cost = 0;
Plugin.Instance.buyhHouse(Plugin.Instance.getHouse(player.Position), (ulong)player.CSteamID, (ulong)player.Player.quests.groupID, out cost);
UnturnedChat.Say(player, "You succesfully bought this house for " + cost + "!", Color.yellow);
Uconomy.Instance.Database.IncreaseBalance(player.CSteamID.ToString(), -cost);
}
}
}
123 changes: 123 additions & 0 deletions CommandCheckHouse.cs
@@ -0,0 +1,123 @@
using fr34kyn01535.Uconomy;
using Rocket.API;
using Rocket.Core.Plugins;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using SDG.Unturned;
using Steamworks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using UnityEngine;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Reflection;
using Rocket.Unturned.Permissions;

namespace Edsparr.Houseplugin
{
public class CommandCheckHouse : IRocketCommand
{
#region Declarations

public bool AllowFromConsole
{
get
{
return false;
}
}

public List<string> Permissions
{
get
{
return new List<string>()
{
"checkhouse"
};
}
}

public AllowedCaller AllowedCaller
{
get
{
return AllowedCaller.Player;
}
}

public bool RunFromConsole
{
get
{
return false;
}
}

public string Name
{
get
{
return "checkhouse";
}
}

public string Syntax
{
get
{
return "apartment (create/select)";
}
}

public string Help
{
get

{
return "You assign the sell barricade.";
}
}

public List<string> Aliases
{
get
{
return new List<string>();
}
}

#endregion

public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer player = (UnturnedPlayer)caller;
OwnerItem bfound = null;
HouseItem afound = null;
try
{
bfound = Plugin.Instance.Configuration.Instance.BoughtHouses.Find(c => (c.house == Plugin.Instance.getHouse(player.Position).position));
afound = Plugin.Instance.Configuration.Instance.Houses.Find(c => (c.id == Plugin.Instance.getHouseLevelObject(player.Position).id));
}
catch { if (afound != null) { UnturnedChat.Say(player, "This house is not calimed and cost " + afound.cost + "!", Color.red); return; } UnturnedChat.Say(player, "Couden't manage to find a house here!", Color.red); return; }
string final = "";
if(bfound == null && afound != null)
{
final = "This house is not calimed and cost " + afound.cost + "!";
}
else if(bfound != null)
{
final = "This house has been claimed by " + Edsparr.DisplaynameSaver.Plugin.Instance.GetDisplayName((CSteamID)bfound.owner) + " and payed the rent at " + bfound.boughtAt + " of " + afound.cost + "!";
}
else
{
UnturnedChat.Say(player, "House not found!", Color.red);
return;
}
UnturnedChat.Say(player, final, Color.yellow);
}
}
}

0 comments on commit c6106af

Please sign in to comment.