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

      1. #####################################################
      2. # GTChat 0.95 Alpha Plugin - Schere, Stein, Papier #
      3. # Written for release whatever #
      4. # Author: SpiltCoffee #
      5. # Übersetzer: Çÿbë®Ðëmõñ #
      6. # #
      7. # Powered by GT-Chat.de #
      8. # #
      9. # This plugin provides the /rps command, a little #
      10. # game for you and your chat users to enjoy. #
      11. #####################################################
      12. package GTChat::Plugins::SPSCommand::095;
      13. use strict;
      14. return bless({
      15. command_handlers => {
      16. 'sps' => \&handler,
      17. },
      18. });
      19. sub check_gagged
      20. {
      21. my $main = shift;
      22. if (exists($main->{current_user}{gagtime}) && $main->{runtime}{now} < $main->{current_user}{gagtime})
      23. {
      24. return [$main->createErrorOutput('gagged',{seconds => $main->{current_user}{gagtime}-$main->{runtime}{now}})];
      25. }
      26. return undef;
      27. }
      28. sub check_allowed
      29. {
      30. my $main = shift;
      31. if (exists($main->{current_user}{sps}) && $main->{runtime}{now} < $main->{current_user}{sps})
      32. {
      33. return [$main->createErrorOutput('sps_notallowed',{seconds => $main->{current_user}{sps}-$main->{runtime}{now}})];
      34. }
      35. return undef;
      36. }
      37. sub handler
      38. {
      39. my($self,$main,$command,$text) = @_;
      40. my @ret=();
      41. my $waittime = 5; # Minuten, die man zwischen den Spielen warten muss
      42. my $points = 10; # Punkte pro gewonnene / verlorene Runde
      43. if (my $error=check_gagged($main))
      44. {
      45. return $error;
      46. }
      47. if (my $error=check_allowed($main))
      48. {
      49. return $error;
      50. }
      51. my $sum = sprintf '%.0f', rand(2)-1;
      52. $sum = int($sum);
      53. my ($hand,$number) = getHand($text);
      54. my $turnout = getTurnout($number,$sum);
      55. my $user = $main->{current_user};
      56. if ($hand)
      57. {
      58. $main->loadUser($user->{name},$user);
      59. if ($sum > 0)
      60. {
      61. $user->{points} += $points;
      62. my $output = $main->createInfoOutput('sps_win',
      63. {
      64. nick => $main->{current_user}{nick},
      65. hand => $hand,
      66. turnout => $turnout,
      67. points => $points,
      68. });
      69. $output->restrictToCurrentRoom();
      70. push @ret,$output;
      71. }
      72. elsif ($sum < 0)
      73. {
      74. $user->{points} -= $points;
      75. my $output = $main->createInfoOutput('sps_loss',
      76. {
      77. nick => $main->{current_user}{nick},
      78. hand => $hand,
      79. turnout => $turnout,
      80. points => $points,
      81. });
      82. $output->restrictToCurrentRoom();
      83. push @ret,$output;
      84. }
      85. elsif ($sum == 0)
      86. {
      87. my $output = $main->createInfoOutput('sps_draw',
      88. {
      89. nick => $main->{current_user}{nick},
      90. hand => $hand,
      91. turnout => $turnout,
      92. });
      93. $output->restrictToCurrentRoom();
      94. push @ret,$output;
      95. }
      96. $user->{sps} = $main->{runtime}{now}+(60*$waittime);
      97. $main->saveUser($user);
      98. }
      99. elsif (!$hand)
      100. {
      101. my $output = $main->createErrorOutput('sps');
      102. push @ret, $output->restrictToCurrentUser;
      103. }
      104. return \@ret;
      105. }
      106. sub getHand
      107. {
      108. my $text = shift;
      109. if ($text =~ /\bstein\b/i)
      110. {
      111. return ('stein',1);
      112. }
      113. elsif ($text =~ /\bschere\b/i)
      114. {
      115. return ('schere',2);
      116. }
      117. elsif ($text =~ /\bpapier\b/i)
      118. {
      119. return ('papier',3);
      120. }
      121. else
      122. {
      123. return (0,-5);
      124. }
      125. }
      126. sub getTurnout
      127. {
      128. my ($number,$sum) = @_;
      129. my @hands = ('papier','stein','schere','papier','stein');
      130. my $turnout = $number + $sum;
      131. return $hands[$turnout] if ($turnout >= 0);
      132. }
      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;
      }
      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.

      Norris schrieb:

      Hm möchte jetzt hier nix lernen wollte das einfach haben ?? Kann mir da keiner helfen ?.
      Du willst einen Chat betreiben, aber willst nichts lernen? Erklär mir das bitte..

      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 Forum ist nicht dazu da, um dir alles vorzusagen.
      Ein bisschen Eigeniniziative musst du haben!

      Wie gesagt - ich habe dir im ersten Beitrag den Ansatz geschrieben - natürlich wird etwas Wissen vorrausgesetzt.
      Klasse, Kanns trozdem dadurch net und dann werde ich das auch wohl nicht von dir bekommen also ist gut ;p trozdem frage ich ander um die mir dabei evt. Helfen könnten tuht mir leid das ich net soo gut coden kann wie du aba ich will es einfach nur haben aba trozdem danke für deine hilfe.
      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:

      PHP-Quellcode

      1. if($main->{current_user}{room} eq 'raumname(KLEINGESCHRIEBEN)')
      2. {
      3. ...code....
      4. }


      Wir sind kein Pizzaservice, wo es Codes auf Bestellung gibt...
      Guten Abend,

      Habe nun folgendes gemacht.

      Quellcode

      1. #####################################################
      2. # GTChat 0.95 Alpha Plugin - Schere, Stein, Papier #
      3. # Written for release whatever #
      4. # Author: SpiltCoffee #
      5. # Übersetzer: Çÿbë®Ðëmõñ #
      6. # #
      7. # Powered by GT-Chat.de #
      8. # #
      9. # This plugin provides the /rps command, a little #
      10. # game for you and your chat users to enjoy. #
      11. #####################################################
      12. package GTChat::Plugins::SPSCommand::095;
      13. use strict;
      14. return bless({
      15. command_handlers => {
      16. 'sps' => \&handler,
      17. },
      18. });
      19. sub check_gagged
      20. {
      21. my $main = shift;
      22. if (exists($main->{current_user}{gagtime}) && $main->{runtime}{now} < $main->{current_user}{gagtime})
      23. {
      24. return [$main->createErrorOutput('gagged',{seconds => $main->{current_user}{gagtime}-$main->{runtime}{now}})];
      25. }
      26. return undef;
      27. }
      28. sub check_allowed
      29. {
      30. my $main = shift;
      31. if (exists($main->{current_user}{sps}) && $main->{runtime}{now} < $main->{current_user}{sps})
      32. {
      33. return [$main->createErrorOutput('sps_notallowed',{seconds => $main->{current_user}{sps}-$main->{runtime}{now}})];
      34. }
      35. return undef;
      36. }
      37. sub handler
      38. {
      39. my($self,$main,$command,$text) = @_;
      40. my $settings = $main->loadRoom($main->{current_user}{room});
      41. if ($settings->{sps})
      42. my @ret=();
      43. my $waittime = 5; # Minuten, die man zwischen den Spielen warten muss
      44. my $points = 10; # Punkte pro gewonnene / verlorene Runde
      45. if (my $error=check_gagged($main))
      46. {
      47. return $error;
      48. }
      49. if (my $error=check_allowed($main))
      50. {
      51. return $error;
      52. }
      53. my $sum = sprintf '%.0f', rand(2)-1;
      54. $sum = int($sum);
      55. my ($hand,$number) = getHand($text);
      56. my $turnout = getTurnout($number,$sum);
      57. my $user = $main->{current_user};
      58. return [$main->createErrorOutput('cannotkiss')] if($main->{current_user}{mentor4564589978} < 499);
      59. if ($hand)
      60. {
      61. $main->loadUser($user->{name},$user);
      62. if ($sum > 0)
      63. {
      64. $user->{points} += $points;
      65. my $output = $main->createInfoOutput('sps_win',
      66. {
      67. nick => $main->{current_user}{nick},
      68. hand => $hand,
      69. turnout => $turnout,
      70. points => $points,
      71. });
      72. $output->restrictToCurrentRoom();
      73. push @ret,$output;
      74. }
      75. elsif ($sum < 0)
      76. {
      77. $user->{points} -= $points;
      78. my $output = $main->createInfoOutput('sps_loss',
      79. {
      80. nick => $main->{current_user}{nick},
      81. hand => $hand,
      82. turnout => $turnout,
      83. points => $points,
      84. });
      85. $output->restrictToCurrentRoom();
      86. push @ret,$output;
      87. }
      88. elsif ($sum == 0)
      89. {
      90. my $output = $main->createInfoOutput('sps_draw',
      91. {
      92. nick => $main->{current_user}{nick},
      93. hand => $hand,
      94. turnout => $turnout,
      95. });
      96. $output->restrictToCurrentRoom();
      97. push @ret,$output;
      98. }
      99. $main->saveUser($user);
      100. }
      101. elsif (!$hand)
      102. {
      103. my $output = $main->createErrorOutput('sps');
      104. push @ret, $output->restrictToCurrentUser;
      105. }
      106. return \@ret;
      107. }
      108. sub getHand
      109. {
      110. my $text = shift;
      111. if ($text =~ /\bstein\b/i)
      112. {
      113. return ('stein',1);
      114. }
      115. elsif ($text =~ /\bschere\b/i)
      116. {
      117. return ('schere',2);
      118. }
      119. elsif ($text =~ /\bpapier\b/i)
      120. {
      121. return ('papier',3);
      122. }
      123. else
      124. {
      125. return (0,-5);
      126. }
      127. }
      128. sub getTurnout
      129. {
      130. my ($number,$sum) = @_;
      131. my @hands = ('papier','stein','schere','papier','stein');
      132. my $turnout = $number + $sum;
      133. return $hands[$turnout] if ($turnout >= 0);
      134. }


      Nun geht es aba in jeden channel :p

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Norris“ ()

      ungetestet, es sollte aber Funktionieren!



      Quellcode

      1. #####################################################
      2. # GTChat 0.95 Alpha Plugin - Schere, Stein, Papier #
      3. # Written for release whatever #
      4. # Author: SpiltCoffee #
      5. # Übersetzer: Çÿbë®Ðëmõñ #
      6. # #
      7. # Powered by GT-Chat.de #
      8. # #
      9. # This plugin provides the /rps command, a little #
      10. # game for you and your chat users to enjoy. #
      11. #####################################################
      12. package GTChat::Plugins::SPSCommand::095;
      13. use strict;
      14. return bless({
      15. command_handlers => {
      16. 'sps' => \&handler,
      17. },
      18. });
      19. sub check_gagged
      20. {
      21. my $main = shift;
      22. if (exists($main->{current_user}{gagtime}) && $main->{runtime}{now} < $main->{current_user}{gagtime})
      23. {
      24. return [$main->createErrorOutput('gagged',{seconds => $main->{current_user}{gagtime}-$main->{runtime}{now}})];
      25. }
      26. return undef;
      27. }
      28. sub check_allowed
      29. {
      30. my $main = shift;
      31. if (exists($main->{current_user}{sps}) && $main->{runtime}{now} < $main->{current_user}{sps})
      32. {
      33. return [$main->createErrorOutput('sps_notallowed',{seconds => $main->{current_user}{sps}-$main->{runtime}{now}})];
      34. }
      35. return undef;
      36. }
      37. sub handler
      38. {
      39. my($self,$main,$command,$text) = @_;
      40. $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');
      41. my @ret=();
      42. my $waittime = 5; # Minuten, die man zwischen den Spielen warten muss
      43. my $points = 10; # Punkte pro gewonnene / verlorene Runde
      44. if (my $error=check_gagged($main))
      45. {
      46. return $error;
      47. }
      48. if (my $error=check_allowed($main))
      49. {
      50. return $error;
      51. }
      52. my $sum = sprintf '%.0f', rand(2)-1;
      53. $sum = int($sum);
      54. my ($hand,$number) = getHand($text);
      55. my $turnout = getTurnout($number,$sum);
      56. my $user = $main->{current_user};
      57. if ($hand)
      58. {
      59. $main->loadUser($user->{name},$user);
      60. if ($sum > 0)
      61. {
      62. $user->{points} += $points;
      63. my $output = $main->createInfoOutput('sps_win',
      64. {
      65. nick => $main->{current_user}{nick},
      66. hand => $hand,
      67. turnout => $turnout,
      68. points => $points,
      69. });
      70. $output->restrictToCurrentRoom();
      71. push @ret,$output;
      72. }
      73. elsif ($sum < 0)
      74. {
      75. $user->{points} -= $points;
      76. my $output = $main->createInfoOutput('sps_loss',
      77. {
      78. nick => $main->{current_user}{nick},
      79. hand => $hand,
      80. turnout => $turnout,
      81. points => $points,
      82. });
      83. $output->restrictToCurrentRoom();
      84. push @ret,$output;
      85. }
      86. elsif ($sum == 0)
      87. {
      88. my $output = $main->createInfoOutput('sps_draw',
      89. {
      90. nick => $main->{current_user}{nick},
      91. hand => $hand,
      92. turnout => $turnout,
      93. });
      94. $output->restrictToCurrentRoom();
      95. push @ret,$output;
      96. }
      97. $user->{sps} = $main->{runtime}{now}+(60*$waittime);
      98. $main->saveUser($user);
      99. }
      100. elsif (!$hand)
      101. {
      102. my $output = $main->createErrorOutput('sps');
      103. push @ret, $output->restrictToCurrentUser;
      104. }
      105. return \@ret;
      106. }
      107. sub getHand
      108. {
      109. my $text = shift;
      110. if ($text =~ /\bstein\b/i)
      111. {
      112. return ('stein',1);
      113. }
      114. elsif ($text =~ /\bschere\b/i)
      115. {
      116. return ('schere',2);
      117. }
      118. elsif ($text =~ /\bpapier\b/i)
      119. {
      120. return ('papier',3);
      121. }
      122. else
      123. {
      124. return (0,-5);
      125. }
      126. }
      127. sub getTurnout
      128. {
      129. my ($number,$sum) = @_;
      130. my @hands = ('papier','stein','schere','papier','stein');
      131. my $turnout = $number + $sum;
      132. return $hands[$turnout] if ($turnout >= 0);
      133. }



      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.