mIRC Home    About    Download    Register    News    Help

Print Thread
#105913 22/12/04 05:26 AM
L
Latoneyde
Latoneyde
L
Im making a bot and i want it to be a colour on each message......random colour (besides yellow)

How do i do it??

Ps: If u dont know how to get random colours BESIDES yellow just gimme the command for any colour.. i can deal with that and change it

#105914 22/12/04 05:31 AM
Joined: Mar 2004
Posts: 342
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Mar 2004
Posts: 342
you could use $rand:

$rand(v1,v2)
This works in two ways. If you supply it with numbers for v1 and v2, it returns a random number between v1 and v2. If you supply it with letters, it returns a random letter between letters v1 and v2.

and then test the value returend and if it is '8' then call $rand again..

ie: set %color1 $rand(1,15) (valid values are 0 to 15 but you do not want to use 0)

Hope this helps.

#105915 22/12/04 05:41 AM
L
Latoneyde
Latoneyde
L
hmm i havent used $ rand before...


Try telling me the command.. cause ive seen pplz do it but.....


"Greedy" pplz dont wanna share :tongue: laugh

#105916 22/12/04 08:00 AM
D
DaveC
DaveC
D
set %color1 $calc((($rand(1,14) + 7 ) % 15) + 1)

random color from 1,2,3,4,5,6,7,9,10,11,12,13,14,15

#105917 22/12/04 03:30 PM
L
Latoneyde
Latoneyde
L
hmmm... what u told me there isnt workin.... or am i doin sumthing wrong..

#105918 22/12/04 03:42 PM
Joined: Dec 2002
Posts: 3,534
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,534
Do you mean when a message is incoming (On Text) or outgoing (On Input)?

#105919 22/12/04 03:47 PM
L
Latoneyde
Latoneyde
L
On input....

Wheneever i type a message i want it to be in a dif. colour ...not for me but for everyone

#105920 22/12/04 03:57 PM
Joined: Dec 2002
Posts: 3,534
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,534
Code:
on 1:Input:*: {
  if ($left($1-,1) == $readini(mirc.ini, text, commandchar)) { return $1- }
  else { 
    set %color1 $calc((($rand(1,14) + 7 ) % 15) + 1)
    msg $active $chr(3) $+ %color1 $+ $1- $+ $chr(3)
  }
  halt
}

#105921 22/12/04 04:03 PM
Joined: Nov 2003
Posts: 2,321
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,321
/ is always a command char, but your if statement will only check if the text doesn't start with the second command char, so, for example, it would send commands if they were prefixed with / but ~ was your second command char.

This fixes that:

Code:
on *:input:*:{
  if (!$istok(/ $readini($mircini,text,commandchar),$left($1,1),32)) { 
    msg $active $+($chr(3),$base($rand(0,15),10,10,2),$1-) 
    halt
  }
}

#105922 22/12/04 04:17 PM
Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
Don't forget that there could be unrequired results when the string $1- would start with a number, thus possibly corrupting the color code.

Anyway, you already know this, but I'd add a double bold char, or $base($r(0,15),10,10,2) to that expression, just in case.

Greets!

#105923 22/12/04 04:18 PM
K
KaiHeilos
KaiHeilos
K
Found a couple errors in my code and need to fix em @_@
How do i delete posts?

Last edited by KaiHeilos; 22/12/04 04:47 PM.
#105924 22/12/04 04:29 PM
Joined: Nov 2003
Posts: 2,321
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,321
Good point smile


Link Copied to Clipboard