Custom Teleport Position

Hello,
I wanted to add this custom command into ulx, though when I try to use it it doesn’t work. It’s suppose to teleport you to the setpos when typing out the command “!warp admin”. Do you see any errors of why it wouldn’t work?
Thanks.


function Warp( ply )
    if ply:GetUserGroup() == "superadmin" then
        ply:SetPos( Vector(-693.362183,-3244.650146,44.031250) )
        ply:ChatPrint("Teleported to the Admin Room.")
    else
        ply:ChatPrint("You do not have access.")
    end
end
concommand.Add( "!warp admin", Warp )

You’re adding !warp admin as a concommand which is a console command.

One second let me write you something up.

[editline]n[/editline]

[lua]local warps = {
[“admin”] = {allowed = { [“admin”] = true }, position = Vector ( -693.362183, -3244.650146, 44.031250 ),
}

concommand.Add( “warp”,
function ( ply, cmd, args )
if ( not warps[ args[ 1 ] ] ) then
ply:ChatPrint ( “No warps such as “” … args[ 1 ] … “”” )
return
end

	if ( warps[ args[ 1 ] ].allowed[ ply:GetUserGroup ( ) ] ) then
		ply:SetPos ( warps[ args[ 1 ] ].position )
		ply:ChatPrint ( "Teleported to the warp \"" .. args[ 1 ] .. "\"")
	end
end

)[/lua]

Remember that these are concommands ( CONSOLE commands ), not chat commands. Usage would be “warp admin” in the CONSOLE.

Okay Author, and now that I changed “!warp admin” to “admin” it doesn’t teleport me and only prints the chat.

You typed the command in console right??

I typed “warp admin” in console and it says Unknown command: warp.

Where did you put the code?

teleport.lua in ulx.

Put the code in garrysmod/lua/autorun/server/teleport.lua (create new file), or anywhere server side (if you understand what that means)

I made a new file called “teleport.lua” in the place you told me to and added the code inside of it, still not working.

Make sure to restart the server.

-ninja’d-

It restarted, and still nothing.

If the console command doesn’t exist, then the script probably didn’t load.
Try seeing if any errors come up on your end when you load the map.

No errors that I see.

Does the console command exist if you type “warp” in console?

No.

Send me the whole warp.lua you have.

[editline]1st April 2015[/editline]

Location of File if needed: (Host)/garrysmod/lua/autorun/server/(This File)

At the start put: print ("Custom Teleport is working! ")

Restart your server and if the message pops up that means the file is being loaded correctly. If not I’ll tell you something else.