mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2014
Posts: 4
Z
ziz Offline OP
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Jun 2014
Posts: 4
Very new to this. Thought i would mess around with it as a little project but come to a bump in the road.

Here is my code.
Code:
on *:Text:!rank:#:{
  var %exp = $readini(Exp.ini,$+(#,.,$nick),Exp)
  if (%exp isnum 0-5) { %exp = - Recruit - }
  elseif (%exp isnum 6-13) { %exp = ○ Apprentice ○ }
  elseif (%exp isnum 14-22) { %exp = ● Private ● }
  elseif (%exp isnum 23-33) { %exp = ◇ Corporal ◇ }
  elseif (%exp isnum 34-49) { %exp = ◆ Sergeant ◆ }
msg # $nick has $readini(Exp.ini,$+(#,.,$nick),Exp) Exp.
}


This is a shortened less confusing version of my code, but you get the idea. Now, as i don't want people gaining "exp" fast they are not due to get their first exp until around 30 minutes. If they use my !rank command during their first 30 minutes it brings up the message

"user has exp"

How can i make it say something along the lines of

"user has 0 exp. Stay active to gain exp"
_____________________________

Or as an alternative how can I can i make it give new users a one off 1 exp once they join to get them on the ranking list.

Sorry for any confusion and thanks in advance.

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Code:
msg # $nick has $iif($readini(Exp.ini,$+(#,.,$nick),Exp),$v1 Exp.,0 exp. Stay active to gain exp)


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jun 2014
Posts: 4
Z
ziz Offline OP
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Jun 2014
Posts: 4
I understand the code but I'm unsure where I can put that to help my situation. Like I said, I more a less started learning this a day ago so this may seem a stupid question.

I've tried placing it in a variety of places and none give the required output correctly.

Last edited by ziz; 01/06/14 08:28 PM.
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
If you don't know where to put it then you don't understand it at all. Replace your "msg #..." with that.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jun 2014
Posts: 4
Z
ziz Offline OP
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Jun 2014
Posts: 4
I apologise, the first time I tried your line of code it didn't appear to give me what I wanted. Tried again and realised I must of done something wrong.

Unfortunately what I'm trying to achieve isn't quite as simple as what I first put.

Code:
on *:Text:!level:#:{
  var %exp = $readini(Exp.ini,$+(#,.,$nick),Exp) 
  if (%exp isnum 1-5) { %exp = - Recruit - }
  elseif (%exp isnum 6-13) { %exp = ○ Apprentice ○ }
  elseif (%exp isnum 14-22) { %exp = ● Private ● }
  elseif (%exp isnum 23-33) { %exp = ◇ Corporal ◇ }
  msg # $nick is a Level $iif($readini(Rank.ini,$+(#,.,$nick),Rank),$v1 Rank.,0 %exp with $iif($readini(Exp.ini,$+(#,.,$nick),Exp),$v1 Exp.,0  Exp. Stay active to gain Exp)
}


As you can see I also have a separate "Rank" which is also displayed. This is on a separate timer.

Ideal outcome "Nick is a Level 20 - recruit - with 102 Exp."

Ideal outcome if new user "Nick is a Level 0 with 0 Exp. Please stay active to gain Exp.

Now, as you can see I have tried to edit the line you gave me suit this. This clearly doesn't work, I'm guessing I can't have the two $iif in one line? If so what is the alternative please?

Sorry to be a pain also how would I go about maxing the "rank" level at 50 as I have not used the isnum method for this and it just simply adds 1 to the rank every 40 minutes. Is it possible to stop this going past 50?

Code:
on !*:join:#:{
  $+(.timerrank.,#,.,$nick) 0 2880 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
  if ((%floodjoin) || ($($+(%,floodjoin.,$nick),2))) { return }
  set -u10 %floodjoin On
  set -u30 %floodjoin. $+ $nick On
}
on !*:part:#:$+(.timerrank.,#,.,$nick) off
alias -l add.pts {
  writeini -n Rank.ini $1 Rank $calc($readini(Rank.ini,$1,Rank) + 1)
  if ((%floodpart) || ($($+(%,floodpart.,$nick),2))) { return }
  set -u10 %floodpart On
  set -u30 %floodpart. $+ $nick On

Thanks for the help. Very much appreciated smile

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
You can have however many $iif's as you want, as long as you're using the correct syntax, which you aren't. You also don't need to use another, since the second $iif seems to always be true if the first one is.

Now, tell me how the exp.ini looks like and what it has to do with rank.ini. Cause I can't know for sure. But as far as I can tell, you can just do it with some simple if statements.
Code:
if ($readini(rank.ini,$1,rank) { msg # user is ranked: $v1 }
Code:
if ($readini(exp.ini,$1,exp) { msg # user has $v1 exp. }
You can obviously use $iif to shorten it down to one line in a single message, but if you feel like this way is easier, by all means.

And, to stop going past 50, you just gotta make it only work if it is less than 50.
Code:
alias -l add.pts {
  var %r $readini(Rank.ini,$1,Rank)
  if (%r < 50) writeini -n Rank.ini $1 Rank $calc($v1 + 1)
}


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
Why you dont store level into difference variable?
Code:
on *:Text:!level:#:{
  var %topic = $+(#,.,$nick)
  var %exp = $readini(Exp.ini,%topic,Exp)
  var %rank = $readini(rank.ini,%topic,Rank)
  var %level = $null 
 
  if (!%exp) { var %exp = 0, %level = Please stay active to gain Exp. }
  elseif (%exp isnum 1-5) { %level = - Recruit - }
  elseif (%exp isnum 6-13) { %level = &#9675; Apprentice &#9675; }
  elseif (%exp isnum 14-22) { %level = &#9679; Private &#9679; }
  elseif (%exp isnum 23-33) { %level = &#9671; Corporal &#9671; }
  msg # $nick has %exp exp. Rank: %rank $+ . %level 
}

Joined: Jun 2014
Posts: 4
Z
ziz Offline OP
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Jun 2014
Posts: 4
Right guys! Got it working. Mixed and matched both your suggestions. Might not be the best way to write this little script but it seems to be doing the job fine.

Code:
on *:Text:!level:#:{
  var %topic = $+(#,.,$nick)
  var %exp = $readini(Exp.ini,$+(#,.,$nick),Exp)
  var %rank = $readini(Rank.ini,%topic,Rank)
  var %level = $null 

  if (!%rank) { var %rank = 0 }
  if (!%exp) { var %exp = 0, %exp = - Recruit - }
  elseif (%exp isnum 1-5) { %exp = - Recruit - }
  elseif (%exp isnum 6-13) { %exp = &#9675; Apprentice &#9675; }
  elseif (%exp isnum 14-22) { %exp = &#9679; Private &#9679; }
  elseif (%exp isnum 23-33) { %exp = &#9671; Corporal &#9671; }
  elseif (%exp isnum 34-49) { %exp = &#9670; Sergeant &#9670; }
  msg # $nick is a Level: %rank %exp with $iif($readini(Exp.ini,$+(#,.,$nick),Exp),$v1 Exp.,0 exp. Please stay active to gain exp.)  
}


@Nillen, sorry where do I place the code to stop it going above 50.

Code:
on !*:join:#:{
  $+(.timerrank.,#,.,$nick) 0 2880 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
  if ((%floodjoin) || ($($+(%,floodjoin.,$nick),2))) { return }
  set -u10 %floodjoin On
  set -u30 %floodjoin. $+ $nick On
}
on !*:part:#:$+(.timerrank.,#,.,$nick) off
alias -l add.pts {
  writeini -n Rank.ini $1 Rank $calc($readini(Rank.ini,$1,Rank) + 1)
  if ((%floodpart) || ($($+(%,floodpart.,$nick),2))) { return }
  set -u10 %floodpart On
  set -u30 %floodpart. $+ $nick On
}


Thank you very much. Both were very helpful.


Link Copied to Clipboard