A couple of questions

Question 1:
Hey, so I want to make a command that requires arguments, like !goto <player>, how does one make a command that finds the player and sends them?

Question 2:
I want to make a command like !gotov <player> that will teleport the player to a players vehicle (that they spawned with the Q menu)

Note: I do not want these commands made for ULX, not for any admin mod, just the Player say stuff.

You could do it using Lua Patterns


hook.Add("PlayerSay","goto_command", function(sender,text,_)
    
    -- Makes sure if the player is an Admin, if not it will not work
    if not sender:IsAdmin() then return end
    
    -- Get the arguments
    local _,_,playername = text:find("!goto (%w+)")
    
    -- Find the player
    for k,v in pairs(player.GetAll()) do
        if v:Name() == playername then
            -- Goto them
        end
    end
end)

However this code has some flaws such as you cant goto players with a space in their name.

as for GOING to the players, im not quite sure.

  1. Make a

GM:PlayerSay hook, check if the message starts with “!goto” with

string.sub, then loop through

player.GetAll and compare

Player:Nick with the rest of the message.

  1. Make a

SANDBOX:PlayerSpawnVehicle and cache the vehicle in a table with the client that spawned it’s SteamID as the key, then just do what I said above while also checking if the player does have a vehicle by checking the table. You could use

Player:GetVehicle instead but that only works if the target is in the vehicle.

You can set a player’s position by using

Entity:SetPos and getting the target’s position with

Entity:GetPos.

-snip I’m wrong-

How? It’s returning, not returning an empty string.