Valhalla Legends Forums Archive | Battle.net Bot Development | Basic Kick command

AuthorMessageTime
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
September 24, 2004, 10:39 AM
LordNevar
Would look something like this.
[code]
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
[/code]

September 24, 2004, 12:56 PM
Myndfyr
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.
September 24, 2004, 3:21 PM
LordNevar
Was just giving him something basic to go off of for now.
September 24, 2004, 3:22 PM
Myndfyr
[quote author=LordNevar link=board=17;threadid=8820;start=0#msg81791 date=1096039352]
Was just giving him something basic to go off of for now.
[/quote]

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.
September 24, 2004, 3:27 PM
Networks
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.
September 24, 2004, 5:37 PM
l2k-Shadow
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

[code]
'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)
[/code]

Hope that helps.
September 24, 2004, 7:41 PM
CrAz3D
[code]Dim splt() As String
splt = Split(Message, " ")
Send "/kick " & splt(1)[/code]
That doesn't work so well if the message is to be more than 1 word.

[code]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
[/code]

Hope this helps/works.
September 24, 2004, 8:59 PM
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.
September 24, 2004, 10:10 PM
prck
[quote author=CrAz3D link=board=17;threadid=8820;start=0#msg81836 date=1096059541]
[code]Dim splt() As String
splt = Split(Message, " ")
Send "/kick " & splt(1)[/code]
That doesn't work so well if the message is to be more than 1 word.

[code]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
[/code]

Hope this helps/works.
[/quote]
You could just do,
[code]
send "/kick " & splt(1) & " " & mid(message,len(splt(1)) + 7)
[/code]
I think that will work ;)
September 24, 2004, 11:19 PM
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.
September 25, 2004, 3:39 AM
Minux
[quote author=titan0060 link=board=17;threadid=8820;start=0#msg81885 date=1096083571]
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.
[/quote]

Split by " "

Example
[code]
Command = Split(Message, " ")
[/code]

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.
September 25, 2004, 5:27 AM
l2k-Shadow
[quote author=titan0060 link=board=17;threadid=8820;start=0#msg81885 date=1096083571]
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.
[/quote]

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.

[code]
'Example: 'Message = "/kick titan0060"
Dim splt() As String
splt = Split(Message, " ")
'splt(0) = "/kick"; splt(1) = titan0060
Send splt(0) & Space(1) & splt(1)
[/code]
September 25, 2004, 6:43 AM
titan0060
Thanks, now it finaly works. if an Admin is present, please close the thread.
September 25, 2004, 3:09 PM
titan0060
because my question was answered, theres nothing more to say in this thread.
September 25, 2004, 4:01 PM
ColT
Noobs, can still learn of this thread.
September 25, 2004, 4:17 PM
Quarantine
Then what difference does it make if its locked or closed?
September 25, 2004, 7:35 PM
CrAz3D
If you don't tell the split function how many strings to split to then it will go as many as there are perimeters
Split(Message, " ", 2) would split it into 2 strings
September 25, 2004, 10:34 PM
titan0060
[quote author=CrAz3D link=board=17;threadid=8820;start=15#msg82033 date=1096151662]
If you don't tell the split function how many strings to split to then it will go as many as there are perimeters
Split(Message, " ", 2) would split it into 2 strings
[/quote]

if u leave it blank though wont it just go on forever?
September 26, 2004, 11:34 AM
CrAz3D
Yes, it will split into MANY strings.

Example:
Message = `kick CrAz3D You're just too awesome dood!

Now, if you don't specify how many strings to split it into you will end up with 7 different strings.

By using what I showed you would would get 2 strings.

string1 = `kick
string2 = CrAz3D You're just too awesome dood!
September 26, 2004, 2:22 PM
titan0060
[quote author=CrAz3D link=board=17;threadid=8820;start=15#msg82106 date=1096208574]
Yes, it will split into MANY strings.

Example:
Message = `kick CrAz3D You're just too awesome dood!

Now, if you don't specify how many strings to split it into you will end up with 7 different strings.

By using what I showed you would would get 2 strings.

string1 = `kick
string2 = CrAz3D You're just too awesome dood!
[/quote]

wait, wouldn't it continue to split this? the only way to split this in 2 is to have
Split=(Message "`kick")

Split=(Message " ") would continue to split this without saying how many to split.

or does it just cut it at the first " "?
September 26, 2004, 2:53 PM
CrAz3D
You should look into the Split function a little more, like how it is layed out. Splitting by `kick wouldn't do you ANY good....Splitting by " " with no declaration of how many strings would keep the splitting 'going on forever'. By using the limit declaration you can specify how many strings to split into.

Array = Split(Message, " ", 2) would split the message into 2 strings, the first string only having 1 word, the second string containing the rest of the words in that Message.
September 26, 2004, 4:16 PM

Search