|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
SONDAGE À CHOIX ILLIMITÉS, TOUT (OU PRESQUE) ÉTANT CONFIGURABLE (HASH-TABLE)
Information sur la source
Description
Tout est dans le titre :x
Je sais qu'il y en a deja pas mal, mais je pense que celui-ci mérite d'être publié :)
Possibilitée "infinie" de choix
Stats de fin :
- meilleurs scores (il marque les égalités)
- plus bas (égalités également)
- ne marque pas les autres, pour ne pas flood, mais pourrait le faire si vous me demandez de changer le code
Si vous voulez en rajouter, contactez moi ...
Source
- alias sondage {
- var %t = 0
- if ($hget(Sondage,Total)) var %t = $hget(Sondage,Total)
- inc %t
- if (!$hget(Sondage)) hmake Sondage 10
- hmake Sondage $+ %t 10
- if (!$hget(Sondage,Total)) hadd Sondage Total 0
- hinc Sondage Total
- hadd Sondage Actuel %t
- hadd $+(Sondage,$hget(Sondage,Actuel)) Question $?="Quelle est la question du sondage ?"
- if (!$hget($+(Sondage,$hget(Sondage,Actuel)),Question)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
- hadd $+(Sondage,$hget(Sondage,Actuel)) Temps $?="Temps pour voter, en secondes ? Supérieur à 10sec"
- if ($hget($+(Sondage,$hget(Sondage,Actuel)),Temps) !isnum) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
- if ($hget($+(Sondage,$hget(Sondage,Actuel)),Temps) < 10) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
- var %t = $?="Combien de choix ?"
- if ((%t <= 0) || (%t !isnum)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
- hadd $+(Sondage,$hget(Sondage,Actuel)) Choix %t
- hadd $+(Sondage,$hget(Sondage,Actuel)) Chan $?="Sur quel salon faire le sondage ?"
- if ($left($hget($+(Sondage,$hget(Sondage,Actuel)),Chan),1) != $chr(35)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
- if ($hget(Sondage,$hget($+(Sondage,$hget(Sondage,Actuel)),Chan))) { echo -a 2 $+ $asctime([HH:nn:ss]) 12,1[ 0Il y a déjà un sondage sur ce salon ! 12] | hdec Sondage Total | hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
- hadd Sondage $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) $hget(Sondage,Actuel)
- if (!$hget($+(Sondage,$hget(Sondage,Actuel)),Chan)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
- if ($me !ison $hget($+(Sondage,$hget(Sondage,Actuel)),Chan)) { echo -a 2 $+ $asctime([HH:nn:ss]) 12,1[ 0Il faut être sur le chan ! 12] | hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
- var %t = 1
- while %t <= $hget($+(Sondage,$hget(Sondage,Actuel)),Choix) {
- while (!$hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,%t))) {
- hadd $+(Sondage,$hget(Sondage,Actuel)) $+(Question,%t) $?="Choix %t ?"
- }
- inc %t
- }
- if ($?!="Voulez-répondre vous même au sondage ?") {
- var %t = $?="Entre le numéro correspondant à votre choix ?"
- if (%t isnum $+(1-,$hget($+(Sondage,$hget(Sondage,Actuel)),Choix))) {
- hinc $+(Sondage,$hget(Sondage,Actuel)) %t
- }
- }
- msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Un nouveau sondage est lancé ! La question est : $hget($+(Sondage,$hget(Sondage,Actuel)),Question) 12]
- var %o = 1
- var %t = 0
- while %o <= $hget($+(Sondage,$hget(Sondage,Actuel)),Choix) {
- inc %t 4.5
- if ($hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,$calc(%o +1)))) { .timersondage. $+ $+(Sondage,$hget(Sondage,Actuel)) $+ . $+ %t -o 1 %t msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Choix $+(%o,) : $hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,%o)) 12::0 Choix $+($calc(%o +1),) : $hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,$calc(%o +1))) 12] | inc %o }
- else .timersondage. $+ $+(Sondage,$hget(Sondage,Actuel)) $+ . $+ %t -o 1 %t msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Choix $+(%o,) : $hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,%o)) 12]
- inc %o
- }
- inc %t 4
- .timersondage.annonce -o 1 %t msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Vous pouvez voter ! Vous avez $duration($hget($+(Sondage,$hget(Sondage,Actuel)),Temps)) pour répondre ! Tapez !sondage "X" 12]
- .timersondage.activer -o 1 %t hadd $+(Sondage,$hget(Sondage,Actuel)) Status ON
- .timersondage.lancer -o 1 %t .timersondage.fin $+ $hget(Sondage,Actuel) -o 1 $hget($+(Sondage,$hget(Sondage,Actuel)),Temps) sondage.fin $hget(Sondage,Actuel)
- }
- ON *:TEXT:!sondage *:#:{
- if (!$hget(Sondage,$chan)) return
- if ($hget($+(Sondage,$hget(Sondage,$chan)),Status) != ON) return
- if ($2 !isnum) return
- if ($hmatch($+(Sondage,$hget(Sondage,$chan)),$address($nick,2))) return
- if (!$hget($+(Sondage,$hget(Sondage,$chan)),$+(Question,$2))) return
- if (!$hget($+(Sondage,$hget(Sondage,$chan)),Total)) hadd Sondage $+(Sondage,$hget(Sondage,$chan)) 0
- if (!$hget($+(Sondage,$hget(Sondage,$chan)),$2)) hadd $+(Sondage,$hget(Sondage,$chan)) $2 0
- hinc $+(Sondage,$hget(Sondage,$chan)) $2
- hinc $+(Sondage,$hget(Sondage,$chan)) Total
- hadd $+(Sondage,$hget(Sondage,$chan)) $address($nick,2) 1
- echo -a 2 $+ $asctime([HH:nn:ss]) 12,1[ 0Le vote a compté ! La proposition $2 a désormais $hget($+(Sondage,$hget(Sondage,$chan)),$2) voix 12]
- }
- alias sondage.fin {
- if (!$1) return
- hadd $+(Sondage,$1) Status OFF
- msg $hget($+(Sondage,$1),Chan) 12,1[ 0Le vote est fini ! Il y a eu $iif($hget($+(Sondage,$1),Total),$ifmatch,0) $+(votes,$iif($hget($+(Sondage,$1),Total),$+($chr(44),$chr(32),merci) à tous,$+($chr(44),$chr(32),pas) terrible ...)) 12]
- if (!$hget($+(Sondage,$1),Total)) return
- unset %l %l2
- var %t = 1
- var %o = 0
- while %t <= $hget($+(Sondage,$1),Choix) {
- var %l = %l $+(%t,-,$iif($hget($+(Sondage,$1),%t),$ifmatch,0))
- var %l2 = %l2 $+($iif($hget($+(Sondage,$1),%t),$ifmatch,0),-,%t)
- inc %t
- }
- if (%l) {
- var %l2 = $sorttok(%l2,32)
- var %l = $sorttok(%l,32)
- var %m = $gettok($gettok(%l2,-1,32),1,45)
- var %s = $wildtok($replace(%l,$+(-,%m),¥),*¥,0,32)
- unset %q
- var %k = 1
- while %k <= %s {
- var %q = %q - $hget($+(Sondage,$1),$+(Question,$remove($wildtok($replace(%l,$+(-,%m),¥),*¥,%k,32),$chr(165))))
- inc %k
- }
- .timerresultat1 -o 1 1 msg $hget($+(Sondage,$1),Chan) 12,1[ 0Il y a %s $+(proposition,$iif(%s > 1,s)) qui $+(l'emporte,$iif(%s > 1,ent)) avec %m voix : $right(%q,-1) 12]
- var %m = $gettok($gettok(%l2,1,32),1,45)
- var %s = $wildtok($replace(%l,$+(-,%m),¥),*¥,0,32)
- unset %q
- var %k = 1
- while %k <= %s {
- var %q = %q - $hget($+(Sondage,$1),$+(Question,$remove($wildtok($replace(%l,$+(-,%m),¥),*¥,%k,32),$chr(165))))
- inc %k
- }
- .timerresultat2 -o 1 2 msg $hget($+(Sondage,$1),Chan) 12,1[ 0Il y a %s $+(proposition,$iif(%s > 1,s)) ayant receuilli le moins de voix $+($chr(40),%m,$chr(41)) : $right(%q,-1) 12]
- }
- hdel Sondage $hget($+(Sondage,$1),Chan)
- hfree $+(Sondage,$1)
- }
alias sondage {
var %t = 0
if ($hget(Sondage,Total)) var %t = $hget(Sondage,Total)
inc %t
if (!$hget(Sondage)) hmake Sondage 10
hmake Sondage $+ %t 10
if (!$hget(Sondage,Total)) hadd Sondage Total 0
hinc Sondage Total
hadd Sondage Actuel %t
hadd $+(Sondage,$hget(Sondage,Actuel)) Question $?="Quelle est la question du sondage ?"
if (!$hget($+(Sondage,$hget(Sondage,Actuel)),Question)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
hadd $+(Sondage,$hget(Sondage,Actuel)) Temps $?="Temps pour voter, en secondes ? Supérieur à 10sec"
if ($hget($+(Sondage,$hget(Sondage,Actuel)),Temps) !isnum) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
if ($hget($+(Sondage,$hget(Sondage,Actuel)),Temps) < 10) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
var %t = $?="Combien de choix ?"
if ((%t <= 0) || (%t !isnum)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
hadd $+(Sondage,$hget(Sondage,Actuel)) Choix %t
hadd $+(Sondage,$hget(Sondage,Actuel)) Chan $?="Sur quel salon faire le sondage ?"
if ($left($hget($+(Sondage,$hget(Sondage,Actuel)),Chan),1) != $chr(35)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
if ($hget(Sondage,$hget($+(Sondage,$hget(Sondage,Actuel)),Chan))) { echo -a 2 $+ $asctime([HH:nn:ss]) 12,1[ 0Il y a déjà un sondage sur ce salon ! 12] | hdec Sondage Total | hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
hadd Sondage $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) $hget(Sondage,Actuel)
if (!$hget($+(Sondage,$hget(Sondage,Actuel)),Chan)) { hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
if ($me !ison $hget($+(Sondage,$hget(Sondage,Actuel)),Chan)) { echo -a 2 $+ $asctime([HH:nn:ss]) 12,1[ 0Il faut être sur le chan ! 12] | hfree $+(Sondage,$hget(Sondage,Actuel)) | return }
var %t = 1
while %t <= $hget($+(Sondage,$hget(Sondage,Actuel)),Choix) {
while (!$hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,%t))) {
hadd $+(Sondage,$hget(Sondage,Actuel)) $+(Question,%t) $?="Choix %t ?"
}
inc %t
}
if ($?!="Voulez-répondre vous même au sondage ?") {
var %t = $?="Entre le numéro correspondant à votre choix ?"
if (%t isnum $+(1-,$hget($+(Sondage,$hget(Sondage,Actuel)),Choix))) {
hinc $+(Sondage,$hget(Sondage,Actuel)) %t
}
}
msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Un nouveau sondage est lancé ! La question est : $hget($+(Sondage,$hget(Sondage,Actuel)),Question) 12]
var %o = 1
var %t = 0
while %o <= $hget($+(Sondage,$hget(Sondage,Actuel)),Choix) {
inc %t 4.5
if ($hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,$calc(%o +1)))) { .timersondage. $+ $+(Sondage,$hget(Sondage,Actuel)) $+ . $+ %t -o 1 %t msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Choix $+(%o,) : $hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,%o)) 12::0 Choix $+($calc(%o +1),) : $hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,$calc(%o +1))) 12] | inc %o }
else .timersondage. $+ $+(Sondage,$hget(Sondage,Actuel)) $+ . $+ %t -o 1 %t msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Choix $+(%o,) : $hget($+(Sondage,$hget(Sondage,Actuel)),$+(Question,%o)) 12]
inc %o
}
inc %t 4
.timersondage.annonce -o 1 %t msg $hget($+(Sondage,$hget(Sondage,Actuel)),Chan) 12,1[ 0Vous pouvez voter ! Vous avez $duration($hget($+(Sondage,$hget(Sondage,Actuel)),Temps)) pour répondre ! Tapez !sondage "X" 12]
.timersondage.activer -o 1 %t hadd $+(Sondage,$hget(Sondage,Actuel)) Status ON
.timersondage.lancer -o 1 %t .timersondage.fin $+ $hget(Sondage,Actuel) -o 1 $hget($+(Sondage,$hget(Sondage,Actuel)),Temps) sondage.fin $hget(Sondage,Actuel)
}
ON *:TEXT:!sondage *:#:{
if (!$hget(Sondage,$chan)) return
if ($hget($+(Sondage,$hget(Sondage,$chan)),Status) != ON) return
if ($2 !isnum) return
if ($hmatch($+(Sondage,$hget(Sondage,$chan)),$address($nick,2))) return
if (!$hget($+(Sondage,$hget(Sondage,$chan)),$+(Question,$2))) return
if (!$hget($+(Sondage,$hget(Sondage,$chan)),Total)) hadd Sondage $+(Sondage,$hget(Sondage,$chan)) 0
if (!$hget($+(Sondage,$hget(Sondage,$chan)),$2)) hadd $+(Sondage,$hget(Sondage,$chan)) $2 0
hinc $+(Sondage,$hget(Sondage,$chan)) $2
hinc $+(Sondage,$hget(Sondage,$chan)) Total
hadd $+(Sondage,$hget(Sondage,$chan)) $address($nick,2) 1
echo -a 2 $+ $asctime([HH:nn:ss]) 12,1[ 0Le vote a compté ! La proposition $2 a désormais $hget($+(Sondage,$hget(Sondage,$chan)),$2) voix 12]
}
alias sondage.fin {
if (!$1) return
hadd $+(Sondage,$1) Status OFF
msg $hget($+(Sondage,$1),Chan) 12,1[ 0Le vote est fini ! Il y a eu $iif($hget($+(Sondage,$1),Total),$ifmatch,0) $+(votes,$iif($hget($+(Sondage,$1),Total),$+($chr(44),$chr(32),merci) à tous,$+($chr(44),$chr(32),pas) terrible ...)) 12]
if (!$hget($+(Sondage,$1),Total)) return
unset %l %l2
var %t = 1
var %o = 0
while %t <= $hget($+(Sondage,$1),Choix) {
var %l = %l $+(%t,-,$iif($hget($+(Sondage,$1),%t),$ifmatch,0))
var %l2 = %l2 $+($iif($hget($+(Sondage,$1),%t),$ifmatch,0),-,%t)
inc %t
}
if (%l) {
var %l2 = $sorttok(%l2,32)
var %l = $sorttok(%l,32)
var %m = $gettok($gettok(%l2,-1,32),1,45)
var %s = $wildtok($replace(%l,$+(-,%m),¥),*¥,0,32)
unset %q
var %k = 1
while %k <= %s {
var %q = %q - $hget($+(Sondage,$1),$+(Question,$remove($wildtok($replace(%l,$+(-,%m),¥),*¥,%k,32),$chr(165))))
inc %k
}
.timerresultat1 -o 1 1 msg $hget($+(Sondage,$1),Chan) 12,1[ 0Il y a %s $+(proposition,$iif(%s > 1,s)) qui $+(l'emporte,$iif(%s > 1,ent)) avec %m voix : $right(%q,-1) 12]
var %m = $gettok($gettok(%l2,1,32),1,45)
var %s = $wildtok($replace(%l,$+(-,%m),¥),*¥,0,32)
unset %q
var %k = 1
while %k <= %s {
var %q = %q - $hget($+(Sondage,$1),$+(Question,$remove($wildtok($replace(%l,$+(-,%m),¥),*¥,%k,32),$chr(165))))
inc %k
}
.timerresultat2 -o 1 2 msg $hget($+(Sondage,$1),Chan) 12,1[ 0Il y a %s $+(proposition,$iif(%s > 1,s)) ayant receuilli le moins de voix $+($chr(40),%m,$chr(41)) : $right(%q,-1) 12]
}
hdel Sondage $hget($+(Sondage,$1),Chan)
hfree $+(Sondage,$1)
}
Conclusion
Copier ce code dans votre remote, et taper /sondage
pour voter, taper !sondage "X", possible dès l'annonce du début du vote.
Bonne année en retard :p
Historique
- 02 janvier 2005 14:19:56 :
- timer -o pour si jamais le mIRC est déconnecté
J'ai lu sur une autre source à propos d'un sondage qu'il serait pas mal d'avoir plusieurs sondages sur plusieurs salons, j'ai donc rajouté cette option :p
il y aura un sondage maximum par salon, sinon on s'embrouille à la fois le script, et les personnes sur le salon :p
- 02 janvier 2005 19:55:40 :
- Possibilité d'annuler (en ne répondant pas à une question, où en mettant de faux paramètres)
Possibilité de voter soi-même (inclu dans des questions)
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Comparez les prix Nouvelle version
|