Skript help with event

Discussion in 'Skript' started by KorixCZ, Jul 5, 2021.

  1. Hello. I need to make the whole event stop as soon as someone leaves the region .. I already had it done and I know it went without variables but now I'm not sure how I did it before .. Rather to say I don't know at all and I don't even I don't remember. Thank you all for your advice

    The code is about robbing a bank with some stuff.
    All messages are in Czech

    on rightclick on sign:
    if "%region at player%" contains "bankavykradani":
    1st line of clicked block is "Vykradani banky"
    set {banka1} to difference between {banka1.%player%} and now
    if {banka1} is less than 4 seconds:
    send "&c&lVYKRADACKA &7Pockej %difference between {banka1} and 4 seconds% nez budes moct vykrast obchod"
    stop
    set {banka1.%player%} to now
    if player has diamond axe:
    if player has rail named "&c&lHackovaci Laptop":
    if player has tripwire hook named "&c&lLockpick":
    send "3" to player
    make player execute command "doc 10 Vykrada sejf"
    make console execute command "gs zkouseni vykradani banky. Ignorujte to dík - Vas buh"
    set {robbery::%event-entity%} to true
    wait 8 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl prvni sejf, zbyva ti jich 9 pro ziskani plne odmeny." to player
    make console execute command "eco give %player% 20000" #První sejf
    wait 2 seconds
    send "&c&lVYKRADACKA &7Vykradas dalsi sejf"
    make player execute command "doc 10 Vykrada sejf"
    wait 8 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl druhy sejf, zbyva ti jich 8 pro ziskani plne odmeny." to player
    make console execute command "eco give %player% 20000" #Druhy sejf
    wait 2 seconds
    send "&c&lVYKRADACKA &7Vykradas dalsi sejf"
    make player execute command "doc 10 Vykrada sejf"
    wait 8 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl tretu sejf, zbyva ti jich 7 pro ziskani plne odmeny." to player
    make console execute command "eco give %player% 20000" #Treti sejf
    wait 2 seconds
    send "&c&lVYKRADACKA &7Vykradas dalsi sejf"
    make player execute command "doc 10 Vykrada sejf"
    wait 8 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl ctvrty sejf, zbyva ti jich 6 pro ziskani plne odmeny." to player
    make console execute command "eco give %player% 20000" #Ctvrty sejf
    wait 2 seconds
    send "&c&lVYKRADACKA &7Vykradas dalsi sejf"
    make player execute command "doc 10 Vykrada sejf"
    wait 8 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl paty sejf, zbyva ti jich 5 pro ziskani plne odmeny." to player
    make console execute command "eco give %player% 20000" #Paty sejf
    wait 2 seconds
    send "&c&lVYKRADACKA &7Vykradas dalsi sejf"
    make player execute command "doc 10 Vykrada sejf"
    wait 8 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl sesty sejf, zbyvaji ti 4 pro ziskani plne odmeny." to player
    make console execute command "eco give %player% 20000" #Sesty sejf
    wait 2 seconds
    send "&c&lVYKRADACKA &7Vykradas dalsi sejf"
    make player execute command "doc 10 Vykrada sejf"
    wait 8 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl sedmy sejf, zbyvaji ti 3 pro ziskani plne odmeny." to player
    make console execute command "eco give %player% 20000" #Sedmy sejf
    wait 2 seconds
    send "&c&lVYKRADACKA &7Vykradas dalsi sejf"
    make player execute command "doc 10 Vykrada sejf"
    wait 8 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl osmy sejf, zbyvaji ti 2 pro ziskani plne odmeny." to player
    make console execute command "eco give %player% 20000" #Osmy sejf
    wait 2 seconds
    send "&c&lVYKRADACKA &7Vykradas dalsi sejf"
    make player execute command "doc 10 Vykrada sejf"
    wait 8 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl devaty sejf, zbyva ti 1 pro ziskani plne odmeny." to player
    make console execute command "eco give %player% 20000" #Devaty sejf
    wait 2 seconds
    send "&c&lVYKRADACKA &7Vykradas dalsi sejf"
    make player execute command "doc 10 Vykrada sejf"
    wait 8 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl vsechny sejfy a tak ziskavas plnou odmenu!" to player
    make console execute command "eco give %player% 20000" #Desaty sejf
    give player 5 gold ingots named "&6&lZlato"
    wait 2 seconds
    send "&c&lVYKRADACKA &7Uspesne si vykradl celou banku! Vice tu nemaji! Budes muset pockat %difference between {banka1} and 4 seconds% nez naskladni nejake penize"
    if {robbery::%event-entity%} is set:
    delete {robbery::%event-entity%}
    stop
    else:
    send "&c&lVYKRADACKA &7to jsi si vazne myslel, ze muzes obchod vykrast bez zbrane? Volam policii!"
    stop

    on leave of region "bankavykradani":
    send "naser si"

    Code on pastebin - https://pastebin.com/YC5HjLyX

    Thanks for help <3
     
  2. you should use a loop - repetitive code is not good (if your code is repetitive it means you're doing something wrong and need to do something else, because programming is designed to remove the need to do repetitive tasks, not to do them in the code), then in that loop you can add a condition
     
  3. Would it be possible to show me an example from which I would better understand it? I'm just learning a script. I would love to thank you very much
     
  4. example:

    loop 10 times:
    stop if {timer::running} is not set
    send "Something will happen in %abs(loop-number - 10)% seconds!"
    wait a second