Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #196 from ServerMod/game-update/11.1.2
Browse files Browse the repository at this point in the history
Smod 3.10.0
  • Loading branch information
KarlOfDuty committed Feb 6, 2022
2 parents 58ed7e4 + 568040c commit aef4e0e
Show file tree
Hide file tree
Showing 24 changed files with 783 additions and 867 deletions.
18 changes: 9 additions & 9 deletions ExamplePlugin/ExamplePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public float MicroChance
microChance = value;
}
}

// Grabs the "DamageMultiplier" field from the plugin with the ID "dev.plugin", given that the field is a pipe
[PipeLink("dev.plugin", "DamageMultiplier")]
private FieldPipe<float> damageMultiplier;
Expand All @@ -55,8 +55,8 @@ public float MicroChance
public readonly LiveConfig<int> lottoItemCount = new LiveConfig<int>(1);

// Registers lang setting CONFIG_VALUE in exampleplugin with a default of "Config value: " on initialization
[LangOption]
public readonly string _configValue = "Config value: ";
[LangOption]
public readonly string _configValue = "Config value: ";

public override void OnDisable()
{
Expand All @@ -73,7 +73,7 @@ public override void OnEnable()

this.Info(this.Details.name + " has loaded :)");
}

public override void Register()
{
killChance = 0.2f;
Expand All @@ -84,7 +84,7 @@ public override void Register()
// Register multiple events
this.AddEventHandlers(new RoundEventHandler(this));
// Register single event with priority (need to specify the handler type)
this.AddEventHandler(typeof(IEventHandlerPlayerPickupItem), new LottoItemHandler(this), Priority.High);
this.AddEventHandler(typeof(IEventHandlerPlayerPickupItem), new LottoItemHandler(this), Priority.EARLY);
// Register Command(s)
this.AddCommand("hello", new HelloWorldCommand(this));
// Registers config at runtime (in this case it is in Register, so it is on initialization)
Expand All @@ -94,7 +94,7 @@ public override void Register()
// Sets a permission node as a default permission meaning all players will have it unless overridden by a permission plugin
this.AddDefaultPermission("exampleplugin.lottoitem");
}

