mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
when !away #114963 20/03/05 03:48 PM
Joined: Feb 2005
Posts: 27
O
omen_253 Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Feb 2005
Posts: 27
Heya all again , ok i posted this small !rob thing before about a timer for it and it worked great..But this time i need it to able to not rob when someone has typed - !away - within the game any ideas ??


on *:text:!rob*:#Battle: {
if (%rob [ $+ [ $nick ] ] == on) {
msg $nick You Have Already Robbed Someone Within 5 mins!
halt
}
if (%rob [ $+ [ $nick ] ] != on) && ($2 ison #) && (%account [ $+ [ $2 ] ] == on) {
msg $chan $nick Attempts To Rob $2
set %attempt $rand(1,5)
}
if (%attempt == 1) {
set %tthier-money $round($calc(%money [ $+ [ $2 ] ] / 2),0)
msg $chan $nick SuccessFully Robs $2
msg $chan $nick Has Robbed $2 by %tthier-money Money From $2
inc %money [ $+ [ $nick ] ] %tthier-money
dec %money [ $+ [ $2 ] ] %tthier-money
set -u300 %rob [ $+ [ $nick ] ] on
}
else {
msg $chan $nick Has Failed To Rob $2 !
set -u300 %rob [ $+ [ $nick ] ] on
}
}


thx for your time here , many thx smile

Re: when !away #114964 20/03/05 03:58 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
on *:text:!away:#: set %account [ $+ [ $nick ] ] == off
 


Based on your code given, that should stop someone from robbing them.

Hope it works
smile

Re: when !away #114965 20/03/05 04:17 PM
Joined: Feb 2005
Posts: 27
O
omen_253 Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Feb 2005
Posts: 27
Nope i still rob them , thx any ways.. smile

Last edited by omen_253; 20/03/05 04:18 PM.
Re: when !away #114966 20/03/05 05:00 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
It's probably
on *:text:!away:#:set %account [ $+ [ $nick ] ] off
without the == smile

But I would use another set of %vars for that, just to prevent unintended account or rob status changes...

on *:text:!away:#Battle: set %rob.AWAY. [ $+ [ $nick ] ] on
on *:text:!rob*:#Battle: {
if (%rob. [ $+ [ $nick ] ] == on) {
msg $nick You Have Already Robbed Someone Within 5 mins!
halt
}
if (%rob.AWAY. [ $+ [ $2 ] ] == on) {
msg $nick $2 is away!
halt
}
if (%rob. [ $+ [ $nick ] ] != on) && ($2 ison #) && (%account [ $+ [ $2 ] ] == on) {
msg $chan $nick Attempts To Rob $2
if (!$rand(0,4)) {
set %tthier-money $round($calc(%money [ $+ [ $2 ] ] / 2),0)
msg $chan $nick SuccessFully Robs $2
msg $chan $nick Has Robbed $2 by %tthier-money Money From $2
inc %money [ $+ [ $nick ] ] %tthier-money
dec %money [ $+ [ $2 ] ] %tthier-money
set -u300 %rob. [ $+ [ $nick ] ] on
}
else {
msg $chan $nick Has Failed To Rob $2 !
set -u300 %rob [ $+ [ $nick ] ] on
}
}
}

What's still missing I guess: a way to get back after someone types !away smile
on *:text:!back:#Battle: set %rob.AWAY. [ $+ [ $nick ] ]

And some assorted tips and tricks:
- I'm personally fan of using 1 for "on" and 0 for "off": //if (%var) is the same as //if (%var == on) if you use 0 (or $null, %var doesn't exist) for false and 1 for true. It's shorter too smile
- Replaced your $rand(1,5) with !$rand(0,4) -> !0 = 1(true), !1 (or !4) = 0(false)
- I used %rob.AWAY. -> the . makes the separation between the constant part (%rob) and the changing part ($nick) more clear. Not that it matters much since you're probably not reading your Variables section daily wink

Re: when !away #114967 20/03/05 05:16 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
basically it shouldn't matter what was assigned to %account [ $+ [ $nick ] ] as long as it was something other than ON, which is one of the parameters checked in the original script. So while you are correct, the == wasn't required, in theory, it shouldn't have mattered, since the value of %account [ $+ [ $nick ] ] was being changed from ON, therefore making the comparison false

Re: when !away #114968 20/03/05 05:48 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Quote:

Nope i still rob them , thx any ways.. smile


I shall inform the police because of your theiving. grin

