mIRC Home    About    Download    Register    News    Help

Print Thread
[help] Ranking script #236966 05/04/12 04:16 PM
Joined: Apr 2012
Posts: 5
C
ChickyChan Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Apr 2012
Posts: 5
Hello,
I'm trying to write a script to add/check/change someone's ranking on mirc.
So if someone typed "!rank somebody" the script would reply with "Somebody's rank is: Hard [Date added: 12/12/12]"
However, if you try to check the ranking of someone who's not on the list it would reply with: "Somebody does not have a rank, yet."
Typing "!rank" only would give the reply "Please choose a player."

I got this right now but I'm like 99% sure this is rubbish and doesn't work. I also don't know how to add the "[Date added: x/x/x]" part.

Code:
on *:TEXT:!rank *:#: {
var %nick $2-
var %rank
if (!%rank) {
/msg $chan %nick does not have a rank, yet.
return
}
/msg $chan %nick $+ 's rank is: %rank [Date added: ]

The available ranks should be: "Very Easy", "Easy", "Normal", "Hard" and "Very hard".
I'm not sure how to save the playername and rank information, though. I'm thinking of using a .txt file for saving the information.

Now for the part I have no clue how to start at all.
I want the people in my channel to be able to promote/demote a player's rank.
so if someone is currently ranked "Hard" people can type "!promote [Name]" to change his rank to "Very Hard". However, this should require the vote of 5 different people. So if the same person tries to promote the same player again he should get the notice: "You've already voted for [Name]!"
Once the player rank has changed you should be able to vote for the same person again. The same goes for "!demote [Name]".

So what I'm trying to do is overwriting a player's rank with the next higher/lower rank but only if 5 different people have entered the command. After successfully changing the rank, the date the rank was added should also be updated.

Example:
Someone's rank is: Hard [Date added: 1/1/12]

---After 5 users have voted to demote the player---

Someone's rank is: Normal [Date added: 2/2/12]


I would be VERY grateful for any help.

Re: [help] Ranking script [Re: ChickyChan] #236967 05/04/12 05:18 PM
Joined: Mar 2004
Posts: 526
HorseC Offline
Fjord artisan
Offline
Fjord artisan
Joined: Mar 2004
Posts: 526
Originally Posted By: ChickyChan
Hello,
I'm trying to write a script to add/check/change someone's ranking on mirc.
So if someone typed "!rank somebody" the script would reply with "Somebody's rank is: Hard [Date added: 12/12/12]"
However, if you try to check the ranking of someone who's not on the list it would reply with: "Somebody does not have a rank, yet."
Typing "!rank" only would give the reply "Please choose a player."

I got this right now but I'm like 99% sure this is rubbish and doesn't work. I also don't know how to add the "[Date added: x/x/x]" part.

Code:
on *:TEXT:!rank *:#: {
var %nick $2-
var %rank
if (!%rank) {
/msg $chan %nick does not have a rank, yet.
return
}
/msg $chan %nick $+ 's rank is: %rank [Date added: ]

The available ranks should be: "Very Easy", "Easy", "Normal", "Hard" and "Very hard".
I'm not sure how to save the playername and rank information, though. I'm thinking of using a .txt file for saving the information.

Now for the part I have no clue how to start at all.
I want the people in my channel to be able to promote/demote a player's rank.
so if someone is currently ranked "Hard" people can type "!promote [Name]" to change his rank to "Very Hard". However, this should require the vote of 5 different people. So if the same person tries to promote the same player again he should get the notice: "You've already voted for [Name]!"
Once the player rank has changed you should be able to vote for the same person again. The same goes for "!demote [Name]".

So what I'm trying to do is overwriting a player's rank with the next higher/lower rank but only if 5 different people have entered the command. After successfully changing the rank, the date the rank was added should also be updated.

Example:
Someone's rank is: Hard [Date added: 1/1/12]

---After 5 users have voted to demote the player---

Someone's rank is: Normal [Date added: 2/2/12]


I would be VERY grateful for any help.


What you have is a good start smile

I would suggest in what you have written so far you verify $1 has been passed. (that wold be the nickname)

as for date thats not hard, it would be done when you !add or !promote someone...

the !add function would (in my mind) be optional since it could be done via promote..

for !promote, you would take the first parm as the nick and then use $date to pickup the date the !promote was issued and store it along with the nickname via a var
ie var $1 $+ . $+ date $date
This would create a variable nickname.date with the date issued as the value associated with the variable, then you could display it smile

I did not include code, but you should be able to work from here.

