Accueil > > > SONDAGE À CHOIX ILLIMITÉS, TOUT (OU PRESQUE) ÉTANT CONFIGURABLE (HASH-TABLE)
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
|
Derniers Blogs
COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL [WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ?MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ? par junarnoalg
La prochaine session de MyTIC aura lieu à Namur, le 23 mars prochain. Pendant presque une heure, nous parlerons de SharePoint 2010. Voici un aperçu du programme.
Accueil : 17h30 Début de la session : 18h00 - Les nouvelles int...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
RE : COULEUR TEXTRE : COULEUR TEXT par WorldDMT
Cliquez pour lire la suite par WorldDMT
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|