1. Hello all, I'm trying to make a plugin which teleports players to a certian position when Initialize, but im not sure how to go about that. I'll share my code and any help is appreciated.
    Code:
      private const string UsePerm = "customspawn.use";
          private void Init()
          {
            permission.RegisterPermission(UsePerm, this);
          }      private void OnPlayerInit(BasePlayer player)
          {
            if (!permission.UserHasPermission(player.UserIDString, UsePerm))
            {
              // do nothing because player does not have correct permission to teleport to spawn location
            } else {
              // if player has correct permission teleport to spawn location
              string x = 12.68355;
              string y = 6.220349;
              string z = -33.45345;
              TeleportToPosition(player, x, y, z);
            }
          }
    
     
  2. Wulf

    Wulf Community Admin

    Where is TeleportToPosition defined and what is the actual issues?
     
  3. Code:
    using Oxide.Core.Libraries.Covalence;
    using System.Collections.Generic;
    using Oxide.Core.Plugins;
    using System;
    using System.Linq;namespace Oxide.Plugins
    {
        [Info("CustomSpawn", "Sonny-Boi", "1.0.0")]
        [Description("Teleport all players to set position when first connected to the server")]    class CustomSpawn : RustPlugin
        {      private const string UsePerm = "customspawn.use";
          private void Init()
          {
            permission.RegisterPermission(UsePerm, this);
          }      private void OnPlayerInit(BasePlayer player)
          {
            if (!permission.UserHasPermission(player.UserIDString, UsePerm))
            {
              // do nothing because player does not have correct permission to teleport to spawn location
            } else {
              // if player has correct permission teleport to spawn location
              string x = 12.68355;
              string y = 6.220349;
              string z = -33.45345;
              TeleportToPosition(player, x, y, z);
            }
          }    }
    }
    
    Error while compiling: CustomSpawn.cs(33,11): error CS0103: The name `TeleportToPosition' does not exist in the current context
     
  4. Wulf

    Wulf Community Admin

    You should be able to use player.Teleport(new Vector3(x, y, z)) if I'm recalling correctly.
     
  5. Sorry for being such a nuisance, it's just that its hard to find coverage on this type of stuff. Thanks alot man, have a great day
     
  6. Wulf

    Wulf Community Admin

    The player.Teleport thing would be from Rust itself (might be player.MovePosition), which you can find using a decompiler such as JustDecompile. Oxide has some of its own methods which can be found via GitHub.
     
  7. Code:
              string x = "12.68355";
              string y = "6.220349";
              string z = "-33.45345";
              player.Teleport(new Vector3(x, y, z));
    Error while compiling: CustomSpawn.cs(34,39): error CS1503: Argument `#1' cannot convert `string' expression to type `float'
     
  8. Wulf

    Wulf Community Admin

    Ah, because you're storing them as strings. Try using them as floats instead without the " around them.
     
  9. How am i meant to accomplish gathering the x y z values from the config, and include the f?
    float f = f;
    float x = Config["x"]'f';
    float y = Config["y"]'f';
    float z = Config["z"]'f';
    player.Teleport(new Vector3(x, y, z));
     
  10. You would have to cast the data types.
    i.e Convert.ToSingle(Config["value"])
     
  11. thank you man, ill try not to post as much