Help with chat commands for E2

Okay, so I’ve made a basic E2 that finds a player (currently, you have to enter the name into the code), and then out puts their X, Y, and Z coordinates. (I’m using it for teleporting)

I’ve been able to set up some chat commands (!set, !teleport, !reset). But when I tried making it so if anything besides my set commands are said, the Chip will reset (with the Hoverdrive, it would turn off “set target” for example). Except, when I tried, it would ignore it when I say the other commands (I can’t get it to set a target or teleport).

I wanted to have it so anything in the chat box would work, because it is annoying to have to say “!reset” every time I use it.

I was also wondering how to set up an internal timer in the E2, so that after activating it, a timer goes for a certain amount of time, and after said amount of time, it automatically resets (would no longer need to worry about chat commands messing up).

Finally, I like to know how to use the findPlayerByName function with chat, so if I type all, or part of someones name, the E2 will start targeting them.

So, can someone give an example on how to set up any/all of those? It would be greatly appreciated.


@name Teleporter
@inputs
@outputs JumpTGT:vector Jump
@persist JumpTGTPly:entity ChatCMD:array

runOnChat(1) # Might need to be runOnTick.

ChatCMD:array = owner():lastSaid():explode(" ") # Splits words apart 

# !teleport <name>
if (ChatCMD:string(1) == "!teleport" & chatClk() & Jump == 0) { # If you say something and your first word is "!teleport". Jump == 0 is there to prevent jumping before reset
  JumpTGTPly = findPlayerByName(ChatCMD:string(2)) # Set the entity to the partial name found as second word
  JumpTGT = JumpTGTPly:pos() + vec(100, 0, 100) # Set the jump target to 100 units above and 100 units to the east. You can change this if you want
  Jump = 1 # PUNCH IT CHEWIE
  timer("Reset", 1000) # A one-second timer.
}

if (clk("Reset")) { # If the timer starts it
  hideChat(1)
  concmd("say Blah") # This is to make sure some other chatter doesn't make you teleport again
  Jump = 0
  hint("Jumper reset", 4)
}

Doesn’t need to be runOnTick()
Instead of using “concmd(say blah)”, just use chatClk(owner())

Try using “hideChat(1)” to make your message not show up in chat, for more epicness.
When using asgards, I found out you need to wait a short amount of time after setting the XYZ coordinates before activating it… Lavacano’s code would probably work with other things, and maybe the asgard thing I found was just one time.
Here’s a code that lets you teleport to someone else or to where you are aiming :smiley:


@name Asgard Teleporter Control Chip
@outputs Xo Yo Zo Xd Yd Zd Send
@persist
@trigger all
runOnChat(1) #Run on chat

#Wire it to the asgard like this:
#Xo = X Origin
#Xd = X Destination

#These will always be this
Xo = owner():pos():x()
Yo = owner():pos():y()
Zo = owner():pos():z()

if (chatClk(owner())) {
Msg = owner():lastSaid():explode(" ") #KABOOM :D
	if (Msg:string(1) == ".tp") { #Teleport to where you aim
		Xd = owner():aimPos():x()
		Yd = owner():aimPos():y()
		Zd = owner():aimPos():z()
		timer("Send",50)
	}
	if (Msg:string(1) == ".goto") { #Teleport to someone else
		Target = findPlayerByName(Msg:string(2))
		Pos = Target:pos() + Target:forward() * 100
		Xd = Pos:x()
		Yd = Pos:y()
		Zd = Pos:z()
		timer("Send",50)
	}
}
if (clk("Send")) {Send = 1} else {Send = 0} #Weee!

Thanks guys .I’ll start trying to splice this into my code.

EDIT:

If I have the findPlayerByname at the beginning of the code, so it has a default person to target, and I use something like “JumpTGTPly = findPlayerByName(ChatCMD:string(2)”, will the chat target only last until I give a new command, or until I give a new chat target?

(If I’m the default target, and use chat to target Bob, will the next command without a name target me, or will Bob remain the target?)

If JumpTGTPly is in persists, it will stay as that person until you use “JumpTGTPly = findPlayerByName(ChatCMD:string(2))” again to replace it.
If you want it to teleport the default target, you could make a second variable called “DefaultPly” and then:



if (Msg:string(2) == "") {*teleport default target*} else {JumpTGTPly = findPlayerByName(Msg:string(2)), *teleport JumpTGTPly*}

If JumPTGTPly is NOT in persists, the E2 will “forget” about that player as soon as the current execution is over.

Okay, so I can have findPlayerByName target me by default, then use Chat to temporarily switch the target to some other player, and it will switch back to me afterwords (as long as I don’t mention any of it in the persists)?

No. By Default I assume you mean like this:


if (first() | duped() {TargetPly = findPlayerByName("Carlisle")}

If you do that while TargetPly is not in persists, it will forget about that after execution, and TargetPly will not exist anymore. Like I said, if you want to be able to switch between another person temporarily and then switch back to you, you need to either code something that changes TargetPly back to you after use, or use 2 different variables.

Edit:
If a variable is not in Persists, it is a “temporary” variable.
Try doing delta ("$") on a variable that is not in persists and you will see. :slight_smile:

thanks for the help

what is the command that teleports me cause i am trying to type the goto thing but that is admin and i tryed changeing it to tele but that aint working

There is no command in the default E2 that allows you to teleport players. People have made custom functions that do, though. These custom functions are only available on a few servers.
The E2s in this thread use an entity from Stargate called the Asgard Teleporter to teleport players.

i know but i cant tele port

This is the typical unanswerable “omg its broken fix it” post.

We can’t help you unless you actually ask a question.

i did how the hell do i tele port because the cammands in the code do not work and i tried changeing them and they still dont work

Agreed. I think chaosbman is a troll!

mokbi is a troll i would remove him before he starts spaming fourms thats what he does cause he hates garrys mod and thinks roblox is better witch it is not so if u guys were smart ban mokbi before spams

At least I didn’t fail grade four english. Are you gonna listen to this troll who just posts run-on sentences, or me? That smart one?

Choose.

he goes to my school and u guys just wait it will happen trust me he allways does this he did it to the roblox fourms and no he will do it to facepunch not to menttion this is a help fourm not an arguing one so i would like some help with my earlyer post and by the way he is already commenting on my other threads he is a sack of crap

Heh heh

i will also add that flarp is a spamer to

Still posting run-on sentences. By the way,
http://forums.macrumors.com/showthread.php?t=194601