Code:runOnChat(1) if ( chatClk(owner()) ) { #Do all your chat stuff, remove owner() if you want it to run on any player. }
Heylo everyone...
I got a quick question and need some help.
I want to be able to say stuff in the game Chat and then use that as a "command" if you will.
Right now I'm using something like this:
[highlight=e2]
if (owner():lastSaid() == "!on")
{
#on stuff here
}
[/highlight]
Now I know this is definitely not the best way at all to do this...
It will constantly check this every loop around if an interval is attached.
So is there a way I can possibly only call the Expression when my chat has changed?
I tried using:
[highlight=e2]
if (owner():lastSaidWhen() == LastSaid)
{
#already checked this message!
}
[/highlight]
Is this the best approach?
Thanks,
LeonBlade
Code:if (powerLevel > 9000) { print "IT'S OVER 9000!!!11"; }Code:mov #status,1337
Thanks to hunter(some number :P) he helped me with exactly this, what i got out is:
[highlight=e2]
runOnChat(1)
if(chatclk()=owner():lastSpoke()) # You could have your own entity
#there like Pod:lastSpoke()
if(LS=="!mypos"){Do stuff} # LS is an string.
}
[/highlight]
I think its owner():lastSpoke() like that, but i could have any fail in it.
Get out. Seriously, do it.
If you do it like this...
...then you're converting it to lowercase, so its no longer case sensitive, and you can use the string to search for the word so the command doesnt have to be word for word, you can be more or less specific with your commands.Code:Said = owner():lastSaid():lower() if(Said:find("hello")){ #do stuff }
Last edited by LeonBlade; 06-02-2009 at 11:53 PM.
Code:if (powerLevel > 9000) { print "IT'S OVER 9000!!!11"; }Code:mov #status,1337
Switch command?
Get out. Seriously, do it.
I think he mean as in a conditional statement, like an if...elseif...else statement, but only comparing one value for many outcomes.
Do you mean like a toggle? Try this
[highlight=e2]
Command=owner():lastSaid()
if (chatClk(owner())) # or you can do
# if (chatClk() & lastSpoke()=owner()
# NOT lastSaidWhen(), I believe that
# gives you the time that you said something
{
if (Command="Switch")
{
Switch=!Switch
}
#other chat commands you want
}
if (Switch)
{
#Stuff
}[/highlight]
no, a toggle wouldn't be any use here. He means a Switch statement, something like this:
but thats PHP, he means one for E2PHP Code:switch (String)
{
case "What\'s your name?":
echo "My name is ...";
break;
case "What\'s your age?":
echo "My age Is ...";
break;
case "What\'s your gender?":
echo "I\'m a ...";
break;
}
ohh thats easy
[highlight=e2]
Command=owner():lastSaid():lower()
if (chatClk(owner()))
{
if (Command="Hello, how are you?")
{
concmd(say "I am fine. Nice weather we are having.")
}
#other chat commands you want
}[/highlight]
Make sure you have concmd turned on through your console. Although the wiki does not mention how to do that.
Bookmarks