sps in 1 channel spielbar?
Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen
-
-
-
Nabend,
Danke aba da ich in gtchat net gut bin und net richtig check ich denke du meinst das ganze in der .pm datei machen könntes du das mal eben machen
Quellcode
- #####################################################
- # GTChat 0.95 Alpha Plugin - Schere, Stein, Papier #
- # Written for release whatever #
- # Author: SpiltCoffee #
- # Übersetzer: Çÿbë®Ãëmõñ #
- # #
- # Powered by GT-Chat.de #
- # #
- # This plugin provides the /rps command, a little #
- # game for you and your chat users to enjoy. #
- #####################################################
- package GTChat::Plugins::SPSCommand::095;
- use strict;
- return bless({
- command_handlers => {
- 'sps' => \&handler,
- },
- });
- sub check_gagged
- {
- my $main = shift;
- if (exists($main->{current_user}{gagtime}) && $main->{runtime}{now} < $main->{current_user}{gagtime})
- {
- return [$main->createErrorOutput('gagged',{seconds => $main->{current_user}{gagtime}-$main->{runtime}{now}})];
- }
- return undef;
- }
- sub check_allowed
- {
- my $main = shift;
- if (exists($main->{current_user}{sps}) && $main->{runtime}{now} < $main->{current_user}{sps})
- {
- return [$main->createErrorOutput('sps_notallowed',{seconds => $main->{current_user}{sps}-$main->{runtime}{now}})];
- }
- return undef;
- }
- sub handler
- {
- my($self,$main,$command,$text) = @_;
- my @ret=();
- my $waittime = 5; # Minuten, die man zwischen den Spielen warten muss
- my $points = 10; # Punkte pro gewonnene / verlorene Runde
- if (my $error=check_gagged($main))
- {
- return $error;
- }
- if (my $error=check_allowed($main))
- {
- return $error;
- }
- my $sum = sprintf '%.0f', rand(2)-1;
- $sum = int($sum);
- my ($hand,$number) = getHand($text);
- my $turnout = getTurnout($number,$sum);
- my $user = $main->{current_user};
- if ($hand)
- {
- $main->loadUser($user->{name},$user);
- if ($sum > 0)
- {
- $user->{points} += $points;
- my $output = $main->createInfoOutput('sps_win',
- {
- nick => $main->{current_user}{nick},
- hand => $hand,
- turnout => $turnout,
- points => $points,
- });
- $output->restrictToCurrentRoom();
- push @ret,$output;
- }
- elsif ($sum < 0)
- {
- $user->{points} -= $points;
- my $output = $main->createInfoOutput('sps_loss',
- {
- nick => $main->{current_user}{nick},
- hand => $hand,
- turnout => $turnout,
- points => $points,
- });
- $output->restrictToCurrentRoom();
- push @ret,$output;
- }
- elsif ($sum == 0)
- {
- my $output = $main->createInfoOutput('sps_draw',
- {
- nick => $main->{current_user}{nick},
- hand => $hand,
- turnout => $turnout,
- });
- $output->restrictToCurrentRoom();
- push @ret,$output;
- }
- $user->{sps} = $main->{runtime}{now}+(60*$waittime);
- $main->saveUser($user);
- }
- elsif (!$hand)
- {
- my $output = $main->createErrorOutput('sps');
- push @ret, $output->restrictToCurrentUser;
- }
- return \@ret;
- }
- sub getHand
- {
- my $text = shift;
- if ($text =~ /\bstein\b/i)
- {
- return ('stein',1);
- }
- elsif ($text =~ /\bschere\b/i)
- {
- return ('schere',2);
- }
- elsif ($text =~ /\bpapier\b/i)
- {
- return ('papier',3);
- }
- else
- {
- return (0,-5);
- }
- }
- sub getTurnout
- {
- my ($number,$sum) = @_;
- my @hands = ('papier','stein','schere','papier','stein');
- my $turnout = $number + $sum;
- return $hands[$turnout] if ($turnout >= 0);
- }
-
-
So?
sub check_allowed
{
my $main = shift;
if (exists($main->{current_user}{sps}) && $main->{runtime}{now} < $main->{current_user}{sps}) {Current_room eq} 'S-S-Papier'
{
return [$main->createErrorOutput('sps_notallowed',{seconds => $main->{current_user}{sps}-$main->{runtime}{now}})];
}
return undef;
} -
-
-
Norris schrieb:
Hm möchte jetzt hier nix lernen wollte das einfach haben ?? Kann mir da keiner helfen ?.
Ich selber habe deine gewünschte Funktion bereits in meinem Chat integriert, läuft einwandfrei und es sind garantiert nur 2-3 sehr leichte Zeilen Code. -
-
Norris schrieb:
Klasse ich peil es grad nicht und ich frage ja hier im forum um die lösung zu bekommen dafür ist dieses forum & dieses thema ja da ;).
MfG.
Ein bisschen Eigeniniziative musst du haben!
Wie gesagt - ich habe dir im ersten Beitrag den Ansatz geschrieben - natürlich wird etwas Wissen vorrausgesetzt. -
-
Norris, bitte gewöhne dir an mit punkt und komma zu schreiben.
@Coder es ist wahr das des forum dafür da ist um hilfe zu geben,
hat du ja auch getan... ich verstehe auch voll und ganz deine meinung.
aber das man einen gtchat betreibt, setzt kein wissen in perl vorraus.
Ich persönlich kann auch kein perl schmeiße mir aber trotzdem viele funktionen
@Norris es gibt da ein paar addons, die sich auf einen einzigen raum beschränken, die könntest du dir zum beispiel anschauen -
Norris, Foren sind dazu da um dir die Lösungsvorschläge/wege zu zeigen...
Warum schaust Du dir nicht andere Addons an, um zu sehen, wie die Funktionieren und DARAUS zu lernen?
Lösung:
Wir sind kein Pizzaservice, wo es Codes auf Bestellung gibt... -
Guten Abend,
Habe nun folgendes gemacht.
Quellcode
- #####################################################
- # GTChat 0.95 Alpha Plugin - Schere, Stein, Papier #
- # Written for release whatever #
- # Author: SpiltCoffee #
- # Übersetzer: Çÿbë®Ãëmõñ #
- # #
- # Powered by GT-Chat.de #
- # #
- # This plugin provides the /rps command, a little #
- # game for you and your chat users to enjoy. #
- #####################################################
- package GTChat::Plugins::SPSCommand::095;
- use strict;
- return bless({
- command_handlers => {
- 'sps' => \&handler,
- },
- });
- sub check_gagged
- {
- my $main = shift;
- if (exists($main->{current_user}{gagtime}) && $main->{runtime}{now} < $main->{current_user}{gagtime})
- {
- return [$main->createErrorOutput('gagged',{seconds => $main->{current_user}{gagtime}-$main->{runtime}{now}})];
- }
- return undef;
- }
- sub check_allowed
- {
- my $main = shift;
- if (exists($main->{current_user}{sps}) && $main->{runtime}{now} < $main->{current_user}{sps})
- {
- return [$main->createErrorOutput('sps_notallowed',{seconds => $main->{current_user}{sps}-$main->{runtime}{now}})];
- }
- return undef;
- }
- sub handler
- {
- my($self,$main,$command,$text) = @_;
- my $settings = $main->loadRoom($main->{current_user}{room});
- if ($settings->{sps})
- my @ret=();
- my $waittime = 5; # Minuten, die man zwischen den Spielen warten muss
- my $points = 10; # Punkte pro gewonnene / verlorene Runde
- if (my $error=check_gagged($main))
- {
- return $error;
- }
- if (my $error=check_allowed($main))
- {
- return $error;
- }
- my $sum = sprintf '%.0f', rand(2)-1;
- $sum = int($sum);
- my ($hand,$number) = getHand($text);
- my $turnout = getTurnout($number,$sum);
- my $user = $main->{current_user};
- return [$main->createErrorOutput('cannotkiss')] if($main->{current_user}{mentor4564589978} < 499);
- if ($hand)
- {
- $main->loadUser($user->{name},$user);
- if ($sum > 0)
- {
- $user->{points} += $points;
- my $output = $main->createInfoOutput('sps_win',
- {
- nick => $main->{current_user}{nick},
- hand => $hand,
- turnout => $turnout,
- points => $points,
- });
- $output->restrictToCurrentRoom();
- push @ret,$output;
- }
- elsif ($sum < 0)
- {
- $user->{points} -= $points;
- my $output = $main->createInfoOutput('sps_loss',
- {
- nick => $main->{current_user}{nick},
- hand => $hand,
- turnout => $turnout,
- points => $points,
- });
- $output->restrictToCurrentRoom();
- push @ret,$output;
- }
- elsif ($sum == 0)
- {
- my $output = $main->createInfoOutput('sps_draw',
- {
- nick => $main->{current_user}{nick},
- hand => $hand,
- turnout => $turnout,
- });
- $output->restrictToCurrentRoom();
- push @ret,$output;
- }
- $main->saveUser($user);
- }
- elsif (!$hand)
- {
- my $output = $main->createErrorOutput('sps');
- push @ret, $output->restrictToCurrentUser;
- }
- return \@ret;
- }
- sub getHand
- {
- my $text = shift;
- if ($text =~ /\bstein\b/i)
- {
- return ('stein',1);
- }
- elsif ($text =~ /\bschere\b/i)
- {
- return ('schere',2);
- }
- elsif ($text =~ /\bpapier\b/i)
- {
- return ('papier',3);
- }
- else
- {
- return (0,-5);
- }
- }
- sub getTurnout
- {
- my ($number,$sum) = @_;
- my @hands = ('papier','stein','schere','papier','stein');
- my $turnout = $number + $sum;
- return $hands[$turnout] if ($turnout >= 0);
- }
Nun geht es aba in jeden channel :pDieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Norris“ ()
-
-
ungetestet, es sollte aber Funktionieren!
Quellcode
- #####################################################
- # GTChat 0.95 Alpha Plugin - Schere, Stein, Papier #
- # Written for release whatever #
- # Author: SpiltCoffee #
- # Übersetzer: Çÿbë®Ãëmõñ #
- # #
- # Powered by GT-Chat.de #
- # #
- # This plugin provides the /rps command, a little #
- # game for you and your chat users to enjoy. #
- #####################################################
- package GTChat::Plugins::SPSCommand::095;
- use strict;
- return bless({
- command_handlers => {
- 'sps' => \&handler,
- },
- });
- sub check_gagged
- {
- my $main = shift;
- if (exists($main->{current_user}{gagtime}) && $main->{runtime}{now} < $main->{current_user}{gagtime})
- {
- return [$main->createErrorOutput('gagged',{seconds => $main->{current_user}{gagtime}-$main->{runtime}{now}})];
- }
- return undef;
- }
- sub check_allowed
- {
- my $main = shift;
- if (exists($main->{current_user}{sps}) && $main->{runtime}{now} < $main->{current_user}{sps})
- {
- return [$main->createErrorOutput('sps_notallowed',{seconds => $main->{current_user}{sps}-$main->{runtime}{now}})];
- }
- return undef;
- }
- sub handler
- {
- my($self,$main,$command,$text) = @_;
- $main->fatal_error('a',{a => "Sie müssen sich im Channel _S-S-Papier_ befinden, um diesen Befehl auszuführen."}) if($main->{current_user}{room} ne 'S-S-Papier');
- my @ret=();
- my $waittime = 5; # Minuten, die man zwischen den Spielen warten muss
- my $points = 10; # Punkte pro gewonnene / verlorene Runde
- if (my $error=check_gagged($main))
- {
- return $error;
- }
- if (my $error=check_allowed($main))
- {
- return $error;
- }
- my $sum = sprintf '%.0f', rand(2)-1;
- $sum = int($sum);
- my ($hand,$number) = getHand($text);
- my $turnout = getTurnout($number,$sum);
- my $user = $main->{current_user};
- if ($hand)
- {
- $main->loadUser($user->{name},$user);
- if ($sum > 0)
- {
- $user->{points} += $points;
- my $output = $main->createInfoOutput('sps_win',
- {
- nick => $main->{current_user}{nick},
- hand => $hand,
- turnout => $turnout,
- points => $points,
- });
- $output->restrictToCurrentRoom();
- push @ret,$output;
- }
- elsif ($sum < 0)
- {
- $user->{points} -= $points;
- my $output = $main->createInfoOutput('sps_loss',
- {
- nick => $main->{current_user}{nick},
- hand => $hand,
- turnout => $turnout,
- points => $points,
- });
- $output->restrictToCurrentRoom();
- push @ret,$output;
- }
- elsif ($sum == 0)
- {
- my $output = $main->createInfoOutput('sps_draw',
- {
- nick => $main->{current_user}{nick},
- hand => $hand,
- turnout => $turnout,
- });
- $output->restrictToCurrentRoom();
- push @ret,$output;
- }
- $user->{sps} = $main->{runtime}{now}+(60*$waittime);
- $main->saveUser($user);
- }
- elsif (!$hand)
- {
- my $output = $main->createErrorOutput('sps');
- push @ret, $output->restrictToCurrentUser;
- }
- return \@ret;
- }
- sub getHand
- {
- my $text = shift;
- if ($text =~ /\bstein\b/i)
- {
- return ('stein',1);
- }
- elsif ($text =~ /\bschere\b/i)
- {
- return ('schere',2);
- }
- elsif ($text =~ /\bpapier\b/i)
- {
- return ('papier',3);
- }
- else
- {
- return (0,-5);
- }
- }
- sub getTurnout
- {
- my ($number,$sum) = @_;
- my @hands = ('papier','stein','schere','papier','stein');
- my $turnout = $number + $sum;
- return $hands[$turnout] if ($turnout >= 0);
- }
Gruß, Lukas -
-
Norris schrieb:
Hm möchte jetzt hier nix lernen wollte das einfach haben ?? Kann mir da keiner helfen ?.
Im Grunde sollte man aus einen Support Forum schon was lernen, auch wenn es nicht viel ist am ende. Und du als Freehoster solltest erst recht was lernen.
Coder schrieb:
Lies bitte was ich geschrieben habe.
Das waren "Hilfs-Schnippsel", die du brauchst, um das zu machen!
Nein. Du brauchst eine eigene Abfrage.
Aber willst du nicht erstmal die Grundsachen von Perl lernen? Du kannst ja, wie ich sehe, nicht mal einfachste if()s.
Entwerde 100% hilfe geben oder gar keine.
Nicht jeder kann hier Perl und wenn du es kannst, schreib die Lösungen doch gleich richtig hin. So lernt jemand eher was als von sinnlosen Schnippsel-Codes.
-
Teilen
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0