Re: when !away #114969 20/03/05 08:18 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
IF your going for preventing uninteneded side effects like I assume you were by using %rob.AWAY.$nick Then you should not have gone and changed the code so much.

Side effects I saw...
(1) A likely uninteneded logic hole has been patched (this in fact my be good)
.. Say that if (%rob [ $+ [ $nick ] ] != on) && ($2 ison #) && (%account [ $+ [ $2 ] ] == on) { Failed but global var %Attempt was 1 at the time, then if (%attempt == 1) { should succeed, it no longer does.
(2) Game logic has been altered, originally If you attempt a !rob and you have not robbed in 30 mins, regardless of what happens you can not attempt a !rob again for 30 mins (changed to 5 mins now)
(3) Global var %Attempt is no longer set, this may or may not be used else where to report the success or failure of the last !rob attempt


Personally, If it had been me , I would have just taken a punt that It would have been ok to do and use /set %account$nick away

Re: when !away #114970 21/03/05 08:55 AM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
for 1) and 3) I hate strange global %vars that noone knows what they're for and change seemingly randomly. In this case, if the %attempt is set or even used somewhere else, the logic behind it is most likely unintended or (intended and) just plain wrong smile So if that %attempt was indeed used elsewhere, he should thank me for breaking it and making him use something that has at least some chance of being correct. :tongue:
I have the strong feeling that the OP always uses /set for local vars (like %attempt, %tthier-money) etc, where it's really better to use /var %attempt = bleh for those, so that they don't interfere with other scripts, giving strange results and that your %variables sections does not look like a collection of counters and stuff smile

for 2) I don't see any half hours in the original code or in mine confused

Re: when !away #114971 21/03/05 10:36 AM
Joined: Feb 2005
Posts: 27
O
omen_253 Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Feb 2005
Posts: 27
OK thx , I have not tried it yet but i will ..
Also this Script which is a game has a - !away !back - part to it i was not sure i you needed it , sorry.
I seem to think it will work from this part within the script.

The - !away !back - part:

on *:text:!Away:#Battle: {
if (%away [ $+ [ $nick ] ] == on) {
msg $nick You Are Already set As Away!
halt
}
else {
msg $nick You Are Now Away!!
set %away [ $+ [ $nick ] ] on
}
}
on *:text:!Back:#Battle: {
if (%away [ $+ [ $nick ] ] != on) {
msg $nick Your Trying To Get back from what?!?!? Your Already Back
}
else {
msg $nick You Are Now Set To Back
unset %away [ $+ [ $nick ] ]
}
}


Also when you try to - !fight - someone in the game who's NIC is set to - !away - you cant which is good smile
It tells you that you cant - !fight - that nic..
I seem to think that is needs to be change to help with not bein able to - !rob - someone when - !away -

on *:text:!fight*:#Battle: {
if (%account [ $+ [ $nick ] ] != on) { msg $nick You Have NO Account | halt }
if (%account [ $+ [ $2 ] ] != on) { msg $nick $2 Has No Account | halt }
if (%away [ $+ [ $nick ] ] == on) { msg $nick You Are Away You Cannot Battle! | halt }
if (%away [ $+ [ $2 ] ] == on) { msg $nick $2 Is Away You cannot Battle | halt }
if (%battle == on) { msg $nick Sorry A Battle Is Already on! | halt }
if (%account [ $+ [ $nick ] ] == on) && (%account [ $+ [ $2 ] ] == on) {
if ($2 ison #) && (%battle != on) {
set %turner $rand(1,2)
if (%turner == 1) {
set %turn $nick
}
if (%turner == 2) {
set %turn $2
}


Thx so much for your time and help here ... smile crazy

Re: when !away #114972 21/03/05 11:03 AM
Joined: Feb 2005
Posts: 27
O
omen_253 Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Feb 2005
Posts: 27
Ok thx i have tried, done this ..

}
on *:text:!Away:#Battle: set %rob.AWAY. [ $+ [ $nick ] ] on
on *:text:!back:#Battle: set %rob.AWAY. [ $+ [ $nick ] ]
on *:text:!rob*:#Battle: {
if (%rob [ $+ [ $nick ] ] == on) {
msg $nick You Have Already Robbed Someone Within 5 mins!
halt
}
if (%rob [ $+ [ $nick ] ] != on) && ($2 ison #) && (%account [ $+ [ $2 ] ] == on) {
msg $chan $nick Attempts To Rob $2
set %attempt $rand(1,5)
}
if (%attempt == 1) {
set %tthier-money $round($calc(%money [ $+ [ $2 ] ] / 2),0)
msg $chan $nick SuccessFully Robs $2
msg $chan $nick Has Robbed $2 by %tthier-money Money From $2
inc %money [ $+ [ $nick ] ] %tthier-money
dec %money [ $+ [ $2 ] ] %tthier-money
set -u300 %rob [ $+ [ $nick ] ] on
}
else {
msg $chan $nick Has Failed To Rob $2 !
set -u300 %rob [ $+ [ $nick ] ] on
}
}


