Solved Variables on Damage Event

  • 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!

Status
Not open for further replies.

JustADev

Well-Known Member
Apr 8, 2017
379
9
18
22
Can I do this?:

code_language.skript:
                    if {_It} is not set:
                        set {_It} to a random element out of {_players::*}
                        play raw sound "mob.enderdragon.growl" at player with pitch 1 volume 1
                        broadcast "&8[&bMinigame&8] &b%{_It}% &eis the &cTagger"
                        send "&8[&bMinigame&8] &eYou are the &cTagger" to {_It}
                        equip {_It} with red wool block named "&cYou are the Tagger"
                        equip {_It} with leather chestplate named "&eTagger Chestplate" dyed yellow
                        equip {_It} with leather leggings named "&eTagger Leggings" dyed yellow
                        equip {_It} with leather boots named "&eTagger Boots" dyed yellow
                       
on damage of player:
    attacker is {_It}:
        victim is player:
            broadcast "&8[&bMinigame&8] &b%victim% &eis now the &cTagger"

It does not work btw :emoji_slight_smile: and the spacing is good, I just didnt input the rest of my code because it doesnt have to do with the {_It} variable
 
code_language.skript:
command /setminigamelobby:
    description: Sets the minigame specified lobby
    permission: lobbyminigame.setlobby
    permission message: &c&l(!) You do not have permission to do this (!)
    trigger:
        if {lobby} is set:
            delete {lobby}
            set {lobby} to player's location
            send "&8[&bMinigame&8] &eYou have set the location of the lobby"
        else:
            set {lobby} to player's location
            send "&8[&bMinigame&8] &eYou have set the location of the lobby"
            
command /setminigamemap:
    description: Sets the minigame specified map
    permission: lobbyminigame.setmap
    permission message: &c&l(!) You do not have permission to do this (!)
    trigger:
        if {map} is set:
            delete {map}
            set {map} to player's location
            send "&8[&bMinigame&8] &eYou have set the location of the map"
        else:
            set {map} to player's location
            send "&8[&bMinigame&8] &eYou have set the location of the map"


on load:
    if {_ingame} is not set:
        set {_ingame} to false
    if {_ingame} is true:
        set {_ingame} to false


command /startminigame [<text>]:
    description: Activate a Lobby Minigame
    permission: minigame.start
    permission message: &c&l(!) You do not have permission to do this (!)
    trigger:
        if arg-1 is not set:
            send "&8[&bMinigame&8] &7You must specify a minigame"
            send "&bMinigames: &fTag"
        else:
            if arg-1 is "Tag":
                if amount of all players = 1:
                    send "&8[&bMinigame&8] &7There are not enough players online to do that"
                    stop
                else:
                    if amount of all players = 2:
                        set {_ingame} to true
                        delete {_players::*}
                        delete {_It}
                        clear inventories of players
                        set gamemode of all players to survival
                        teleport players to {lobby}
                        set {_time} to 30
                        broadcast "&8[&bMinigame&8] &eThe game will start in &b30 seconds"
                    while {_time} is more than 0:
                        set player's level to {_time}
                        remove 1 from {_time}
                        wait 1 second
                        if {_time} is 10:
                            play raw sound "random.orb" at player with pitch 1 volume 1
                            broadcast "&8[&bMinigame&8] &eThe game will start in &b%{_time}% seconds"
                        if {_time} is 3 or 2 or 1:
                            play raw sound "random.orb" at player with pitch 1 volume 1
                            broadcast "&8[&bMinigame&8] &eThe game is starting in %{_time}%"
                        if {_time} is 0:
                            set player's level to 0
                    loop all players:
                        add loop-players to {_players::*}
                        wait 1 tick
                        teleport {_players::*} to {map}
                    send ""
                    send "&8[&bMinigame&8] &eThe tagger will be picked in &b10 seconds"
                    wait 10 seconds
                    if {_It} is not set:
                        set {_It} to a random element out of {_players::*}
                        play raw sound "mob.enderdragon.growl" at player with pitch 1 volume 1
                        broadcast "&8[&bMinigame&8] &b%{_It}% &eis the &cTagger"
                        send "&8[&bMinigame&8] &eYou are the &cTagger" to {_It}
                        equip {_It} with red wool block named "&cYou are the Tagger"
                        equip {_It} with leather chestplate named "&eTagger Chestplate" dyed yellow
                        equip {_It} with leather leggings named "&eTagger Leggings" dyed yellow
                        equip {_It} with leather boots named "&eTagger Boots" dyed yellow
                        
