Solved Problem with duels :D

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

BoxMiners

Member
Jul 19, 2022
47
0
6
18
Code:
command /duel [<offline player>]:
 cooldown: 1 second
 trigger:
  if arg 1 is not set:
   send "&cNot a valid player"
  else if arg 1 is set:
   if arg 1 = player:
    send "&cYou can't duel yourself!"
   else:
    send "&c%player% &awants to duel you &8| &7/request accept &c%player% &7to accept" to arg 1
    send "&7Successfully send a request to &c%arg-1%"
    set {request::%player%} to true
    set {asked::%arg-1%} to true
    wait 1 minute
    delete {asked::%arg-1%} and {request::%player%}
 
command /request [<text>] [<offline player>]:
 trigger:
  if arg 1 is not set:
   send "&cNot a valid type"
   send "&cOptions: Accept, Deny"
  if arg 1 is set:
   if arg 2 is not set:
    send "&cNot a valid player"
   if arg 1 is "accept":
    if arg 2 is set:
     if {request::%arg-2%} is set:
      if {asked::%player%} is set:
       teleport arg 2 to location(-241, 94, -281, world "world")
       teleport player to location(-241, 94, -241, world "world")
       set {duels::%player%} to true
       set {duelss::%arg-2%} to true
       set {duel::%player%::*} to all items in inventory of player
       set {duels::%arg-2%::*} to all items in inventory of player
       clear player's inventory
       clear arg-2's inventory
       stop
   else if arg 1 is "deny":
    delete {request::%arg-2%} and {asked::%player%}
 
on respawn:
  if {duels::%player%} is set:
    delete {duels::%player%}
    wait 5 ticks
    set {_inventory} to chest inventory with 5 rows named "&aSaved Items"
    wait 2 ticks
    loop {duel::%player%::*}:
      add loop-value to {_inventory}
    open {_inventory} to player
    set {secstore::%player%} to true
 
on respawn:
    if {duelss::%player%} is set:
        delete {duelss::%player%}
        wait 5 ticks
        set {_inventory} to chest inventory with 5 rows named "&aSaved Items"
        wait 2 ticks
        loop {duels::%player%::*}:
            add loop-value to {_inventory}
        open {_inventory} to player
        set {secstore::%player%} to true
i was making this for duels 1v1 and it reloades but when you respawn as the arg-2 in request you look in the other persons items which is weird i couldnt find anything on other places please help if you have any idea how to fix
 
I rewrite most part of your's code.


Code:
command /duel [<player>]:
 cooldown: 1 second
 trigger:
  if {p::%uuid of player%::currentDuel} is not set:
   if arg-1 is set:
    if arg-1 is not player:
     if {duels::requests::%uuid of arg-1%::%uuid of player%} is not set:
      send "&c%player% &awants to duel you &8| &7/request accept &c%player% &7to accept" to arg 1
      send "&7Successfully send a request to &c%arg-1%"
    
      set {duels::requests::%uuid of arg-1%::%uuid of player%} to player
      set {p::%uuid of player%::sendedRequests::%uuid of arg-1%} to arg-1

      wait 1 minute
      delete {duels::requests::%uuid of arg-1%::%uuid of player%},{p::%uuid of player%::sendedRequests::%uuid of arg-1%}
     else:
      send "You cancel your's request to %arg-1%"
      send "%player% cancel request to duel with you" to arg-1
      delete {duels::requests::%uuid of arg-1%::%uuid of player%},{p::%uuid of player%::sendedRequests::%uuid of arg-1%}
    else:
     send "&cYou cant send request to yourself"
   else:
    send "&cNot a valid player"
  else:
   send "&cYou cant send requests when duel is running"

command /request [<text>] [<player>]:
 trigger:
  if {p::%uuid of player%::currentDuel} is not set:
   if arg 2 is not set:
    send "&cNot a valid player"
   else if arg 1 is set:
    if arg-1 is "accept":
     if {duels::requests::%uuid of player%::%uuid of arg-2%} is set:
      send "&aYour's request accepted by %player%" to arg-2
    
      delete {duels::requests::%uuid of player%::%uuid of arg-2%}
      delete {p::%uuid of arg-2%::sendedRequests::%uuid of player%}

      add 1 to {duels::counter}

      set {duels::active::%{duels::counter}%::previousLocations::%uuid of player%} to location of player
      set {duels::active::%{duels::counter}%::previousLocations::%uuid of arg-2%} to location of arg-2
      set {duels::active::%{duels::counter}%::players::%uuid of player%} to arg-2
      set {duels::active::%{duels::counter}%::players::%uuid of arg-2%} to player
      set {duels::active::%{duels::counter}%::savedItems::%uuid of player%::*} to all items in inventory of player
      set {duels::active::%{duels::counter}%::savedItems::%uuid of arg-2%::*} to all items in inventory of arg-2

      set {p::%uuid of player%::currentDuel} to {duels::counter}
      set {p::%uuid of arg-1%::currentDuel} to {duels::counter}
    
      teleport arg-2 to location(-241, 94, -281, world "world")
      teleport player to location(-241, 94, -241, world "world")
      clear player's inventory
      clear arg-2's inventory
     else:
      send "&cYou doesn't have requests from this player"
    else if arg-1 is "deny":
     if {duels::requests::%uuid of player%::%uuid of arg-2%} is set:
      send "&c%player% denied your's request to duel" to arg-2
      delete {duels::requests::%uuid of player%::%uuid of arg-2%}
      delete {p::%uuid of arg-2%::sendedRequests::%uuid of player%}
     else:
      send "&cYou doesn't have requests from this player"
    else:
     send "&cNot a valid type"
     send "&cOptions: Accept, Deny"
  else:
   send "&cYou cant accept requests when duel is running"

