mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 21:55:42 +12:00
fix /playername command
This commit is contained in:
parent
d88132a9eb
commit
9944ead90e
2 changed files with 37 additions and 20 deletions
|
@ -446,7 +446,7 @@ namespace HISP.Game.Chat
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (!client.LoggedinUser.MutePrivateMessage && !client.LoggedinUser.MuteAll)
|
if (!client.LoggedinUser.MutePrivateMessage && !client.LoggedinUser.MuteAll)
|
||||||
if (client.LoggedinUser.Username.ToLower() == to.ToLower())
|
if (client.LoggedinUser.Username.ToLower().StartsWith(to.ToLower()))
|
||||||
recipiants.Add(client);
|
recipiants.Add(client);
|
||||||
}
|
}
|
||||||
return recipiants.ToArray();
|
return recipiants.ToArray();
|
||||||
|
|
|
@ -73,7 +73,16 @@ namespace HISP.Server
|
||||||
if (GameServer.IsUserOnline(ranchOwner))
|
if (GameServer.IsUserOnline(ranchOwner))
|
||||||
GameServer.GetUserById(ranchOwner).AddMoney(moneyToAdd);
|
GameServer.GetUserById(ranchOwner).AddMoney(moneyToAdd);
|
||||||
else
|
else
|
||||||
Database.SetPlayerMoney(Database.GetPlayerMoney(ranchOwner) + moneyToAdd, ranchOwner);
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Database.SetPlayerMoney(Database.GetPlayerMoney(ranchOwner) + moneyToAdd, ranchOwner);
|
||||||
|
}
|
||||||
|
catch (OverflowException)
|
||||||
|
{
|
||||||
|
Database.SetPlayerMoney(2147483647, ranchOwner);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3047,7 +3056,14 @@ namespace HISP.Server
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Database.AddMessageToQueue(horseToSell.Owner, Messages.FormatAutoSellSoldOffline(horseToSell.Name, horseToSell.AutoSell, sender.LoggedinUser.Username));
|
Database.AddMessageToQueue(horseToSell.Owner, Messages.FormatAutoSellSoldOffline(horseToSell.Name, horseToSell.AutoSell, sender.LoggedinUser.Username));
|
||||||
Database.SetPlayerMoney((Database.GetPlayerMoney(horseToSell.Owner) + horseToSell.AutoSell), horseToSell.Owner);
|
try
|
||||||
|
{
|
||||||
|
Database.SetPlayerMoney((Database.GetPlayerMoney(horseToSell.Owner) + horseToSell.AutoSell), horseToSell.Owner);
|
||||||
|
}
|
||||||
|
catch (OverflowException)
|
||||||
|
{
|
||||||
|
Database.SetPlayerMoney(2147483647, horseToSell.Owner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
horseToSell.Owner = sender.LoggedinUser.Id;
|
horseToSell.Owner = sender.LoggedinUser.Id;
|
||||||
|
@ -5801,22 +5817,10 @@ namespace HISP.Server
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
channel = Chat.ChatChannel.Dm;
|
channel = Chat.ChatChannel.Dm;
|
||||||
string find = channelString.Substring(1);
|
nameTo = channelString.Substring(1);
|
||||||
nameTo = "";
|
|
||||||
if (find == "")
|
if (nameTo == "")
|
||||||
break;
|
break;
|
||||||
// Search for closest-matching user
|
|
||||||
foreach (GameClient client in GameClient.ConnectedClients)
|
|
||||||
{
|
|
||||||
if (client.LoggedIn)
|
|
||||||
{
|
|
||||||
if (client.LoggedinUser.Username.StartsWith(find))
|
|
||||||
{
|
|
||||||
nameTo = client.LoggedinUser.Username;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5902,7 +5906,7 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
nameTo = GetUserByName(nameTo).Username;
|
nameTo = GetUserByNameStartswith(nameTo).Username;
|
||||||
}
|
}
|
||||||
catch(KeyNotFoundException)
|
catch(KeyNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -5940,7 +5944,7 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
User userTo = GetUserByName(nameTo);
|
User userTo = GetUserByNameStartswith(nameTo);
|
||||||
if (sender.LoggedinUser.MutePlayer.IsUserMuted(userTo))
|
if (sender.LoggedinUser.MutePlayer.IsUserMuted(userTo))
|
||||||
{
|
{
|
||||||
byte[] dmWasBlocked = PacketBuilder.CreateChat(Messages.FormatCantSendYourIgnoringPlayer(userTo.Username), PacketBuilder.CHAT_DM_RIGHT);
|
byte[] dmWasBlocked = PacketBuilder.CreateChat(Messages.FormatCantSendYourIgnoringPlayer(userTo.Username), PacketBuilder.CHAT_DM_RIGHT);
|
||||||
|
@ -7507,6 +7511,19 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
return usersHere.ToArray();
|
return usersHere.ToArray();
|
||||||
}
|
}
|
||||||
|
public static User GetUserByNameStartswith(string username)
|
||||||
|
{
|
||||||
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
|
{
|
||||||
|
if (client.LoggedIn)
|
||||||
|
{
|
||||||
|
if (client.LoggedinUser.Username.ToLower().StartsWith(username.ToLower()))
|
||||||
|
return client.LoggedinUser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new KeyNotFoundException("User was not found.");
|
||||||
|
}
|
||||||
|
|
||||||
public static User GetUserByName(string username)
|
public static User GetUserByName(string username)
|
||||||
{
|
{
|
||||||
foreach(GameClient client in GameClient.ConnectedClients)
|
foreach(GameClient client in GameClient.ConnectedClients)
|
||||||
|
|
Loading…
Add table
Reference in a new issue