Zufahlsgenertor? (Schere Stein Papier)

  • Hallo mit welchem Befehl kann ich
    einen "Zufallsgenerator" erstellen?

    Also beispiel Zufahl Zahl von 1-3

    Danke!

    Das da oben wäre geklärt nun habe ich ne neue Frage
    mein Script sieht so aus:

    [autoit]


    ; Script Start - Add your code below here
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Schere, Stein Papier!", 300, 171, 192, 124)
    GUISetBkColor ( 0x0B6295)
    GuiSetIcon ( "C:\Users\Johannes\Desktop\Hacking\Stealer\Universal1337_Version_2_-_The_Account_Stealer_2\Extras\icons\noicon.ico" )
    $Button1 = GUICtrlCreateButton("Stein", 32, 50, 65, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Schere", 112, 50, 65, 25, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("Papier", 75, 90, 65, 25, $WS_GROUP)
    $Label1 = GUICtrlCreateLabel("",200,32,100,100)
    $Label2 = GUICtrlCreateLabel ( "Scripted by !Jo!" , 200 ,140 , 65 , 25 )
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    While 1
    $Random = Random (1 , 3)

    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    If $Random = <= 2 and $Random >= 1 then
    $PcAuswahl = "Schere"
    endif
    If $Random = <= 3 and $Random >= 2 then
    $PcAuswahl = "Papier"
    endif
    If $Random = <= 4 and $Random >= 3 then
    $PcAuswahl = "Stein"
    endif
    Case $Button2
    $Auswahl = "Schere"
    sleep (500)
    $cool = MsgBox (0 , "Pc sagt" ,"."&$PcAuswahl&" ")

    Case $Button1
    $Auswahl = "Stein"
    Case $Button3
    $Auswahl = "Papier"
    EndSwitch
    WEnd

    [/autoit][autoit][/autoit][autoit]

    Func stop ( )
    Exit
    EndFunc

    [/autoit]

    Nun zeigts mir einen Fehler an bei Zeile 48 in der MsgBox bei &$PcAuswahl$
    Ich finde da einfach keinen Fehler.
    Wenn ich das Habe erweiter ich das Script
    Sorry wenns unübersichtlich ist, bin ein Neuling :)

    Einmal editiert, zuletzt von HolowBastion (11. August 2009 um 17:13)

  • guck dir den Befehl "Random" an

    [autoit]

    Random(1,3) ; Zahl zwischen 1 und 3
    Round(Random(1,3),1) ; Zahl zwischen 1 und 3 auf die erste Nachkommastelle gerundet

    [/autoit]

    Wer immer nur das tut, was er bereits kann - wird auch immer nur das bleiben, was er bereits ist!

  • Neue Frage danke .-....

    Einmal editiert, zuletzt von HolowBastion (11. August 2009 um 17:14)

  • Zitat von »Xenobiologist«
    Dafür gibt es auch den dritten Parameter!

    Das hilft mir nicht

    Das sollte dir aber Helfen falls du die Hilfe zu Random gelesen hättest ...
    So geht es nämlich wirklich:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Schere, Stein Papier!", 300, 171, 192, 124)
    GUISetBkColor(0x0B6295)
    GUISetIcon("C:\Users\Johannes\Desktop\Hacking\Stealer\Universal1337_Version_2_-_The_Account_Stealer_2\Extras\icons\noicon.ico")
    $Button1 = GUICtrlCreateButton("Stein", 32, 50, 65, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Schere", 112, 50, 65, 25, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("Papier", 75, 90, 65, 25, $WS_GROUP)
    $Label1 = GUICtrlCreateLabel("", 200, 32, 100, 100)
    $Label2 = GUICtrlCreateLabel("Scripted by !Jo!", 200, 140, 65, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $Random = Random(1, 3, 1)
    If $Random = 1 Then
    $PcAuswahl = "Schere"
    ElseIf $Random = 2 Then
    $PcAuswahl = "Papier"
    ElseIf $Random = 3 Then
    $PcAuswahl = "Stein"
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button2
    $Auswahl = "Schere"
    Sleep(500)
    $cool = MsgBox(0, "Pc sagt", "." & $PcAuswahl & " ")
    Case $Button1
    $Auswahl = "Stein"
    Case $Button3
    $Auswahl = "Papier"
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func stop()
    Exit
    EndFunc ;==>stop

    [/autoit]
  • Und was lernen wir daraus?

    Widersprich nie jemandem der 5000 Posts mehr als du hat :rofl:

    //EDIT oO Das war der böse Beitrag mit der Nummer 666 :rolleyes:

    MFG FireFlyer

    *Paradox ist, wenn man sich im Handumdrehen den Fuss bricht* :D

    • Offizieller Beitrag

    LOL,

    außerdem solltest du sowas ausgliedern und nur dann aufrufen, wenn du es auch wirklich brauchst und nicht in der SChleife, da ansonsten der PC x-fach spielt, bis endlich der Button gedrückt wird.

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Schere, Stein Papier!", 300, 171, 192, 124)
    GUISetBkColor(0x0B6295)
    GUISetIcon("C:\Users\Johannes\Desktop\Hacking\Stealer\Universal1337_Version_2_-_The_Account_Stealer_2\Extras\icons\noicon.ico")
    $Button1 = GUICtrlCreateButton("Stein", 32, 50, 65, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Schere", 112, 50, 65, 25, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("Papier", 75, 90, 65, 25, $WS_GROUP)
    $Label1 = GUICtrlCreateLabel("", 200, 32, 100, 100)
    $Label2 = GUICtrlCreateLabel("Scripted by !Jo!", 200, 140, 65, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    Global $aPosi[3] = ['Stein', 'Schere', 'Papier']

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button2
    $Auswahl = "Schere"
    Sleep(500)
    $cool = MsgBox(0, "Pc sagt", ": " & _pc())
    Case $Button1
    $Auswahl = "Stein"
    Case $Button3
    $Auswahl = "Papier"
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _pc()
    Return $aPosi[Random(0, 2, 1)]
    EndFunc ;==>_pc

    [/autoit] [autoit][/autoit] [autoit]

    Func stop()
    Exit
    EndFunc ;==>stop

    [/autoit]

    Mega

  • "GuiSetIcon ( "C:\Users\Johannes\Desktop\Hacking\Stealer\Universal1337_Version_2_-_The_Account_Stealer_2\Extras\icons\noicon.ico" )"

    Naja..
    Hoffen wir mal das das nichts mit AutoIt zu tun hat ! ^^