on respawn:
 if {p::%uuid of player%::currentDuel} is set:
  set {_duelId} to {p::%uuid of player%::currentDuel}
 
  wait 5 ticks
  
  teleport player to {duels::active::%{_duelId}%::previousLocations::%uuid of player%}
 
  set {_inventory} to chest inventory with 5 rows named "&aSaved Items"
  loop {duels::active::%{_duelId}%::savedItems::%uuid of player%::*}:
   add loop-value to {_inventory}
  open {_inventory} to player
 
  delete {p::%uuid of player%::currentDuel}
  delete {duels::active::%{_duelId}%::previousLocations::%uuid of player%}
  delete {duels::active::%{_duelId}%::players::%uuid of player%}
  delete {duels::active::%{_duelId}%::savedItems::%uuid of player%::*}

on death of player:
 if {p::%uuid of victim%::currentDuel} is set:

  set {_duelId} to {p::%uuid of victim%::currentDuel}
  set {_opponent} to {duels::active::%{_duelId}%::players::%uuid of victim%}

  send "&aCongrutilations, you win duel with %victim%" to {_opponent}
  send "&cYou lose duel with %{_opponent}%" to victim

  wait 10 seconds
  teleport {_opponent} to {duels::active::%{_duelId}%::previousLocations::%uuid of {_opponent}%}
 
  set {_inventory} to chest inventory with 5 rows named "&aSaved Items"
  loop {duels::active::%{_duelId}%::savedItems::%uuid of {_opponent}%::*}:
   add loop-value to {_inventory}
  open {_inventory} to {_opponent}
 
  delete {p::%uuid of {_opponent}%::currentDuel}
  delete {duels::active::%{_duelId}%::previousLocations::%uuid of {_opponent}%}
  delete {duels::active::%{_duelId}%::players::%uuid of {_opponent}%}
  delete {duels::active::%{_duelId}%::savedItems::%uuid of {_opponent}%::*}
If you have questions about some parts - continue thread
 
Last edited:
I rewrite most part of your's code.


Code:
command /duel [<player>]:
 cooldown: 1 second
 trigger:
  if {p::%uuid of player%::currentDuel} is not set:
   if arg-1 is set:
    if arg-1 is not player:
     if {duels::requests::%uuid of arg-1%::%uuid of player%} is not set:
      send "&c%player% &awants to duel you &8| &7/request accept &c%player% &7to accept" to arg 1
      send "&7Successfully send a request to &c%arg-1%"
    
      set {duels::requests::%uuid of arg-1%::%uuid of player%} to player
      set {p::%uuid of player%::sendedRequests::%uuid of arg-1%} to arg-1

      wait 1 minute
      delete {duels::requests::%uuid of arg-1%::%uuid of player%},{p::%uuid of player%::sendedRequests::%uuid of arg-1%}
     else:
      send "You cancel your's request to %arg-1%"
      send "%player% cancel request to duel with you" to arg-1
      delete {duels::requests::%uuid of arg-1%::%uuid of player%},{p::%uuid of player%::sendedRequests::%uuid of arg-1%}
    else:
     send "&cYou cant send request to yourself"
   else:
    send "&cNot a valid player"
  else:
   send "&cYou cant send requests when duel is running"

