"every 1 seconds:" is not available

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

cocamush

Member
Jan 4, 2025
1
0
1
24
Code:
variables:
    {kills::%player%} = 0
    {deaths::%player%} = 0
    {vote.kills::*} = false
    {vote.innocent::*} = false
    {voters::*} = false
    {murder.active} = false
    {murder.timeout} = 0
    {murder.attacker} = ""

# プレイヤーが死亡したときに攻撃者(殺人者)と被害者を記録
on death of player:
    victim is a player
    attacker is a player
    if attacker is not victim: # 自分自身による死を防ぐ
        set {kills::%attacker%} to {kills::%attacker%} + 1
        set {deaths::%victim%} to {deaths::%victim%} + 1
        broadcast "&6[投票スクリプト] &e%attacker% が %victim% を殺害しました!"
        broadcast "&6投票は60秒以内に行ってください。/vote <killpenalty|innocent>"
        
        # 毒殺など特定の攻撃者を追跡
        set {murder.attacker} to "%attacker%" # ここで殺人者(攻撃者)を設定
        
        # 判決など後続処理
        set {murder.active} to true
        set {murder.timeout} to now
        clear {vote.kills::*}
        clear {vote.innocent::*}
        clear {voters::*}


        # 毎秒投票時間が過ぎていないか確認
        every 1 seconds:
            if {murder.active} is true:
                # 投票開始から60秒経過した場合
                if difference between now and {murder.timeout} > 60 seconds:
                    set {murder.active} to false
                    broadcast "&c[投票スクリプト] 投票時間が終了しました。"
                    # 投票していないプレイヤーのアイテムを削除
                    loop all players:
                        if loop-player is not contained in {voters::*}: # 投票していないプレイヤーのアイテムを削除
                            clear all items of loop-player
                            send "&eあなたのアイテムが削除されました。" to loop-player # メッセージを送信
                    # 投票結果を集計
                    set {_killVotes} to size of {vote.kills::*}
                    set {_innocentVotes} to size of {vote.innocent::*}
                    broadcast "&6[投票スクリプト] &e投票結果: 死刑 %{_killVotes}%票, 無罪 %{_innocentVotes}%票"
                    if {_killVotes} > {_innocentVotes}:
                        # 死刑処理
                        broadcast "&c[投票スクリプト] &e%{murder.attacker}% が死刑と判決されました。BANを実行します。"
                        # 変数に格納されている殺人者(attacker)のプレイヤー名を文字列として扱うために取り出す
                        set {_banReason} to "死刑判決: 死刑 %{_killVotes}%票、無罪 %{_innocentVotes}%票"
                        execute console command "ban %{murder.attacker}% with reason %{_banReason}%"
                        # バンメッセージに投票者を追加
                        add "死刑投票者: %{vote.kills::*}%, 無罪投票者: %{vote.innocent::*}%" to {_banReason}
                    else:
                        # 無罪処理
                        broadcast "&a[投票スクリプト] &e%{murder.attacker}% は無罪と判決されました。"
# 投票の管理コマンド
command /vote [<text>] [<text>]:
    trigger:
        if {murder.active} is false:
            send "&c現在、有効な殺人事件は発生していません。殺人事件が発生した後に投票ができます。"
            stop
        if difference between now and {murder.timeout} > 60 seconds:
            send "&c投票時間が終了しました。次の殺人事件まで待ってください。"
            stop
        if arg-1 is "killpenalty" or "innocent":
            if arg-2 is "show":
                if arg-1 is "killpenalty":
                    send "&e死刑に投票したプレイヤー: %{vote.kills::*}%"
                else:
                    send "&e無罪に投票したプレイヤー: %{vote.innocent::*}%"
                stop
            if player is in {voters::*}:
                send "&cあなたはすでに投票済みです!"
                stop
            add player to {voters::*}
            if arg-1 is "killpenalty":
                add player to {vote.kills::*}
                broadcast "&6[投票スクリプト] &e%player% が死刑に投票しました。 &7(投票済: %{vote.kills::*}% / %size of all players%)"
            else:
                add player to {vote.innocent::*}
                broadcast "&6[投票スクリプト] &e%player% が無罪に投票しました。 &7(投票済: %{vote.innocent::*}% / %size of all players%)"
        else:
            send "&c無効なコマンドです。/vote <killpenalty|innocent> [show] を使用してください。"
(I'm Japanese, so please forgive me if some of the code is Japanese...)
 

Attachments

  • スクリーンショット 2025-01-04 164008.png
    スクリーンショット 2025-01-04 164008.png
    94.8 KB · Views: 15
You can't use "every 1 seconds:" inside the code. It has to be it's own section like your "on death of player" bit.