本文整理汇总了C#中NetUser类的典型用法代码示例。如果您正苦于以下问题:C# NetUser类的具体用法?C# NetUser怎么用?C# NetUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetUser类属于命名空间,在下文中一共展示了NetUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdChatProd
void cmdChatProd(NetUser netuser, string command, string[] args)
{
if (!hasAccess(netuser)) { SendReply(netuser, "You don't have access to this command"); return; }
cachedCharacter = netuser.playerClient.rootControllable.idMain.GetComponent<Character>();
if (!MeshBatchPhysics.Raycast(cachedCharacter.eyesRay, out cachedRaycast, out cachedBoolean, out cachedhitInstance)) { SendReply(netuser, "Are you looking at the sky?"); return; }
if (cachedhitInstance != null)
{
cachedCollider = cachedhitInstance.physicalColliderReferenceOnly;
if (cachedCollider == null) { SendReply(netuser, "Can't prod what you are looking at"); return; }
cachedStructure = cachedCollider.GetComponent<StructureComponent>();
if (cachedStructure != null && cachedStructure._master != null)
{
cachedMaster = cachedStructure._master;
var name = PlayerDatabase?.Call("GetPlayerData", cachedMaster.ownerID.ToString(), "name");
SendReply(netuser, string.Format("{0} - {1} - {2}", cachedStructure.gameObject.name, cachedMaster.ownerID.ToString(), name == null ? "UnknownPlayer" : name.ToString()));
return;
}
}
else
{
cachedDeployable = cachedRaycast.collider.GetComponent<DeployableObject>();
if (cachedDeployable != null)
{
var name = PlayerDatabase?.Call("GetPlayerData", cachedDeployable.ownerID.ToString(), "name");
SendReply(netuser, string.Format("{0} - {1} - {2}", cachedDeployable.gameObject.name, cachedDeployable.ownerID.ToString(), name == null ? cachedDeployable.ownerName.ToString() : name.ToString()));
return;
}
}
SendReply(netuser, string.Format("Can't prod what you are looking at: {0}",cachedRaycast.collider.gameObject.name));
}
示例2: cmdSpawnOpen
void cmdSpawnOpen(NetUser player, string command, string[] args)
{
if (!hasAccess(player)) return;
if (SpawnsData.ContainsKey(player))
{
SendReply(player, "You must save/close your current spawns first. /spawns_help for more informations");
return;
}
if (args == null || args.Length == 0)
{
SendReply(player, "/spawns_remove SPAWN_NUMBER");
return;
}
var NewSpawnFile = Interface.GetMod().DataFileSystem.GetDatafile(args[0].ToString());
if (NewSpawnFile["1"] == null)
{
SendReply(player, "This spawnfile is empty or not valid");
return;
}
SpawnsData.Add(player, new List<Vector3>());
foreach (KeyValuePair<string, object> pair in NewSpawnFile)
{
var currentvalue = pair.Value as Dictionary<string, object>;
((List<Vector3>)SpawnsData[player]).Add(new Vector3(Convert.ToInt32(currentvalue["x"]), Convert.ToInt32(currentvalue["y"]), Convert.ToInt32(currentvalue["z"])));
}
SendReply(player, string.Format("Opened spawnfile with {0} spawns", ((List<Vector3>)SpawnsData[player]).Count.ToString()));
}
示例3: cmdChatClean
void cmdChatClean(NetUser netuser, string command, string[] args)
{
if (!hasAccess(netuser)) { SendReply(netuser, "You dont have access to this command."); return; }
if(args.Length == 0)
{
SendReply(netuser, "You must enter deployed item name that you want to clean.");
SendReply(netuser, "Not using the option: \"all\" will only clean items that are not on a structure.");
SendReply(netuser, "using the option: \"all\" will only clean all the items.");
SendReply(netuser, "/clean DEPLOYNAME optional:all");
return;
}
cachedName = args[0].ToLower();
int totalCleaned = 0;
bool all = (args.Length > 1 && args[1] == "all") ? true : false;
switch (args[0].ToLower())
{
case "lootsack":
case "bag":
case "lootsacks":
case "bags":
totalCleaned = CleanAllSacks(all);
break;
default:
var getvalidname = ValidDeploy(cachedName);
if (getvalidname == null)
{
SendReply(netuser, string.Format("{0} is not a valid deploy name.", args[0]));
return;
}
cachedName = (string)getvalidname;
totalCleaned = CleanAllDeployables(cachedName, all);
break;
}
SendReply(netuser, string.Format("You've successfully cleaned {0} {1}.", totalCleaned.ToString(), args[0]));
}
示例4: RustLegacyLivePlayer
internal RustLegacyLivePlayer(NetUser netUser)
{
this.netUser = netUser;
steamid = netUser.userID;
Character = this;
Object = netUser.playerClient;
}
示例5: uLink_OnPlayerConnected
public void uLink_OnPlayerConnected(uLink.NetworkPlayer player)
{
connectingPlayer = (NetUser)player.localData;
String playerSteamURL = "http://steamcommunity.com/profiles/" + connectingPlayer.userID.ToString();
WebClient wc = new WebClient ();
wc.DownloadStringCompleted += (sender, e) =>
{
userProfilePage = e.Result;
if (lockGroup != "none")
{
if (userProfilePage.IndexOf("http://steamcommunity.com/groups/" + lockGroup) == -1)
{
connectingPlayer.Kick(NetError.Facepunch_Kick_Ban, true);
}
}
Match vacMatch = Regex.Match(userProfilePage, @"^([0-9]{1,5}) day\(s\) since last ban$");
if (vacMatch.Success)
{
int daysSinceBan = Convert.ToInt32(vacMatch.Groups[1].Value);
if (daysSinceBan < minVacDays)
{
connectingPlayer.Kick(NetError.Facepunch_Kick_Ban, true);
}
}
};
wc.DownloadStringAsync(new Uri(playerSteamURL));
}
示例6: cmdChatHouse
void cmdChatHouse(NetUser player, string command, string[] args)
{
if (!hasAccess(player)) { SendReply(player, "You don't have access to this command"); return; }
if (args.Length == 0) { SendReply(player, "/house STEAMID/name"); return; }
string[] steamids;
ulong teststeam;
if(args.Length == 1 && args[0].Length == 17 && ulong.TryParse(args[0],out teststeam))
{
steamids = new string[] { teststeam.ToString() };
}
else
{
var tempsteamids = PlayerDatabase.Call("FindAllPlayers", args[0]);
if(tempsteamids == null)
{
SendReply(player, "You must have the Player Database plugin to use this plugin.");
return;
}
steamids = (string[])tempsteamids;
if(steamids.Length == 0)
{
SendReply(player, "No Players found.");
return;
}
}
userIDToStructure.Clear();
foreach (StructureMaster master in (List<StructureMaster>)StructureMaster.AllStructures)
{
if (userIDToStructure[master.ownerID] == null)
userIDToStructure[master.ownerID] = new List<StructureMaster>();
userIDToStructure[master.ownerID].Add(master);
}
if (userTeleports[player] == null)
userTeleports[player] = new List<Vector3>();
userTeleports[player].Clear();
int currentid = 0;
for (int i = 0; i < steamids.Length; i++)
{
cachedSteamID = steamids[i];
cachedsteamid = Convert.ToUInt64(cachedSteamID);
cachedName = "Unknown";
var tempname = PlayerDatabase?.Call("GetPlayerData", cachedSteamID, "name");
if (tempname != null)
cachedName = tempname.ToString();
if(userIDToStructure[cachedsteamid] == null)
{
SendReply(player, string.Format("{0} - {1}: No Structures Found.",cachedSteamID,cachedName));
continue;
}
foreach(StructureMaster master in userIDToStructure[cachedsteamid])
{
cachedVector3 = FindFirstComponent(master);
userTeleports[player].Add(cachedVector3);
SendReply(player, string.Format("{3} - {0} - {1}: {2}", cachedSteamID, cachedName, cachedVector3.ToString(), currentid.ToString()));
currentid++;
}
}
}
示例7: SendChatMessage
public void SendChatMessage(NetUser netUser, string name, string message = null)
{
if (message == null)
{
message = name;
name = "Server";
}
ConsoleNetworker.SendClientCommand(netUser.networkPlayer, $"chat.add {QuoteSafe(name)} {QuoteSafe(message)}");
}
示例8: cmdSpawnshelp
void cmdSpawnshelp(NetUser player, string command, string[] args)
{
if (!hasAccess(player)) return;
SendReply(player, "Start by making a new data with: /spawns_new");
SendReply(player, "Add new spawn points where you are standing with /spawns_add");
SendReply(player, "Remove a spawn point that you didn't like with /spawns_remove NUMBER");
SendReply(player, "Save the spawn points into a file with: /spawns_save FILENAME");
SendReply(player, "Use /spawns_open later on to open it back and edit it");
SendReply(player, "Use /spawns_close to stop setting points without saving");
}
示例9: cmdSpawnsClose
void cmdSpawnsClose(NetUser player, string command, string[] args)
{
if (!hasAccess(player)) return;
if (!(SpawnsData.ContainsKey(player)))
{
SendReply(player, "You must create a new Spawn file first /spawns_help for more informations");
return;
}
SpawnsData.Remove(player);
SendReply(player, "Spawns file closed without saving");
}
示例10: cmdSpawnAdd
void cmdSpawnAdd(NetUser player, string command, string[] args)
{
if (!hasAccess(player)) return;
if (!(SpawnsData.ContainsKey(player)))
{
SendReply(player, "You must create/open a new Spawn file first /spawns_help for more informations");
return;
}
((List<Vector3>)SpawnsData[player]).Add(player.playerClient.lastKnownPosition);
SendReply(player, string.Format("Added Spawn n°{0}", ((List<Vector3>)SpawnsData[player]).Count));
}
示例11: cmdAddKit
void cmdAddKit(NetUser netuser, string[] args)
{
if (args.Length < 3)
{
SendReply(netuser, "/kit add \"KITNAME\" \"DESCRIPTION\" -option1 -option2 etc, Everything you have in your inventory will be used in the kit");
SendReply(netuser, "Options avaible:");
SendReply(netuser, "-maxXX => max times someone can use this kit. Default is infinite.");
SendReply(netuser, "-cooldownXX => cooldown of the kit. Default is none.");
SendReply(netuser, "-vip => Allow to give this kit only to vip & admins");
SendReply(netuser, "-admin => Allow to give this kit only to admins (set this for the autokit!!!!)");
return;
}
string kitname = args[1].ToString();
string description = args[2].ToString();
bool vip = false;
bool vipp = false;
bool vippp = false;
bool admin = false;
int max = -1;
double cooldown = 0.0;
if (KitsConfig[kitname] != null)
{
SendReply(netuser, string.Format("The kit {0} already exists. Delete it first or change the name.", kitname));
return;
}
if (args.Length > 3)
{
object validoptions = VerifyOptions(args, out admin, out vip, out vipp, out vippp, out max, out cooldown);
if (validoptions is string)
{
SendReply(netuser, (string)validoptions);
return;
}
}
Dictionary<string, object> kitsitems = GetNewKitFromPlayer(netuser);
Dictionary<string, object> newkit = new Dictionary<string, object>();
newkit.Add("items", kitsitems);
if (admin)
newkit.Add("admin", true);
if (vip)
newkit.Add("vip", true);
if (vipp)
newkit.Add("vip+", true);
if (vippp)
newkit.Add("vip++", true);
if (max >= 0)
newkit.Add("max", max);
if (cooldown > 0.0)
newkit.Add("cooldown", cooldown);
newkit.Add("description", description);
KitsConfig[kitname] = newkit;
SaveKits();
}
示例12: cmdChatFly
void cmdChatFly(NetUser netuser, string command, string[] args)
{
if(!hasAccess(netuser)) { SendReply(netuser, "You dont have access to this command."); return; }
if (args.Length == 0 && netuser.playerClient.GetComponent<FlyPlayer>())
{
GameObject.Destroy(netuser.playerClient.GetComponent<FlyPlayer>());
return;
}
float speed = 1f;
if (args.Length > 0) float.TryParse(args[0], out speed);
FlyPlayer newfly = netuser.playerClient.GetComponent<FlyPlayer>();
if(newfly == null) newfly = netuser.playerClient.gameObject.AddComponent<FlyPlayer>();
newfly.Refresh();
newfly.speed = speed;
}
示例13: proccessKitGiven
void proccessKitGiven(NetUser netuser, string kitname, Dictionary<string, object> kitdata, int kitleft)
{
string userid = netuser.playerClient.userID.ToString();
if (KitsData[userid] == null)
{
(KitsData[userid]) = new Dictionary<string, object>();
}
var playerData = (KitsData[userid]) as Dictionary<string, object>;
var currentKitData = new Dictionary<string, object>();
bool write = false;
if (kitdata.ContainsKey("max"))
{
currentKitData.Add("used", (((int)kitdata["max"] - kitleft) + 1));
write = true;
}
if (kitdata.ContainsKey("cooldown"))
{
currentKitData.Add("cooldown", ((double)kitdata["cooldown"] + CurrentTime()));
write = true;
}
if (write)
{
if (playerData.ContainsKey(kitname))
playerData[kitname] = currentKitData;
else
playerData.Add(kitname, currentKitData);
KitsData[userid] = playerData;
}
}
示例14: hasVip
bool hasVip(NetUser netuser, string vipname)
{
if (netuser.CanAdmin()) return true;
return permission.UserHasPermission(netuser.playerClient.userID.ToString(), vipname);
}
示例15: hasAccess
bool hasAccess(NetUser netuser)
{
if (netuser.CanAdmin())
return true;
return false;
}