command /request [<text>] [<player>]:
 trigger:
  if {p::%uuid of player%::currentDuel} is not set:
   if arg 2 is not set:
    send "&cNot a valid player"
   else if arg 1 is set:
    if arg-1 is "accept":
     if {duels::requests::%uuid of player%::%uuid of arg-2%} is set:
      send "&aYour's request accepted by %player%" to arg-2
    
      teleport arg-2 to location(-241, 94, -281, world "world")
      teleport player to location(-241, 94, -241, world "world")

      delete {duels::requests::%uuid of player%::%uuid of arg-2%}
      delete {p::%uuid of arg-2%::sendedRequests::%uuid of player%}

      add 1 to {duels::counter}

      set {duels::active::%{duels::counter}%::previousLocations::%uuid of player%} to location of player
      set {duels::active::%{duels::counter}%::previousLocations::%uuid of arg-2%} to location of arg-2
      set {duels::active::%{duels::counter}%::players::%uuid of player%} to arg-2
      set {duels::active::%{duels::counter}%::players::%uuid of arg-2%} to player
      set {duels::active::%{duels::counter}%::savedItems::%uuid of player%::*} to all items in inventory of player
      set {duels::active::%{duels::counter}%::savedItems::%uuid of arg-2%::*} to all items in inventory of arg-2

      set {p::%uuid of player%::currentDuel} to {duels::counter}
      set {p::%uuid of arg-1%::currentDuel} to {duels::counter}
    
      clear player's inventory
      clear arg-2's inventory
     else:
      send "&cYou doesn't have requests from this player"
    else if arg-1 is "deny":
     if {duels::requests::%uuid of player%::%uuid of arg-2%} is set:
      send "&c%player% denied your's request to duel" to arg-2
      delete {duels::requests::%uuid of player%::%uuid of arg-2%}
      delete {p::%uuid of arg-2%::sendedRequests::%uuid of player%}
     else:
      send "&cYou doesn't have requests from this player"
    else:
     send "&cNot a valid type"
     send "&cOptions: Accept, Deny"
  else:
   send "&cYou cant accept requests when duel is running"

on respawn:
 if {p::%uuid of player%::currentDuel} is set:
  set {_duelId} to {p::%uuid of player%::currentDuel}
 
  wait 5 ticks
  
  teleport player to {duels::active::%{_duelId}%::previousLocations::%uuid of player%}
 
  set {_inventory} to chest inventory with 5 rows named "&aSaved Items"
  loop {duels::active::%{_duelId}%::savedItems::%uuid of player%::*}:
   add loop-value to {_inventory}
  open {_inventory} to player
 
  delete {p::%uuid of player%::currentDuel}
  delete {duels::active::%{_duelId}%::previousLocations::%uuid of player%}
  delete {duels::active::%{_duelId}%::players::%uuid of player%}
  delete {duels::active::%{_duelId}%::savedItems::%uuid of player%::*}

on death of player:
 if {p::%uuid of victim%::currentDuel} is set:

  set {_duelId} to {p::%uuid of victim%::currentDuel}
  set {_opponent} to {duels::active::%{_duelId}%::players::%uuid of victim%}

  send "&aCongrutilations, you win duel with %victim%" to {_opponent}
  send "&cYou lose duel with %{_opponent}%" to victim

  wait 10 seconds
  teleport {_opponent} to {duels::active::%{_duelId}%::previousLocations::%uuid of {_opponent}%}
 
  set {_inventory} to chest inventory with 5 rows named "&aSaved Items"
  loop {duels::active::%{_duelId}%::savedItems::%uuid of {_opponent}%::*}:
   add loop-value to {_inventory}
  open {_inventory} to {_opponent}
 
  delete {p::%uuid of {_opponent}%::currentDuel}
  delete {duels::active::%{_duelId}%::previousLocations::%uuid of {_opponent}%}
  delete {duels::active::%{_duelId}%::players::%uuid of {_opponent}%}
  delete {duels::active::%{_duelId}%::savedItems::%uuid of {_opponent}%::*}
If you have questions about some parts - continue thread
hmm. It doesnt quite work when you do /duel player i don't get my items back when i die. But i really appreciate your help :emoji_grinning:
 
hmm. It doesnt quite work when you do /duel player i don't get my items back when i die. But i really appreciate your help :emoji_grinning:
I doesn't test this, time to test this and fix.
[doublepost=1665421135,1665419329][/doublepost]
hmm. It doesnt quite work when you do /duel player i don't get my items back when i die. But i really appreciate your help :emoji_grinning:
I test this and all work good, idk what your's problem
 
I doesn't test this, time to test this and fix.
[doublepost=1665421135,1665419329][/doublepost]
I test this and all work good, idk what your's problem
for me when i get killed by the person. I don't get the items but if i do kill i do get the items. And the winner can't start a new battle cuz it says "You can't start another during the duel" is that supposed to be like that? :emoji_grinning: you are a so help full hand keep up the good work
 
for me when i get killed by the person. I don't get the items but if i do kill i do get the items. And the winner can't start a new battle cuz it says "You can't start another during the duel" is that supposed to be like that? :emoji_grinning: you are a so help full hand keep up the good work
because duel for winner ends after 10 seconds? Remove 'wait 10 seconds' for instantly end
 
  • Like
Reactions: BoxMiners
because duel for winner ends after 10 seconds? Remove 'wait 10 seconds' for instantly end
It worked thank you so much, you're a life saver
[doublepost=1665513012,1665512523][/doublepost]
because duel for winner ends after 10 seconds? Remove 'wait 10 seconds' for instantly end
wait where do i add "
Code:
make {_opponent} execute command "/spawn"
?
 
It worked thank you so much, you're a life saver
[doublepost=1665513012,1665512523][/doublepost]
wait where do i add "
Code:
make {_opponent} execute command "/spawn"
?
I also store previous locations of players before duel, you dont need teleport them to spawn. If you need this - replace lines 99 for winner and 77 for looser
 
Status
Not open for further replies.