• Welcome to Valhalla Legends Archive.
 

Basic Kick command

Started by titan0060, September 24, 2004, 05:39 AM

Previous topic - Next topic

titan0060

Ok, i've got my access list on my bot an all,  but here's my problem.  I can only add 1 word commands.  For example...
"[trigger]Ops" will des and resign the sender.  how do i add
"[trigger]kick Username"  is there a way i can have the bot recognize "[trigger]kick" as the command and "username" as a variable? right now it view them all as the same.

Please respond either here or at my site.
http://rivalwebz.net

LordNevar

Would look something like this.

EX: Case Kick
If CFG.Trigger = True
send "/kick " Right Or Left(message, Len(message) - 7) depending on your prefrence.
Else
send "Error: Invalid Parameter."
End If



A good fortune may forbode a bad luck, which may in turn disguise a good fortune.
The greatest trick the Devil ever pulled, was convincing the world he didn't exsist.

MyndFyre

#2
Egad!  Isn't there some kind of VB function that splits a string into an array?

My method: split a string into an array based on tokens (split with " " (space) characters) and if the first element in the array takes a parameter, check to make sure that the parameter is there and execute.

Edit: I'm not sure whether or not my method is more efficient or not (I tend to think that, memory- and speed-wise, unless you have to do sever Left() or Right() method calls, it's not particularly better), but it is DEFINITELY cleaner code.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

LordNevar

Was just giving him something basic to go off of for now.

A good fortune may forbode a bad luck, which may in turn disguise a good fortune.
The greatest trick the Devil ever pulled, was convincing the world he didn't exsist.

MyndFyre

Quote from: LordNevar on September 24, 2004, 10:22 AM
Was just giving him something basic to go off of for now.

The problem with code like the snippet you gave him is that when people code like that, you tend to get three nested Left() functions witha Mid$ somewhere and arbitrary indices.

It's okay if the code is like it is right now.  But people don't even declare function results to variables to reuse them... It's just generally nasty.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Networks

#5
Dude it's obvious you don't know your  fucken language and really I don't think anyone should help you. Learn the language and then try to get help. I could understand if you had errors getting it to work.

l2k-Shadow

#6
Give him a break, he's just a little kid who wants to learn.

For kick command u can just replace the trigger, but if you want to use another commands, custom, which are not battle.net commands, you can use one of these methods:

(These are the most newb understandable ways i can think of this)
There are more ways but i'll list 2 possibilities, Replace and Split - Split is better but whichever works for you


'Replace
If Message = Left(LCase(trigger & "kick"), 5) Then
Message= Replace(Message, trigger & "kick ", "")
Send "/kick " & Message

'Split
Dim splt() As String
splt = Split(Message, " ")
Send "/kick " & splt(1)


Hope that helps.
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

CrAz3D

Dim splt() As String
splt = Split(Message, " ")
Send "/kick " & splt(1)

That doesn't work so well if the message is to be more than 1 word.

Dim splt() as String
splt = Split(Right(Message, Len(Message) - 1), " ", 2)
    'Split() seperates the string, by a space, into 2 different strings
    'Using the Right() function as I have, would remove the *trigger*...assuming the trigger is only one character long.
Select Case lcase(splt(0)) 'splt(0) is the first word of the command

case "kick"
Send "/kick "  & splt(1) 'splt(1) is w/e was after the command

end select


Hope this helps/works.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Networks

Cmon man it's all the stuff you can learn in a simple VB book..Believe me I was there just last summer so don't give me that bull.

prck

Quote from: CrAz3D on September 24, 2004, 03:59 PM
Dim splt() As String
splt = Split(Message, " ")
Send "/kick " & splt(1)

That doesn't work so well if the message is to be more than 1 word.

Dim splt() as String
splt = Split(Right(Message, Len(Message) - 1), " ", 2)
    'Split() seperates the string, by a space, into 2 different strings
    'Using the Right() function as I have, would remove the *trigger*...assuming the trigger is only one character long.
Select Case lcase(splt(0)) 'splt(0) is the first word of the command

case "kick"
Send "/kick "  & splt(1) 'splt(1) is w/e was after the command

end select


Hope this helps/works.
You could just do,

send "/kick " & splt(1) & " " & mid(message,len(splt(1)) + 7)

I think that will work  ;)

titan0060

listen, all i need to know how to do is be able to divide a string into two arrays, and none of the code above works.

Minux

#11
Quote from: titan0060 on September 24, 2004, 10:39 PM
listen, all i need to know how to do is be able to divide a string into two arrays, and none of the code above works.

Split by " "

Example

Command = Split(Message, " ")


And don't expect anyone here to go out of their way to make something work for you since you won't bother learning how yourself.

l2k-Shadow

#12
Quote from: titan0060 on September 24, 2004, 10:39 PM
listen, all i need to know how to do is be able to divide a string into two arrays, and none of the code above works.

Buy a VB book and stop spamming the forums. I bought Visual Basic 6 Bible from Borders the other day, i find it quite useful for quick reference for newbs like myself and even bigger newbs like you. Thanks.


'Example: 'Message = "/kick titan0060"
Dim splt() As String
splt = Split(Message, " ")
'splt(0) = "/kick"; splt(1) = titan0060
Send splt(0) & Space(1) & splt(1)
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

titan0060

Thanks, now it finaly works.  if an Admin is present, please close the thread.

titan0060

because my question was answered, theres nothing more to say in this thread.