// Hooks to event called by any plugin
// Hooks can be private as well as public, but all other pipes must be public
[PipeEvent("dev.plugin.OnEpicDeath")]
Expand Down Expand Up @@ -125,9 +125,9 @@ private void OnWhip(Player player, Player target)
public bool GiveLottoItem(Player player)
{
// Makes sure the player is playing on a team that can have items
if (player.TeamRole.Team == TeamType.SPECTATOR ||
player.TeamRole.Team == TeamType.NONE ||
player.TeamRole.Team == TeamType.SCP)
if (player.PlayerRole.Team == TeamType.SPECTATOR ||
player.PlayerRole.Team == TeamType.NONE ||
player.PlayerRole.Team == TeamType.SCP)
{
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions ExamplePlugin/LottoItemHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ public void OnPlayerPickupItem(PlayerPickupItemEvent ev)
if (ev.Item.ItemType == ItemType.COIN)
{
double luckyValue = random.NextDouble();

// Chance of instantly dying
if (luckyValue < plugin.killChance)
{
ev.Player.Kill();
ev.Player.Kill("Was unlucky");
}
else
{
// An array lets other plugins set the values of it in events.
ItemType[] itemPtr = {ItemType.MICROHID};
ItemType[] itemPtr = { ItemType.MICRO_HID };
plugin.InvokeEvent("courtney.example.plugin", itemPtr);

// Get the singular item from the array since indexing it every time is annoying.
ItemType item = itemPtr[0];

// lottoItemCount is automatically read and converted to an int. This gives the item lottoItemCount times to the player.
int count = plugin.lottoItemCount;
plugin.Info($"{nameof(plugin.lottoItemCount)} is {count}");
Expand Down
8 changes: 4 additions & 4 deletions ExamplePlugin/PermissionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ public short CheckPermission(Player player, string permissionName)
};

// Check if the player has a rank.
if (users.ContainsKey(player.SteamId))
if (users.ContainsKey(player.UserID))
{
// Check if the rank exists, steam id 2 above would fail this check as their rank does not exist.
if (ranks.ContainsKey(users[player.SteamId]))
if (ranks.ContainsKey(users[player.UserID]))
{
// Check if the user's rank has this permission listed.
if (ranks[users[player.SteamId]].Contains(permissionName))
if (ranks[users[player.UserID]].Contains(permissionName))
{
// Returns positive to indicate they have the permission.
return 1;
}

// Permission plugins can also support negative permissions in order to negate permissions which are given by default or by other permission handlers
if (ranks[users[player.SteamId]].Contains("-" + permissionName))
if (ranks[users[player.UserID]].Contains("-" + permissionName))
{
// Returns negative to forbid all permission handlers from allowing this permission
return -1;
Expand Down
2 changes: 1 addition & 1 deletion ExamplePlugin/RoundEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void OnRoundStart(RoundStartEvent ev)
{
// Print the player info and then their class info
plugin.Info(player.ToString());
plugin.Info(player.TeamRole.ToString());
plugin.Info(player.PlayerRole.ToString());
}
}
}
Expand Down
80 changes: 35 additions & 45 deletions Smod2/API/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public enum ItemType
NONE = -1,
KEYCARD_JANITOR = 0,
KEYCARD_SCIENTIST = 1,
KEYCARD_SCIENTIST_MAJOR = 2,
KEYCARD_RESEARCH_COORDINATOR = 2,
KEYCARD_ZONE_MANAGER = 3,
KEYCARD_GUARD = 4,
KEYCARD_SENIOR_GUARD = 5,
KEYCARD_NTF_OFFICER = 5,
KEYCARD_CONTAINMENT_ENGINEER = 6,
KEYCARD_NTF_LIEUTENANT = 7,
KEYCARD_NTF_COMMANDER = 8,
Expand All @@ -25,50 +25,40 @@ public enum ItemType
MICRO_HID = 16,
SCP500 = 17,
SCP207 = 18,
WEAPON_MANAGER_TABLET = 19,
AMMO_12_GAUGE = 19,
GUN_E11_SR = 20,
GUN_PROJECT90 = 21,
AMMO556 = 22,
GUN_MP7 = 23,
GUN_CROSSVEC = 21,
AMMO_556_X45 = 22,
GUN_FSP9 = 23,
GUN_LOGICER = 24,
GRENADE_FRAG = 25,
GRENADE_HE = 25,
GRENADE_FLASH = 26,
DISARMER = 27,
AMMO762 = 28,
AMMO9MM = 29,
GUN_USP = 30,
AMMO_44_CAL = 27,
AMMO_762_X39 = 28,
AMMO_9_X19 = 29,
GUN_COM18 = 30,
SCP018 = 31,
SCP268 = 32,
ADRENALINE = 33,
PAINKILLERS = 34,
COIN = 35,
ARMOR_LIGHT = 36,
ARMOR_COMBAT = 37,
ARMOR_HEAVY = 38,
GUN_REVOLVER = 39,
GUN_AK = 40,
GUN_SHOTGUN = 41,
SCP330 = 42,
SCP2176 = 43
}

NULL = -1,
CUP = -1,
JANITOR_KEYCARD = 0,
SCIENTIST_KEYCARD = 1,
MAJOR_SCIENTIST_KEYCARD = 2,
ZONE_MANAGER_KEYCARD = 3,
GUARD_KEYCARD = 4,
SENIOR_GUARD_KEYCARD = 5,
CONTAINMENT_ENGINEER_KEYCARD = 6,
MTF_LIEUTENANT_KEYCARD = 7,
MTF_COMMANDER_KEYCARD = 8,
FACILITY_MANAGER_KEYCARD = 9,
CHAOS_INSURGENCY_DEVICE = 10,
O5_LEVEL_KEYCARD = 11,
COM15 = 13,
MICROHID = 16,
E11_STANDARD_RIFLE = 20,
P90 = 21,
DROPPED_5 = 22,
MP7 = 23,
LOGICER = 24,
FRAG_GRENADE = 25,
FLASHBANG = 26,
DROPPED_7 = 28,
DROPPED_9 = 29,
USP = 30
public enum MedicalItem
{
MEDKIT = ItemType.MEDKIT,
SCP500 = ItemType.SCP500,
SCP207 = ItemType.SCP207,
ADRENALINE = ItemType.ADRENALINE,
PAINKILLERS = ItemType.PAINKILLERS
}

public enum KnobSetting
Expand All @@ -84,18 +74,18 @@ public abstract class Item : IEquatable<Item>
{
public abstract bool InWorld { get; }
public abstract ItemType ItemType { get; }
public abstract bool IsWeapon { get; }
/// <summary>
/// Used so IEquatable is possible so you can compare items.
/// </summary>
public abstract ushort SerialNumber { get; }
public abstract void Remove();
public abstract void Drop();
public abstract Vector GetPosition();
public abstract void SetPosition(Vector pos);
public abstract void SetKinematic(bool doPhysics);
public abstract bool GetKinematic();
public abstract object GetComponent();
public abstract bool IsWeapon { get; }
/// <summary>
/// Used so IEquatable is possible so you can compare items.
/// </summary>
public abstract int UniqueIdentifier { get; }
public abstract Weapon ToWeapon();

public override bool Equals(object obj)
Expand All @@ -105,13 +95,13 @@ public override bool Equals(object obj)

public bool Equals(Item other)
{
return other != null && UniqueIdentifier != 0 && other.UniqueIdentifier != 0 &&
UniqueIdentifier == other.UniqueIdentifier;
return other != null && SerialNumber != 0 && other.SerialNumber != 0 &&
SerialNumber == other.SerialNumber;
}

public override int GetHashCode()
{
return 1780733181 + UniqueIdentifier.GetHashCode();
return 1780733181 + SerialNumber.GetHashCode();
}

public static bool operator ==(Item left, Item right)
Expand Down
Loading

0 comments on commit aef4e0e

Please sign in to comment.