Skip to content

Commit

Permalink
Changed SteamID64 check to use an explicit conversion to the CSteamID…
Browse files Browse the repository at this point in the history
… type. And put target.slay() into a try/catch statement, as that will NRE if the player wasn't found.
  • Loading branch information
cartman-2000 committed Apr 9, 2015
1 parent 46bfeaa commit 1bf1b24
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 20 deletions.
29 changes: 11 additions & 18 deletions CommandSlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,26 @@ public void Execute(RocketPlayer caller, string command)
}

// Check to see if what they put in the command is a valid playername or SteamID64 number, and fail if it isn't.
long parse = 0;
if (long.TryParse(command, out parse))
{
try
{
SteamPlayer targetSteamID = null;
PlayerTool.tryGetSteamPlayer(command, out targetSteamID);
target = RocketPlayer.FromCSteamID(targetSteamID.SteamPlayerID.CSteamID);
}
catch
{
// No match.
}
ulong ulCSteamID = 0;
if (ulong.TryParse(command, out ulCSteamID))
{
target = RocketPlayer.FromCSteamID((Steamworks.CSteamID)ulCSteamID);
}
else
{
target = RocketPlayer.FromName(command);
}
if (target == null)

// Causes the target player to suicide, "if" the player is valid.
try
{
target.Suicide();
}
catch
{
RocketChatManager.Say(caller, String.Format("Cannot find player: {0}", command));
return;
}

// Causes the target player to suicide.
target.Suicide();

// Run with different messages, depending on whether the command was ran from the console, or by a player. If caller equals null, it was sent from the console.
if (caller != null)
{
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.2")]
Binary file modified Ref/Assembly-CSharp-firstpass.dll
Binary file not shown.
Binary file modified Ref/Assembly-CSharp.dll
Binary file not shown.
Binary file modified Ref/RocketAPI.dll
Binary file not shown.
Binary file modified Ref/UnityEngine.dll
Binary file not shown.

0 comments on commit 1bf1b24

Please sign in to comment.