Petit autojoin en htable multiserver.
Le server, le salon et la clef ce mettent automatiquement selon là ou est démarrer le dialog.
-Utilisation de htable
-Utilisation de Gettok, reptok, wildtok, remtok
Source / Exemple :
menu channel {
Auto-Join:dialog -m autoj autoj
}
on *:disconnect:{
.hsave -o autoj autojoin.dou
}
on *:start:{
hmake autoj 1000
hload autoj autojoin.dou
}
ON 1:LOAD:{ hmake autoj 1000 }
on *:exit:{
hsave -o autoj autojoin.dou
}
on *:connect: {
autojoin
}
dialog autoj {
title "Auto-Join Salon"
size -1 -1 184 185
option dbu
list 1, 64 12 61 113, size vsbar
list 2, 6 12 58 113, size vsbar
list 3, 124 12 58 113, size vsbar
edit "", 4, 64 128 50 10, autohs center
edit "", 5, 6 128 50 10, autohs
edit "", 6, 124 128 50 10, autohs
button "Ajouter", 7, 13 147 37 12
button "Supprimer", 8, 131 147 37 12
button "Fermer", 9, 72 166 37 12
button "Modifier", 13, 74 147 37 12
text "Salon", 10, 79 2 25 8, center
text "Server", 11, 17 3 25 8, center
text "Clef", 12, 139 2 25 8, center
}
on *:dialog:autoj:*:*:{
if $devent == init {
var %i = 1
var %w = $gettok($hget(autoj,aj),0,47)
while %i <= %w {
did -a $dname 1 $gettok($gettok($hget(autoj,aj),%i,47),1,126)
did -a $dname 2 $gettok($gettok($hget(autoj,aj),%i,47),2,126)
did -a $dname 3 $gettok($gettok($hget(autoj,aj),%i,47),3,126)
inc %i
}
did -a $dname 4 $active
did -a $dname 5 $server
did -a $dname 6 $chan($active).mode.key
}
if $devent == sclick {
if $did == 1 { did -c $dname 2 $did(1).sel | did -c $dname 3 $did(1).sel }
if $did == 2 { did -c $dname 1 $did(2).sel | did -c $dname 3 $did(2).sel }
if $did == 3 { did -c $dname 1 $did(3).sel | did -c $dname 2 $did(3).sel }
if $did == 7 {
$iif($did(4) && $did(5),hadd -m autoj aj $+($hget(autoj,aj),/,$did(4),~,$did(5),~,$did(6)),echo -a Vous n'avez pas spécifier de server ou de salon.)
did -a $dname 1 $did(4)
did -a $dname 2 $did(5)
did -a $dname 3 $did(6)
}
if $did == 8 {
$iif($wildtok($hget(autoj,aj),$did(1).seltext $+ ~ $+ $did(2).seltext $+ *,0,47),hadd -m autoj aj $remtok($hget(autoj,aj),$wildtok($hget(autoj,aj),$did(1).seltext $+ ~ $+ $did(2).seltext $+ *,1,47),1,47),echo -a Veuillez selectionner un salon et son server attitré.)
did -r $dname 1,2,3
var %i = 1
var %w = $gettok($hget(autoj,aj),0,47)
while %i <= %w {
did -a $dname 1 $gettok($gettok($hget(autoj,aj),%i,47),1,126)
did -a $dname 2 $gettok($gettok($hget(autoj,aj),%i,47),2,126)
did -a $dname 3 $gettok($gettok($hget(autoj,aj),%i,47),3,126)
inc %i
}
}
if $did == 9 { dialog -x $dname $dname }
if $did == 13 {
$iif($wildtok($hget(autoj,aj),$+($did(1).seltext,~,$did(2).seltext,~,$did(3).seltext,*),0,47),hadd -m autoj aj $reptok($hget(autoj,aj),$wildtok($hget(autoj,aj),$did(1).seltext $+ ~ $+ $did(2).seltext $+ ~ $+ $did(3).seltext $+ *,1,47),$+($did(4),~,$did(5),~,$did(6)),1,47),echo -a Veuillez selectionner un salon et son server attitré.)
did -r $dname 1,2,3
var %i = 1
var %w = $gettok($hget(autoj,aj),0,47)
while %i <= %w {
did -a $dname 1 $gettok($gettok($hget(autoj,aj),%i,47),1,126)
did -a $dname 2 $gettok($gettok($hget(autoj,aj),%i,47),2,126)
did -a $dname 3 $gettok($gettok($hget(autoj,aj),%i,47),3,126)
inc %i
}
}
}
}
alias autojoin {
var %i $gettok($hget(autoj,aj),0,47)
while %i > 0 {
var %autojoin $gettok($gettok($hget(autoj,aj),%i,47),2,126)
if $server == %autojoin {
join $gettok($gettok($hget(autoj,aj),%i,47),1,126) $gettok($gettok($hget(autoj,aj),%i,47),3,126)
}
dec %i
}
}
Conclusion :
Si vous remarquer des bugs, amélioration ou optimisation, veuillez m'en faire part.
Je met se code en initié car je pense que les htables et les tokens ne sont pas à porté des débutant.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.