chat_command_teleport 1.0.0

This commit is contained in:
Resxt 2023-02-16 04:13:07 +01:00
parent 505b676e43
commit 3384aef34f
2 changed files with 63 additions and 0 deletions

View File

@ -52,6 +52,18 @@ The player who runs the command dies.
Arguments expected: none. Arguments expected: none.
Example: `!suicide` Example: `!suicide`
## chat_command_teleport.gsc
Teleports a player to another
Arguments expected: (1) the name of the player to teleport (2) the name of the player to teleport to.
| Examples |
|---|
| `!teleport me Eldor` |
| `!teleport Eldor me` |
| `!teleport Eldor Rektinator` |
## chat_command_text_rules.gsc ## chat_command_text_rules.gsc
Prints the server rules in the player's chat. Prints the server rules in the player's chat.

View File

@ -0,0 +1,51 @@
#include scripts\chat_commands;
Init()
{
CreateCommand(level.commands_servers_ports, "teleport", "function", ::TeleportCommand, ["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 = [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);
}