Good luck!




Help others! It makes the world a better place, Makes you feel good, and makes you Healthy!
Re: [help] Ranking script [Re: ChickyChan] #236968 05/04/12 06:33 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Here's a quick ini draft.
Note that currenty, it neither addresses flood protection issues, nor will it prevent ballot stuffing by nick hopping. You may reduce the risk of possible abuse if you limit the access to either the channel or the text events themselves (e.g. with the @ event prefix).
Also note that atm you may have a vote in both !promote and !demote of the same nick at the same time...

Code:
; #### SETUP START ####
; channel(s) to trigger the !rank !promote !remote and !add commands at (separate multiple channels by comma)
alias -l rankchan { return #yourchan }

; file to store ranking in. will be created if not existing. if not located in your main mirc directory, put a full path
alias -l rankini { return ranks.ini }

alias -l rank {
  ; possible ranks, lowest to highest. separate by comma
  var %ranks = very easy,easy,normal,hard,very hard

  if ($findtok(%ranks,$1,1,44)) { return $v1 }
  elseif ($gettok(%ranks,$1,44) !isnum) { return $qt($v1) }
  elseif ($1 == 0) { return $numtok(%ranks,44)) }
}

alias -l rankdate { 
  if ($readini(ranks.ini,n,$1,date)) {
    tokenize 32 $v1
    ; output format ($1 is "added/promoted/demoted", $2 is $ctime of $1)
    return $chr(91) $+ $1 $+ : $date($2) $+ $chr(93)
  }
}

; number of votes required for promotion/demotion
alias -l rankvotes { return 5 }
; #### SETUP END ####


on *:text:!rank:$($rankchan): { 
  MSG $chan Please choose a player with !rank PLAYERSNAME
}

on *:text:!rank &:$($rankchan): {
  if ($readini($rankini,n,$2,rank)) { MSG $chan $2 holds the rank of $rank($v1) $rankdate($2) }
  else { MSG $chan $2 does not have a rank, yet. }
}

on *:text:!addplayer &:$($rankchan): {
  if ($readini($rankini,n,$2,rank)) { MSG $chan $2 already holds the rank of $rank($v1) $+ . $rankdate($2) }
  elseif ($2 !isnum) {
    writeini $qt($rankini) $2 rank 1
    writeini $qt($rankini) $2 date added $ctime
    MSG $chan $2 has been granted the rank of $rank(1) $+ .
  }
}

on *:text:!promote &:$($rankchan): { rankchange promote $2 }

on *:text:!demote &:$($rankchan): { rankchange demote $2 }

alias -l rankchange {
  var %r = $readini($rankini,n,$2,rank)
  ; no rank at all
  if (!%r) { MSG $chan $2 does not hold any rank. }
  ; self-vote
  elseif ($2 == $nick) { MSG $chan voting for yourself? Nah! }
  ; beyond limits
  elseif (($1 == promote) && (%r >= $rank(0))) { MSG $chan $2 already holds the highest possible rank of $rank(%r) $rankdate($2) }
  elseif (($1 == demote) && (%r == 1)) { MSG $chan $2 already holds the lowest possible rank of $rank(%r) $rankdate($2) }
  else {
    var %votes = $readini($rankini,n,$2,$1), %action =  $replace($1,mote,motion)
    ; double vote
    if ($istok(%votes,$nick,32)) { MSG $chan $nick $+ , you already voted for the %action of $2 $+ . }
    else {
      MSG $chan $nick votes for the %action of $2 $+ .
      ; not enough votes yet 
      if ($calc($rankvotes - $numtok(%votes,32)) > 1) { writeini $qt($rankini) $2 $1 %votes $nick }
      ; enough votes: promote/demote
      else {
        var %newrank = $iif(($1 == promote),$calc(%r +1),$calc(%r -1))
        writeini $qt($rankini) $2 rank %newrank
        writeini $qt($rankini) $2 date $1 $+ d $ctime
        remini $qt($rankini) $2 promote | remini $qt($rankini) $2 demote
        MSG $chan $2 has been $1 $+ d to the rank of $rank(%newrank) $+ .
      }
    }
  }
}

Re: [help] Ranking script [Re: Horstl] #236969 05/04/12 07:58 PM
Joined: Apr 2012
Posts: 5
C
ChickyChan Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Apr 2012
Posts: 5
Oh my god, thank you so much! It scares me that you've written this "quickly". I'll just try closing the loopholes and the script is perfect smile.
Vielen herzlichen Dank!