mIRC Home    About    Download    Register    News    Help

Print Thread
#223098 14/07/10 02:09 PM
Joined: Jul 2010
Posts: 23
B
botnoob Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Jul 2010
Posts: 23
Ok, so basically I have a calc script.

Here is coding:

[script]
n0=on *:text:!calculation*:#:{
n1= set %ans [ $+ [ $nick] ] $bytes($calc($remove($2-,$chr(44))),bd)
n2= msg $chan $bytes($calc($remove($2-,$chr(44))),bd)
n3=}


Wondering if anybody could give me a solution so that the users name is displayed and then the answer.

For example if John were to do:
!calculation 1+1

It would come out as:
John, the answer is: 2


Thanks

botnoob #223101 14/07/10 02:18 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Change the msg line to include $nick and write it however you want it to appear... just like if you were typing it to the channel. Note that if you want a comma to be next to the nick, write it as $nick $+ , (that will combine the two so you don't have a space between them).


Invision Support
#Invision on irc.irchighway.net
botnoob #223103 14/07/10 03:13 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Why the $bytes identifier? confused

Below's but a quick scribble - I'm sure you can find some elaborated calculation scripts at the various dedicated mIRCscript websites.
Code:
on *:text:!calc*:#: {

  ; no parameter given: syntax help
  if ($2 == $null) { msg $chan $nick $+ $chr(44) try: !calculation <stuff to calculate> }

  ; parameters don't contain any digit or "pi"
  elseif (!$regex($2-,/(?:\d|pi)/)) { msg $chan Nothing to calculate, $nick $+ ! }

  ; calculation output, with x replaced by *, commas by dots, pi by it's value
  ; note that it isn't supporting $sqrt, $sin, $cos, $tan etc as yet, and odd bracket usage may break the calculation, like in " 5+2*(3 "
  else { msg $chan $nick $+ $chr(44) the answer is: $calc( $replace($2-,x,*,$chr(44),$chr(46),pi,$pi) ) }
}

Horstl #223108 14/07/10 04:30 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Using $bytes is a quick and easy way of getting commas in the output in the correct (standard) locations.

RusselB #223118 14/07/10 06:00 PM
Joined: Jul 2010
Posts: 23
B
botnoob Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Jul 2010
Posts: 23
Cheers guys.
I got it to work, but as seen below I get 2 answers. lol

My finishing code was:

[script]
n0=on *:text:!cal*:#a:{
n1= msg $chan $nick $chan; the answer is $bytes($calc($remove($2-,$chr(44))),bd)
n2=}

Here was the line

[18:57] <~John> !cal 1+1
[18:57] <@JW|Bot> 2
[18:57] <@JW|Bot> John the answer is 2


What part can I take out to remove the first answel and only have the second.

Hope you can help, off to the cinema now and will check when I get beck to see if anybody can help.

Thanks a lot.

Last edited by botnoob; 14/07/10 06:00 PM.
RusselB #223123 14/07/10 07:44 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Ah, I tend to forget about the english way of writing numerary.
For example here in Germany, we put a comma where you put the dot, and sometimes we use dots as the column separator - e.g.: 25,95 €, 5.000,00 € ...renders my suggestion above into a "localized" version... laugh Either is against ISO anyway. whistle

botnoob #223124 14/07/10 07:48 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Most likely, you've loaded more than one script with a matching on text event.
Also note that there's a superfluous "$chan;" identifier in your code.

Horstl #223127 14/07/10 08:54 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
While it is against ISO, it is not against tradition, which, in my experience, overrides technical procedures more often than not.

Additionally, as I understand it, the $bytes uses the general format for your local area as specified in the Windows numeric format. Thus, $bytes in your area may show the format that you are expecting.

RusselB #223130 14/07/10 11:18 PM
Joined: Jul 2010
Posts: 23
B
botnoob Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Jul 2010
Posts: 23
i guess i will just need to fiddle around and do a bit of trial and error.

botnoob #223132 15/07/10 03:04 AM
Joined: Jul 2010
Posts: 23
B
botnoob Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Jul 2010
Posts: 23
Ok I done it.

Works now, and here was my finish product:

[script]
on *:text:!cal*:#:{
/set %calc.answer $bytes($calc($remove($2-,$chr(44))),bd)
msg $chan $nick the answer is %calc.answer
/unset %calc.answer
}

botnoob #223137 15/07/10 01:19 PM
Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
why /set /unset the command /var exist
/var is local variable
/help /var


WorldDMT
chacha #223141 15/07/10 02:20 PM
Joined: Jul 2010
Posts: 23
B
botnoob Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Jul 2010
Posts: 23
It was my friend who has been scripting for a very short amount of time. 5-6 months maybe. But he rewrit it for me, and it has come out exactly how i wanted it. i could always ask him for you if you like?

chacha #223166 16/07/10 12:29 PM
Joined: Sep 2009
Posts: 52
Z
ziv Offline
Babel fish
Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
Pfft, why even use /vars, he should just put it directly in the .msg line.

ziv.

ziv #223299 20/07/10 10:57 PM
Joined: Jul 2010
Posts: 23
B
botnoob Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Jul 2010
Posts: 23
Thanks for everybody that helped me out laugh


Link Copied to Clipboard