Solved I need help on "if player has" line

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

    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.

ho99ma123

Member
Mar 18, 2021
2
1
3
So this is basically a jail system, whenever the player gets in jail(dies), they have to pay 3 diamonds.
if they jailed again, they have to pay 6, and 9, and 12....(number of player sent to the jail * 3)
if the player has more diamond than he has to pay, the console will unjail the player, but
if player has {pay.player} diamond: <<I think this if statement cannot use variables. it works fine with the numbers, but not the variable. it skips to the else statement. {pay.diamond} supposed to be the amount of diamonds that the player has to pay to get unjailed.
I also tried if player's inventory contains {pay.player} of diamond:

here is the code:


on death of player:
player has permission "hack.worker":
if {salve.value} is true:
add 1 to {slave.player}
set {salve.value} to false
execute console command "jail %player% 1 100000000"

command /test:
trigger:
if {salve.value} is false:
set {pay.player} to {slave.player} * 3
if player has {pay.player} diamond:
remove {pay.player} of diamond from player
execute console command "unjail %player%"
set {salve.value} to true
send "&f&lyou were released" to player
else:
send "&f&lYou do not have enough diamonds! (Diamonds needed: &4%{pay.player}%&f&l" to player
else:
send "&f&lUnavailable for you" to player
 
So this is basically a jail system, whenever the player gets in jail(dies), they have to pay 3 diamonds.
if they jailed again, they have to pay 6, and 9, and 12....(number of player sent to the jail * 3)
if the player has more diamond than he has to pay, the console will unjail the player, but
if player has {pay.player} diamond: <<I think this if statement cannot use variables. it works fine with the numbers, but not the variable. it skips to the else statement. {pay.diamond} supposed to be the amount of diamonds that the player has to pay to get unjailed.
I also tried if player's inventory contains {pay.player} of diamond:

here is the code:


on death of player:
player has permission "hack.worker":
if {salve.value} is true:
add 1 to {slave.player}
set {salve.value} to false
execute console command "jail %player% 1 100000000"

command /test:
trigger:
if {salve.value} is false:
set {pay.player} to {slave.player} * 3
if player has {pay.player} diamond:
remove {pay.player} of diamond from player
execute console command "unjail %player%"
set {salve.value} to true
send "&f&lyou were released" to player
else:
send "&f&lYou do not have enough diamonds! (Diamonds needed: &4%{pay.player}%&f&l" to player
else:
send "&f&lUnavailable for you" to player

This should work:

code_language.skript:
if amount of diamonds in player's inventory => {pay.player}:
   #do stuff

Also, the variable {pay.player} is a general variable, not per player like this {pay.%player%} when the variable's value is per player.
 
This should work:

code_language.skript:
if amount of diamonds in player's inventory => {pay.player}:
   #do stuff

Also, the variable {pay.player} is a general variable, not per player like this {pay.%player%} when the variable's value is per player.

worked!
using 1.12.2 and logic "=>" doesnt work for me. do I used ">" instead.
Thanks!
 
  • Like
Reactions: couger44
Status
Not open for further replies.