Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ConCommand(commandName = "spawn_as", flags = ConVarFlags.ExecuteOnServer, helpText = "Spawn as a new character. Type body_list for a full list of characters")]
- private static void CCSpawnAs(ConCommandArgs args)
- {
- if (args.Count == 0)
- {
- Debug.Log(MagicVars.SPAWNAS_ARGS);
- return;
- }
- string character = Alias.Instance.GetBodyName(args[0]);
- if (character == null)
- {
- Debug.LogFormat(MagicVars.SPAWN_ERROR + args[0]);
- return;
- }
- CharacterMaster master = args.sender.master;
- if (args.Count > 1)
- {
- NetworkUser player = GetNetUserFromString(args[1]);
- if (player != null) master = player.master;
- else
- {
- Debug.Log(MagicVars.PLAYER_NOTFOUND);
- return;
- }
- }
- if (!master.alive)
- {
- Debug.Log(MagicVars.PLAYER_DEADRESPAWN);
- return;
- }
- GameObject newBody = BodyCatalog.FindBodyPrefab(character);
- if (newBody == null)
- {
- List<string> array = new List<string>();
- foreach (var item in BodyCatalog.allBodyPrefabs)
- {
- array.Add(item.name);
- }
- string list = string.Join("\n", array);
- Debug.LogFormat(MagicVars.SPAWN_ERROR + " --- \n{1}", character, list);
- return;
- }
- master.bodyPrefab = newBody;
- Debug.Log(args.sender.userName + " is spawning as " + character);
- master.Respawn(master.GetBody().transform.position, master.GetBody().transform.rotation);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement