Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: titan0060 on September 24, 2004, 05:39 AM

Title: Basic Kick command
Post by: titan0060 on September 24, 2004, 05:39 AM
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
Title: Re:Basic Kick command
Post by: LordNevar on September 24, 2004, 07:56 AM
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


Title: Re:Basic Kick command
Post by: MyndFyre on September 24, 2004, 10:21 AM
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.
Title: Re:Basic Kick command
Post by: LordNevar on September 24, 2004, 10:22 AM
Was just giving him something basic to go off of for now.
Title: Re:Basic Kick command
Post by: MyndFyre on September 24, 2004, 10:27 AM
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.
Title: Re:Basic Kick command
Post by: Networks on September 24, 2004, 12:37 PM
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.
Title: Re:Basic Kick command
Post by: l2k-Shadow on September 24, 2004, 02:41 PM
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.
Title: Re:Basic Kick command
Post by: 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.
Title: Re:Basic Kick command
Post by: Networks on September 24, 2004, 05:10 PM
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.
Title: Re:Basic Kick command
Post by: prck on September 24, 2004, 06:19 PM
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  ;)
Title: Re:Basic Kick command
Post by: 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.
Title: Re:Basic Kick command
Post by: Minux on September 25, 2004, 12:27 AM
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.
Title: Re:Basic Kick command
Post by: l2k-Shadow on September 25, 2004, 01:43 AM
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)
Title: Re:Basic Kick command
Post by: titan0060 on September 25, 2004, 10:09 AM
Thanks, now it finaly works.  if an Admin is present, please close the thread.
Title: Re:Basic Kick command
Post by: titan0060 on September 25, 2004, 11:01 AM
because my question was answered, theres nothing more to say in this thread.
Title: Re:Basic Kick command
Post by: ColT on September 25, 2004, 11:17 AM
Noobs, can still learn of this thread.
Title: Re:Basic Kick command
Post by: Warrior on September 25, 2004, 02:35 PM
Then what difference does it make if its locked or closed?
Title: Re:Basic Kick command
Post by: CrAz3D on September 25, 2004, 05:34 PM
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
Title: Re:Basic Kick command
Post by: titan0060 on September 26, 2004, 06:34 AM
Quote from: CrAz3D on September 25, 2004, 05:34 PM
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

if u leave it blank though wont it just go on forever?
Title: Re:Basic Kick command
Post by: CrAz3D on September 26, 2004, 09:22 AM
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!
Title: Re:Basic Kick command
Post by: titan0060 on September 26, 2004, 09:53 AM
Quote from: CrAz3D on September 26, 2004, 09:22 AM
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!

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 " "?
Title: Re:Basic Kick command
Post by: CrAz3D on September 26, 2004, 11:16 AM
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.