I think it works but not sure as it tells you ---
'omen Has Failed To Rob God !'
Which is in the esle part -
else {
msg $chan $nick Has Failed To Rob $2 !
set -u300 %rob [ $+ [ $nick ] ] on
}
}
confused

Thx for your time and help again .. smile

Re: when !away #114973 21/03/05 04:24 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Just a few tips first, I hope you don't mind...

The /halt is not required in the on *:text:!Away:#Battle: trigger. The else part is skipped anyway, and a return is done automatically at the end of the code. It can change if you are going to add some code after that, and for those cases I'd use /return instead of /halt. /halt also sets $halted for other scripts (.mrc files) and can stop mIRC from displaying the text if it's an on ^*:TEXT

Try to use /var %turn = blah instead of /set %turn blah for those %variables that you only need during the trigger itself. This makes it more clear which variables are for storing information about nicks and which variables are only used to keep some info during the processing of the on TEXT event. For your case: use /set for %away [ $+ [ $nick ] ] and %rob [ $+ [ $nick ] ] but /var for %turn, %turner and such...


set %turner $rand(1,2)
if (%turner == 1) {
set %turn $nick
}
if (%turner == 2) {
set %turn $2
}
You can replace all this with (assuming you only use %turn in this on TEXT event)
if ($rand(0,1)) var %turn = $nick
else var %turn = $2
or even:
var %turn = $iif($rand(0,1),$nick,$2)

Re: when !away #114974 21/03/05 04:40 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
You can remove those %rob.AWAY. stuff since you have your own away stuff.
The green text is the code to check if $nick or $2 is away.
The red text is really made difficult, and it's probably incorrect: if someone successfully robs someone, everyone will be able to unless they are away or robbed less than 300 seconds ago. %attempt == 1 and it's done with /set so it's kept and never changed to 0...
wrong:
set %attempt $rand(1,5)
}
if (%attempt == 1) {




on *:text:!rob*:#Battle: {
if (%rob [ $+ [ $nick ] ] == on) {
msg $nick You Have Already Robbed Someone Within 5 mins!
return
}
if (%away [ $+ [ $nick ] ] == on) {
msg $nick You're away, no robbing when you're away!
return
}
if (%away [ $+ [ $2 ] ] == on) {
msg $nick $2 is away, you cannot rob someone who is away!
return
}

if (%rob [ $+ [ $nick ] ] != on) && ($2 ison #) && (%account [ $+ [ $2 ] ] == on) {
msg $chan $nick Attempts To Rob $2
if ($rand(1,5) == 1) {
set %tthier-money $round($calc(%money [ $+ [ $2 ] ] / 2),0)
msg $chan $nick SuccessFully Robs $2
msg $chan $nick Has Robbed $2 by %tthier-money Money From $2
inc %money [ $+ [ $nick ] ] %tthier-money
dec %money [ $+ [ $2 ] ] %tthier-money
}
else msg $chan $nick Has Failed To Rob $2 !
set -u300 %rob [ $+ [ $nick ] ] on
}
}

Re: when !away #114975 21/03/05 09:59 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
for 1) and 3) I hate strange global %vars that noone knows what they're for and change seemingly randomly. .....


I agree, random vars are hard to work out and also incredibly stupid to have used, like no other script might ever use the word %attempt !??!?!?!?
If i need (choose really since u can always do something else) to store a global var, ill name it %djc.scriptname.releventname (djc is my initials) this keeps all mine together


Quote:
for 2) I don't see any half hours in the original code or in mine confused


original code

The game logic was effected also if Bill does a !rob then unless his cant rob flag is up then it well be set to up, even if the the rob was invalid values (for ex $2 might not be in channel)

While you now allow Bill to repeatedly type !rob untill $2 is not away, is in channel and account is on, and that is a significant change in play ability, part of the game MAY have been that users had to keep a watchfull eye on who was away who wasnt who was in channel who wasnt who had an account and who didnt.

