JulioGarcia  FAEG  Posts: 431 Joined: May 2009 | How to code random values In Expression To start off Name the expression.
@name Random Values And Chatbot test
We need to define output(s) for it also But for these, we don't have to.
@outputs A
We shouldn't need to have inputs for this type of expression The Code
First off, We Need to write the random line.
A=round(random(1,10))
Now, That would make A Be a random value between 1 and 10 every 0.1 seconds.
This is good for random responses in chat bots,
B=round(random(1,5)) if(B==1) {C="This Is a random Text String!"} if(B==2) {C="LoL TeXt HaX"} if(B==3) {C="Text Random Strig :O!"} if(B==4) {C="Bleep Blop Bloop"} if(B==5) {C="This Text Is Random :D!"}
And Now, For Implementing it into a bot
if(Command:find("test") & !MeSaid) {concmd("Say Chatbot: "+C+")}
That line would make it say What ever C Is equal to, As we set it to a random string
In Order to make the chatbot work, we need some special strings
MeSaid = Command:find("chatbot:")
Command = lastSaid():lower()
Basicly, MeSaid Is to make it not loop,
Without it,
It would say
Chatbot: This is random text! Chatbot: LoL TeXt HaX! Chatbot: Text random of! Chatbot: This is random text! Chatbot: This is random text! Chatbot: This is random text! Chatbot: This is random text!
Until someone else said something, ceasing the function
Or we might be able to do the same without this.
Using the else{command/value change}
But i don't Know how to do it that way.
Mush simpler with !mesaid Other Commands
There are many other things you can do also,
For example
Owner=owner():name()
if(Command:find("owner") & !MeSaid) {concmd("Say Chatbot: My Spawnee is "+Owner+".")}
For Example It would say
Chatbot: My Spawnee is JulioGee.
These are the ones I Use In My Chat Bots
Owner=owner():name() Map=map() Servername=hostname() Playernum=numPlayers() Maxplayernum=maxPlayers() Gamemode=gamemode()
Code Examples are...
if(Command:find("chatbot") & Command:find("map") & !MeSaid){concmd("say chatbot: The map Were on is "+Map+".bsp")}
Chatbot: The map Were on is gm_flatgrass.bsp
if(Command:find("chatbot") & Command:find("server") & !MeSaid){concmd("say chatbot: The server your on is "+Servername+".")}
Chatbot: The server your on is UFA Public Build- [PHX-WireExtras-XtraTools-AWESOME!]
if(Command:find("chatbot") & Command:find("gamemode") & !MeSaid){concmd("say chatbot: Your playing "+Gamemode+".")}
Chatbot: Your playing Sandbox.
if(Command:find("chatbot") & Command:find("how") & Command:find("players") & !MeSaid){concmd("say chatbot: There are "+Playernum+" players.")}
Chatbot: There are 5 players.
if(Command:find("chatbot") & Command:find("max") & Command:find("players") & !MeSaid){concmd("say chatbot: There can be "+Maxplayernum+" Players on at a time")}
Chatbot: There can be 10 Players on at a time.
Thanks For Reading My Basic Chat bot And Values Tutorial A witty saying proves nothing.
![[Image: pedobear432313.gif]](http://www.zilefile.com/files/3741_ijb0g/pedobear432313.gif)
Check out my forum! Click here you silly! BITCH! DO IT ^ (This post was last modified: 10-12-2009 06:56 PM by JulioGarcia.) | |
| 10-02-2009 07:00 PM | |