Teleporting command script ( SCRIPT HELP )

Anyone got a script that will teleport you to a pos by typing in a word in chat, I want TEAM_STAFF and TEAM_SIT to be able to teleport to setpos 5243.077637 -4066.666748 520.031250;setang 1.525608 90.865730 0.000000 by typing /sit or !sit

Thanks a TON!

Now, I had a script like this but it didn’t work, I’m still working on how to do scripts by myself here’s the one I did.

Client side AKA lua/autorun


DarkRP.declareChatCommand{
	command = "sit",
	description = "Teleport to the sit room",
	delay = 0
}

Server side AKA lua/autorun/server


local function Teleport(ply, args)
	if ply:Team() == TEAM_STAFF then
		ply:SetPos( Vector( 5256.058594 -4067.102783 520.031250 ) )
	end
	return ""
end

Anyone know what I did wrong?

You declared a local function but didn’t hook it into PlayerSay or check if the command was “sit”

Ahhhh ok. I think I get what you’re saying, not trying to be too greedy, but mind showing my a working code?


hook.Add("PlayerSay", "Sit", function(ply, txt)
   if (txt == "!sit" or txt == "/sit") then
      if (ply:Team() == TEAM_STAFF) then
         ply:SetPos(Vector( 5256.058594 -4067.102783 520.031250 ))   
      end
      
      return ""
   end
end)

Where your fuction teleport?

What?

It doesn’t work, I type in chat and nothing happen’s?

Is the player’s team TEAM_STAFF? Where did you put the code?

You need commas between each vector.



ply:SetPos(Vector( 5256.058594, -4067.102783, 520.031250 ))   


Ahh Ok, Lemme try that, and I’m putting it in lua/autorun

[editline]11th August 2016[/editline]

YOOOO it worked! Thanks guys!