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
TECHDAYS PARIS 2010 : SHAREPOINT 2010 POUR LES DéVELOPPEURSTECHDAYS PARIS 2010 : SHAREPOINT 2010 POUR LES DéVELOPPEURS par ROMELARD Fabrice
Animé par: Laurent Cotton Le développement dans SharePoint 2010 passe par plusieurs axes qui seront évoqués dans cette session, mais plus particulièrement les développements simples lié au besoin Business Business Connectivity Services Ce BCS es...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLEINIèRE DERNIER JOURTECHDAYS PARIS 2010 : PLEINIèRE DERNIER JOUR par ROMELARD Fabrice
Cette session est la dernière pleinière de ces 3 jours de TechDays Paris 2010. Généralement, cette troisième journée est plus axée sur l'avenir vu par Microsoft. Après un retour sur l'avenir vu par la Science Fiction ou par ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion
Forum
RE : ON RAWMODERE : ON RAWMODE par WorldDMT
Cliquez pour lire la suite par WorldDMT AVERTISSMENT ET KIKKAVERTISSMENT ET KIKK par mouhcine951990
Cliquez pour lire la suite par mouhcine951990
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
Comparez les prix

HTC Hero
Entre 550€ et 550€
|