From cab303f26a54b4b585ac80f8860aec5284d76d2e Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Tue, 21 Mar 2023 03:30:46 +0100 Subject: [PATCH] chat_command_teleport 1.0.0 --- chat_commands/README.md | 19 +++++++++ chat_commands/chat_command_teleport.gsc | 51 +++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 chat_commands/chat_command_teleport.gsc diff --git a/chat_commands/README.md b/chat_commands/README.md index c231b03..93cc459 100644 --- a/chat_commands/README.md +++ b/chat_commands/README.md @@ -70,6 +70,25 @@ set cc_permission_4 "" - If you prefer to display information (error messages, status change etc.) in the player's chat rather than on his screen you can do that on a dedicated server. For this you need to install [t6-gsc-utils.dll](https://github.com/fedddddd/t6-gsc-utils#installation) (dedicated server only) and change `self IPrintLnBold(message);` to `self tell(message);` in the `TellPlayer` function - Support for clantags was added. You can use the player names in-game or in the dvars without having to care about their clantag. The [setClantag function](https://github.com/fedddddd/t6-gsc-utils#chat) replaces the player name so additional work was required to make the script ignore the clantag +## chat_command_teleport.gsc + +Teleports a player to the position of another player. + +| # | Argument | Mandatory | +|---|---|---| +| 1 | The name of the player to teleport | :white_check_mark: | +| 2 | The name of the player to teleport to | :white_check_mark: | + +| Examples | +|---| +| `!teleport me Eldor` | +| `!teleport Eldor me` | +| `!teleport Eldor Rektinator` | + +| Permission level | +|---| +| 2 | + ## chat_command_unlimited_ammo.gsc Toggles unlimited ammo on the targeted player. diff --git a/chat_commands/chat_command_teleport.gsc b/chat_commands/chat_command_teleport.gsc new file mode 100644 index 0000000..7b02ea6 --- /dev/null +++ b/chat_commands/chat_command_teleport.gsc @@ -0,0 +1,51 @@ +#include scripts\chat_commands; + +Init() +{ + CreateCommand(level.chat_commands["ports"], "teleport", "function", ::TeleportCommand, 2, array("default_help_two_players")); +} + + + +/* Command section */ + +TeleportCommand(args) +{ + if (args.size < 2) + { + return NotEnoughArgsError(2); + } + + error = TeleportPlayer(args[0], args[1]); + + if (IsDefined(error)) + { + return error; + } +} + + + +/* Logic section */ + +TeleportPlayer(teleportedPlayerName, destinationPlayerName) +{ + players = []; + names = array(teleportedPlayerName, destinationPlayerName); + + for (i = 0; i < names.size; i++) + { + name = names[i]; + + player = FindPlayerByName(name); + + if (!IsDefined(player)) + { + return PlayerDoesNotExistError(name); + } + + players = AddElementToArray(players, player); + } + + players[0] SetOrigin(players[1].origin); +} \ No newline at end of file