mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2015
Posts: 6
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Feb 2015
Posts: 6
Hello there,

I was wonder or there is anyone that could help out with a thing for an as simple trivia i could manage to put together to make it work, and read the question / answer from seperate files.

Since i made it respond if a certain variable is in someone his / her sentence.

Now this how i set it up.

3 text files, 1 of the question, 1 for the answer and 1 for the answer but scrambled like for example if the answer is apple i made that in the 3rd file as a**l*, now the annoying thing is i have to make all those hints manual in the 3rd file.

Now my question is, would it be possible for a script to take a variable and scramble that word with *'s or what id want, and change that into a 2nd variable.

Now for part 2, is there a way to make a command like !rank and it would tell the person what place he is a points file like for example.

Person1 = 23
Person2 = 27
Person3 = 15
Person4 = 32

and if person 4 would type !rank "Person4 you are rank #1" if that is a somewhat decent explain :p

Thanks for helping this noobish mIRC user :p

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Originally Posted By: RatkaStream
would it be possible for a script to take a variable and scramble that word with *'s or what id want, and change that into a 2nd variable.


The answer is: yes it is possible. The problem is you haven't really explained "what [you]'d want". It's easy to replace all letters, or even certain letters, with *, for example:

//echo -a $replace(foo, f, *, o, *)

But that's probably not what you want. I'm guessing you may want some randomness involved? If so, you could do something like:

//echo -a $remove($($regsubex(example, /(.)/g, $!iif($rand(1,2) == 1,\1,*) $chr(32)),2),$chr(32))

The problem is these results are extremely unpredictable and probably not what you really want either. Here are a couple of runs:

*xamp**
exa*pl*
e**mpl*
exa*pl*
**am**e

A lot of those are way too much of a hint. You could control how many *'s you add, but even then, you probably want to manually control the way you slowly expose the word via hints. In other words, you probably don't want to automate this.

Originally Posted By: RatkaStream
Now for part 2, is there a way to make a command like !rank and it would tell the person what place he is


You can use /filter -a to sort the file into a hidden @window and then use the line numbers to represent the rank. This is an expensive call, so you should not do it on request, but you should perform this /filter at the end of each round (or whenever points are assigned) and keep the @window active throughout your game. Basically:

Code:
alias trivia.endround { | ; when the round ends
  assignPoints
  filter -fwca ranks.txt @trivia.rank trivia.ranksorter *
}


Then when someone wants their rank you can use $fline to find the line, and the index represents their rank.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Feb 2015
Posts: 6
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Feb 2015
Posts: 6
Regarding the first one, that actualy works fine laugh

Altho it does do the thing with spaces as well, not entirely sure or thers a way to leave the spaces as they are, and like, because i do tend to use like variable have those uhm , i believe token calls for multiple correct answers.

like %TriviaAnswer Answer1,Answer2,Answer3

is there a way to like for example pick the first one, in that case Answer1 and just scramble that and change it into another variable. like it would become

%TriviaHint **n*w***

but considering the 2nd is as u say then an expensive call, guess ill leave it out, and probaly just use this thing then for telling who the top 5 or something.

none the less thanks for the already great help so far :p

Last edited by RatkaStream; 21/11/15 03:56 AM.
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You can use $gettok() to get part of a string, see /help $gettok, which has examples for pretty much exactly what you want. Use that in conjunction with the above $replace or $regsubex code to "scramble" it.

As for your response to point 2, note that my point was sorting ranks is only expensive if you run it at each user request (!rank). If you do it at the end of each round for all [active] players, it's actually not that expensive. If you continually prune the list to a "top 10" or "top 20", it's not that expensive at all.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Link Copied to Clipboard