But personally? well i just think the original script was full of holes, like it never even checks if $nick's account is on for a start. So you turn your account off and go around and rob people :-)

Re: when !away #114976 22/03/05 09:25 AM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Ah, well, I don't go around searching the forum for old versions of code if it's posted again in this thread smile I can't help it if the OP changes those timers between threads...

For the holes stuff: maybe it's better to start on paper, write down all triggers (with their required arguments) and for each trigger, think about what needs to be done, and write down all conditions to check for (away, account, status, etc) and write down the reaction. This can all be in pseudocode or just short text. Also, take another sheet of paper and write down all data structures you need ("for each nick an away status") and how you think to keep that data in mIRC (%vars, hash tables, ini files, recalculate, User list, ...)

Then read those things again a few times, check for inconsistencies, omissions, errors, try to do some strange scenario's in your mind and see if they are handled ok. If all that checks out, then you can start scripting in mIRC smile I know it's a lot of work, but for such complex stuff, it usually pays off.

Re: when !away #114977 22/03/05 10:59 AM
Joined: Feb 2005
Posts: 27
O
omen_253 Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Feb 2005
Posts: 27
Thx m8 have not tried it yet but i will tonite...
thx so much for everyones help & time here....
Plus is there any way of adding a limit to !rob what i mean is if i !rob someone they must have more than 1000 money for me to be able to !rob them.
No limit on the person doing the !rob...
Each nics money and stats are in variables..

%moneyomen_253 1331

Also if unsuccessful in !rob i get - Has Failed To Rob God -
can this be set to some type of Chance type punishment for being unsuccessful in a !rob
IE: cant !rob for 1hour
: pay out 500 money to the person you try to !rob
: loss of health
Only to happen to nic that is unsuccessful in !rob
Health is also in variables

else msg $chan $nick Has Failed To Rob $2 !

%healthomen_253 130

How can i set it so that you have to /notice botnic !rob <nic>
so ppl cant tell who is robbing them..
Thx for your time & help here...

Last edited by omen_253; 22/03/05 11:02 AM.
Re: when !away #114978 22/03/05 12:34 PM
Joined: Feb 2005
Posts: 27
O
omen_253 Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Feb 2005
Posts: 27
Welldone it stop ppl from !rob when set to !away.....
thx for your help here thx thx ..
Welldone it working Great thx a million.....
smile

Last edited by omen_253; 22/03/05 12:44 PM.
Re: when !away #114979 22/03/05 01:50 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Quote:
Plus is there any way of adding a limit to !rob what i mean is if i !rob someone they must have more than 1000 money for me to be able to !rob them.


See red stuff:

Quote:
Also if unsuccessful in !rob i get - Has Failed To Rob God -
can this be set to some type of Chance type punishment for being unsuccessful in a !rob
IE: cant !rob for 1hour
: pay out 500 money to the person you try to !rob
: loss of health
Only to happen to nic that is unsuccessful in !rob

See blue stuff:

Quote:
How can i set it so that you have to /notice botnic !rob <nic>
so ppl cant tell who is robbing them..

See green stuff.


