mIRC Home    About    Download    Register    News    Help

Print Thread
#105703 19/12/04 10:54 PM
Joined: Dec 2004
Posts: 18
S
sylain Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: Dec 2004
Posts: 18
I hope this is the right place for it...

var %i = 1
var %x = $$2
/person { if ( $$1 = minus) { var %i = %i - var %x }}
//say person has lost: %x points.
//say person now has: %1 points.
{ if ( $$1 = add) { var %1 = %i + var %x }}
//say person has gained: %x points.
//say person now has: %1 points.
else { halt }


That is my script I have right now, and whenever I run it... it quits me from mIRC frown
Here's what I want it to do:
I type " /person minus 2"
it outputs:
"Person has lost: 2 points"
"Person now has: -1 points"

or I put in "/person add 2"
and it says:
"Person has gained: 2 points"
"Person now has: 3 points"

can someone help me with my situation? confused

Moved to Scripts & Popups

Last edited by Mentality; 19/12/04 11:00 PM.
#105704 20/12/04 01:31 AM
Joined: Dec 2004
Posts: 18
S
sylain Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: Dec 2004
Posts: 18
er... I kinda fixed it...
now, new question
/person {
{ if ( $$1 = minus ) { var %i = %i - %x }
//say person has lost: %x point.
//say god now has: %i points.
}
{ if ( $$1 = add ) { var %i = %i + %x }
//say person has gained: %x point.
//say person now has: %i points.
}
else { halt }
}

that's my script, and I defined the variables in the variable section :tongue:
now, here's the problem: It won't keep track, like.
First time, I add one, so it has 1 point
second time, I add one, and it has 1 point, not two confused

#105705 20/12/04 01:33 AM
Joined: Dec 2004
Posts: 18
S
sylain Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: Dec 2004
Posts: 18
here;s the question:
How can I make a variable that doesn't reset it's calue after every time I use it?

#105706 20/12/04 01:38 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Well, that's a fine mess LOL
I assume that "Person" is a static name, and that this is going into Aliases.
Code:
person {
[color:gray]  ; if the score variable doesn't exist, create it
  ; I used %person as the scoring variable name, change every occurence of if as you wish[/color]
  if !%person { set %person 0 }

[color:gray]  ; set the var to add/minus $2 -- '$replace($1,minus,-,add,+)' changes "add" to "+" or "minus" to "-"
  ; thus the same line is used to increase or decrease the variable[/color]
  set %person %person $replace($1,minus,-,add,+) $$2

[color:gray]  ; '$replace($1,add,gained,minus,lost)' again changes $1, "add" becomes "gained" and "minus" becomes "lost"[/color]
  say Person has $replace($1,add,gained,minus,lost) $2 points
  say Person now has: %person points
}
BTW you can also use "/person + 3", "/person - 2"

#105707 20/12/04 02:08 AM
Joined: Dec 2004
Posts: 18
S
sylain Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: Dec 2004
Posts: 18
Quote:
Well, that's a fine mess LOL
I assume that "Person" is a static name, and that this is going into Aliases.
Code:
person {
[color:gray]  ; if the score variable doesn't exist, create it
  ; I used %person as the scoring variable name, change every occurence of if as you wish[/color]
  if !%person { set %person 0 }

[color:gray]  ; set the var to add/minus $2 -- '$replace($1,minus,-,add,+)' changes "add" to "+" or "minus" to "-"
  ; thus the same line is used to increase or decrease the variable[/color]
  set %person %person $replace($1,minus,-,add,+) $$2

[color:gray]  ; '$replace($1,add,gained,minus,lost)' again changes $1, "add" becomes "gained" and "minus" becomes "lost"[/color]
  say Person has $replace($1,add,gained,minus,lost) $2 points
  say Person now has: %person points
}
BTW you can also use "/person + 3", "/person - 2"
er...thanks ^^;
I'l try it now..
and...
problem frown
now it's saying stuff like:
Person now has: -2 gain 2 + 2 - 2 points
what's wrong?

#105708 20/12/04 02:11 AM
Joined: Dec 2004
Posts: 18
S
sylain Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: Dec 2004
Posts: 18
er...nvm ^^;
Thanks a lot ^^

#105709 20/12/04 02:17 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Err yeah +|- works but I didn't consider those for say line. laugh
  • say Person has $replace($1,+,gained,-,lost,add,gained,minus,lost) $2 points

#105710 20/12/04 02:25 AM
Joined: Dec 2004
Posts: 18
S
sylain Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: Dec 2004
Posts: 18
Quote:
Err yeah +|- works but I didn't consider those for say line. laugh
  • say Person has $replace($1,+,gained,-,lost,add,gained,minus,lost) $2 points
........
Please tell me that doesn't work frown
if so, I have wasted a lot of time for THAT confused

#105711 20/12/04 02:32 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
ROFL
The final code without all the comments is
Code:
person {
  if !%person { set %person 0 }
  set %person %person $replace($1,minus,-,add,+) $$2
  say Person has $replace($1,+,gained,-,lost,add,gained,minus,lost) $2 points
  say Person now has: %person points
}
and yes it should work.


Link Copied to Clipboard