on damage of player:
    if attacker is {_It}:
        if victim is player:
        broadcast "&8[&bMinigame&8] &b%victim% &eis now the &cTagger"


Looks like you're trying to use a local variable across events. Use a global variable (no underscore)
That did not work
 
So how do I recall the exact player variable from this Line on the event?
code_language.skript:
                        set {_It} to a random element out of {_players::*}
[doublepost=1502584767,1502583566][/doublepost]:emoji_grinning: I got it on my own
code_language.skript:
command /setminigamelobby:
    description: Sets the minigame specified lobby
    permission: lobbyminigame.setlobby
    permission message: &c&l(!) You do not have permission to do this (!)
    trigger:
        if {lobby} is set:
            delete {lobby}
            set {lobby} to player's location
            send "&8[&bMinigame&8] &eYou have set the location of the lobby"
        else:
            set {lobby} to player's location
            send "&8[&bMinigame&8] &eYou have set the location of the lobby"
            
command /setminigamemap:
    description: Sets the minigame specified map
    permission: lobbyminigame.setmap
    permission message: &c&l(!) You do not have permission to do this (!)
    trigger:
        if {map} is set:
            delete {map}
            set {map} to player's location
            send "&8[&bMinigame&8] &eYou have set the location of the map"
        else:
            set {map} to player's location
            send "&8[&bMinigame&8] &eYou have set the location of the map"


on load:
    if {_ingame} is not set:
        set {_ingame} to false
    if {_ingame} is true:
        set {_ingame} to false


command /startminigame [<text>]:
    description: Activate a Lobby Minigame
    permission: minigame.start
    permission message: &c&l(!) You do not have permission to do this (!)
    trigger:
        if arg-1 is not set:
            send "&8[&bMinigame&8] &7You must specify a minigame"
            send "&bMinigames: &fTag"
        else:
            if arg-1 is "Tag":
                if amount of all players = 1:
                    send "&8[&bMinigame&8] &7There are not enough players online to do that"
                    stop
                else:
                    if amount of all players = 2:
                        set {_ingame} to true
                        delete {players::*}
                        delete {It}
                        clear inventories of players
                        set gamemode of all players to survival
                        teleport players to {lobby}
                        set {_time} to 30
                        broadcast "&8[&bMinigame&8] &eThe game will start in &b30 seconds"
                    while {_time} is more than 0:
                        set player's level to {_time}
                        remove 1 from {_time}
                        wait 1 second
                        if {_time} is 10:
                            play raw sound "random.orb" at player with pitch 1 volume 1
                            broadcast "&8[&bMinigame&8] &eThe game will start in &b%{_time}% seconds"
                        if {_time} is 3 or 2 or 1:
                            play raw sound "random.orb" at player with pitch 1 volume 1
                            broadcast "&8[&bMinigame&8] &eThe game is starting in %{_time}%"
                        if {_time} is 0:
                            set player's level to 0
                    loop all players:
                        add loop-players to {players::*}
                        wait 1 tick
                        teleport {players::*} to {map}
                    send ""
                    send "&8[&bMinigame&8] &eThe tagger will be picked in &b10 seconds"
                    wait 10 seconds
                    if {It} is not set:
                        set {It} to a random element out of {players::*}
                        play raw sound "mob.enderdragon.growl" at player with pitch 1 volume 1
                        broadcast "&8[&bMinigame&8] &b%{It}% &eis the &cTagger"
                        send "&8[&bMinigame&8] &eYou are the &cTagger" to {It}
                        equip {It} with red wool block named "&cYou are the Tagger"
                        equip {It} with leather chestplate named "&eTagger Chestplate" dyed yellow
                        equip {It} with leather leggings named "&eTagger Leggings" dyed yellow
                        equip {It} with leather boots named "&eTagger Boots" dyed yellow
                        
on damage of player:
    if attacker is {It}:
        if victim is player:
            broadcast "&8[&bMinigame&8] &b%victim% &eis now the &cTagger"
 
Status
Not open for further replies.