Code:
[color:green]on *:NOTICE:!rob *:?: {
  if (($nick !ison #Battle) || ($2 !ison #Battle)) {
    ; $nick or $2 isn't on #battle, so do nothing
    return
  }
[/color]   if (%rob [ $+ [ $nick ] ] == on) {
    msg $nick You Have Already Robbed Someone!
    return
  }
  if (%away [ $+ [ $nick ] ] == on) { 
    msg $nick You're away, no robbing when you're away!
    return
  }
  if (%away [ $+ [ $2 ] ] == on) { 
    msg $nick $2 is away, you cannot rob someone who is away!
    return
  }
[color:red]  if (%money [ $+ [ $2 ] ] &lt; 1000) { 
    msg $nick $2 hasn't got enough money.
    return
  }[/color]

  if (%rob [ $+ [ $nick ] ] != on) &amp;&amp; (%account [ $+ [ $2 ] ] == on) {
    msg $chan $nick Attempts To Rob $2
[color:blue]    ; 20 % chance of success robbing $2
    if ($rand(0,99) &lt; 20) {
      var %tthier-money = $round($calc(%money [ $+ [ $2 ] ] / 2),0)
      msg $chan $nick SuccessFully Robs $2
      msg $chan $nick Has Robbed $2 by %tthier-money Money From $2
      inc %money [ $+ [ $nick ] ] %tthier-money
      dec %money [ $+ [ $2 ] ] %tthier-money
    }
    else {
      ; this is the other 80% chance of not successfully robbing $2
      ; make him lose 10-20 health with a 10% chance
      if (($rand(0,99) &lt; 10) &amp;&amp; ($rand(10,20)) {
        msg $nick $2 saw you and hit you with a trout, you lose $v1 health
        set -u300 %rob [ $+ [ $nick ] ] on
        dec %health [ $+ [ $nick ] ] $v1
        ; you should check if $nick has still got health left :)
      }
      ; OR 5% chance of having to pay 500 money back (or all his money)
      else if ($rand(0,99) &lt; 5) {
        if ((%money [ $+ [ $nick ] ] &lt; 500) || (500)) { }
        dec %money [ $+ [ $nick ] ] $v1
        inc %money [ $+ [ $2 ] ] $v1
        msg $nick $2 saw you and took $v1 money from you!
        set -u300 %rob [ $+ [ $nick ] ] on
      }
      ; OR 15% chance of being unable to rob for 1 hour
      else if ($rand(0,99) &lt; 15) {
        msg $nick $2 saw you and keeps watching you for 1 hour
        set -u3600 %rob [ $+ [ $nick ] ] on
      }[/color] 
      msg $chan $nick Has Failed To Rob $2 !
    }
  } 
}

Re: when !away #114980 22/03/05 03:25 PM
Joined: Feb 2005
Posts: 27
O
omen_253 Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Feb 2005
Posts: 27
Thats working good but for some reason it lets you keep robbing .
The limit is not working ??
But hey its awesome working good..

Re: when !away #114981 22/03/05 04:49 PM
Joined: Feb 2005
Posts: 27
O
omen_253 Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Feb 2005
Posts: 27
Ok thx again ..
the red part - works great smile
The blue part - it seems that it that it only like's 1 esle in there , i dont now i have no clue smile... but i i'n useing most of it ..
and the green part dont like to work...
thx very much i'll keep playing around with it ...
thx again...
smile
this is what i have:

on *:NOTICE:!rob *:?: {
if (($nick !ison #Battle) || ($2 !ison #Battle)) {
; $nick or $2 isn't on #battle, so do nothing
return
}
if (%rob [ $+ [ $nick ] ] == on) {
msg $nick You Have Already Robbed Someone Within 5 mins!
return
}
if (%away [ $+ [ $nick ] ] == on) {
msg $nick You're away, no robbing when you're away!
return
}
if (%away [ $+ [ $2 ] ] == on) {
msg $nick $2 is away, you cannot rob someone who is away!
return
}
if (%money [ $+ [ $2 ] ] < 1000) {
msg $nick $2 hasn't got enough money.
return
}
if (%rob [ $+ [ $nick ] ] != on) && ($2 ison #) && (%account [ $+ [ $2 ] ] == on) {
msg $chan $nick Attempts To Rob $2
if ($rand(0,99) < 20) {
var %tthier-money = $round($calc(%money [ $+ [ $2 ] ] / 2),0)
msg $chan $nick SuccessFully Robs $2
msg $chan $nick Has Robbed $2 by %tthier-money Money From $2
inc %money [ $+ [ $nick ] ] %tthier-money
dec %money [ $+ [ $2 ] ] %tthier-money
}
else msg $chan $nick Has Failed To Rob $2 !
set -u300 %rob [ $+ [ $nick ] ] on
}
}

..wont work with the notice part ...
when i put all that you made it works ..
but can !rob all the time and some it just says

- Attempts To Rob God

and thats it it stops..
.....
Its kool you did great .. i'm trying to make it work ..
thx again

Re: when !away #114982 22/03/05 05:50 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Delete the red part, # has no meaning in a private notice, there is no channel. You could replace # with #Battle, but it's already tested on earlier.

if (%rob [ $+ [ $nick ] ] != on) && ($2 ison #) && (%account [ $+ [ $2 ] ] == on) {


I'm not sure what you mean about multiple else's, so here's an answer to what I think you mean.

An //if can have only one else part, that is correct
BUT in the else part you can have another //if and another else, so

If (test1) echo test1
else if (test2) echo test2
else if (test3) echo test3
else echo no test succeeded
can be written (and is parsed by mIRC as)
Code:
if (test1) echo test1
else {
  if (test2) echo test2
    else {
      if (test3) echo test2
      else {
        echo no test succeeded
      }
    }
  }
} 


The first notation is ofcourse best, since the indentation doesn't keep growing...

Page 1 of 2 1 2