Solved Help with Cheque System

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

Djavan

Member
Jul 19, 2019
16
0
0
Hey y'all,
I made a Cheque system but if I use it it doesn't give you any money.
The error is on 9 (make player execute command "/eco give {cheque::%player%}").
I want to have {cheque::%player%} as number.
Can someone help me with this please?

Information below


Skript Version: Skript 2.2-dev36
Minecraft Version: 1.12.2
---
[EDIT]
Fixed some problems in the skript.
New skript below!

[FIXED-VERSION (V.3)]
Code:
command /testcheque <number>:

  trigger:
    if {money.%player%} is smaller than or equal to 0:
      send "&e&lMONEY&r &e- &cJe hebt niet genoeg geld voor zo'n cheque!"
    if arg-1 is greater than {money.%player%}:
      send "&e&lMONEY&r &e- &cJe hebt niet genoeg geld voor zo'n cheque!"
    else:
      remove arg-1 from {money.%player%}
      give player 1 paper of fortune 1 named "&aCheque" with lore "&7From: %player% ||%arg-1%"
      send "&e&lMONEY&r &e- &cJe hebt succesvol een cheque gemaakt van %arg-1%$!" to player
 
On right click holding a paper of fortune 1:
    if name of tool of player contains "&aCheque":
        set {_value} to the 2nd line of the tool's lore parsed as number
        remove paper from the player's tool
        add {_value} to {money.%player%}
        send "&e&lMONEY&r &e- &cJe hebt succesvol de cheque geïnd! %{_value}%$ is toegevoegd aan je account en nu heb je %{money.%player%}%$!" to player


[FIXED-VERSION (V.2)]

Code:
command /testcheque <integer>:
  trigger:
    remove arg-1 from {money.%player%}
    give player 1 paper of fortune 1 named "&aCheque" with lore "&7From: %player% ||%arg-1%"
    send "&e&lMONEY&r &e- &cJe hebt succesvol een cheque gemaakt van %arg-1%$!" to player
 
On right click holding a paper of fortune 1:
    if name of tool of player contains "&aCheque":
        set {_value} to the 2nd line of the tool's lore parsed as integer
        remove paper from the player's tool
        add {_value} to {money.%player%}
        send "&e&lMONEY&r &e- &cJe hebt succesvol de cheque geïnd! %{_value}%$ is toegevoegd aan je account en nu heb je %{money.%player%}%$!" to player


[WRONG CODE (V.1)]
Code:
command /testcheque <number>:
  trigger:
    give player 1 paper of fortune 1 named "&aCheque"
    set {cheque::%player%} to arg-1
    message "&aJe hebt een Cheque van %arg 1%$ opgenomen" to player
 
On right click holding a paper:
    if name of tool of player is "&aCheque":
        make player execute command "/eco give {cheque::%player%}"
        delete {cheque::%player%}
        remove 1 paper from the player

Errors on Reload:
(There are no errors but the paper doesn't give you anything)

Code:
> [18:36:37 INFO]: [Skript] Reloading d-skript.sk...
> [18:36:37 INFO]: [Skript] Successfully reloaded d-skript.sk.


[EDIT]
I work with a own skript currency. Skript below:
Code:
variables:
    {money.%player%} = 0 #Here you can edit how much many do players have at the start of playing on your server.

command /money [<offlineplayer>]:
    trigger:
        if arg-1 is not set:
            message "&e&lMONEY&r &e- You have &c%{money.%player%}% &emoney."
        else:
            if player has permission "money.admin":
                message "&e&lMONEY&r &e- %arg-1% has &c%{money.%arg-1%}% &emoney."
            else:
                message "&e&lMONEY&r &e- &cYou don't have permission to use that command!"

command /pay <player> <number>:
    trigger:
        if arg-1 is "%player%":
            message "&e&lMONEY&r &e- &cYou cannot pay money to yourself!"
        else:
            if arg-2 > 0:
                if {money.%player%} > 0:
                    remove arg-2 from {money.%player%}
                    add arg-2 to {money.%arg-2%}
                    wait 1 tick
                    if {money.%player%} > 0:
                        message "&e&lMONEY&r &e- You have given &c%arg-2%&e money to %arg-1%!" to player
                        message "&e&lMONEY&r &e- %player% has sent you &c%arg-2%&e money!" to arg-1
                    else:
                        message "&e&lMONEY&r &e- &cYou don't have enough money to pay!"
                        remove arg-2 from {money.%arg-2%}
                        add arg-2 to {money.%player%}
                else:
                    message "&e&lMONEY&r &e- &cYou don't have enough money to pay!"
            else:
                message "&e&lMONEY&r &e- &cYou cannot pay 0 or less money."

command /eco <text> [<player>] [<number>]:
    permission: money.admin
    permission message: &e&lMONEY&r &e- &cYou don't have permission to use that command!
    trigger:
        if arg-1 is "help": #HELP
            message "&2&m---&r&2&lEasyEconomy Help&r&2&m---"
            message "&a&o<> is required, () is optional"
            message "&e/money (player) &2- Shows your/player's balance"
            message "&e/pay <player> <amount> &2- Pay someone from your account"
            message "&e/eco help &2- Shows EasyEconomy Help"
            message "&e/eco give (player) <amount> &2- Gives money to a player"
            message "&e/eco take (player) <amount> &2- Takes money from a player"
        else if arg-1 is "give": #GIVE
            if arg-2 is not set:
                if arg-3 is not set:
                    message "&e&lMONEY&r &e- &cYou had not set money argument!"
                else:
                    add arg-3 to {money.%player%}
                    message "&e&lMONEY&r &e- &c%arg-3%&e money was added to your account!"
            else:
                if arg-3 is not set:
                    message "&e&lMONEY&r &e- &cYou had not set money argument!"
                else:
                    add arg-3 to {money.%arg-2%}
                    message "&e&lMONEY&r &e- &c%arg-3%&e money was added to %arg-2%'s account!"
                    message "&e&lMONEY&r &e- &c%arg-3%&e money was added to your account!" to arg-2
        else if arg-1 is "take": #TAKE
            if arg-2 is not set:
                if arg-3 is not set:
                    message "&e&lMONEY&r &e- &cYou had not set money argument!"
                else:
                    remove arg-3 from {money.%player%}
                    message "&e&lMONEY&r &e- &c%arg-3%&e money was taken from your account!"
            else:
                if arg-3 is not set:
                    message "&e&lMONEY&r &e- &cYou had not set money argument!"
                else:
                    remove arg-3 from {money.%arg-2%}
                    message "&e&lMONEY&r &e- &c%arg-3%&e money was taken from %arg-2%'s account!"
                    message "&e&lMONEY&r &e- &c%arg-3%&e money was taken from your account!" to arg-2
 
Last edited:
So, you are setting a variable with the player name to a value from the command (arg-1)

Code:
{cheque::%player%} to arg-1

You know that the variable will be set as the name of the player who created the cheque, right?
So, if you create the cheque, this will set the variable to your name.

When you do the "on right click holding a paper:", the %player% will be the one holding the cheque.

So you want a cheque system that you can only use it yourself?
Also, this system won't work with multiple cheques.

Example:

Player named "Roberto" creates a cheque with the value of 500.
Later, he creates another cheque with the value of 300.

The variable {cheque::%player%}, in this case, {cheque::Roberto} will be set to the last value, 300. The 500 value will be lost, and the first and second cheque will have the same value, because you set the value in this poorly done variable.

-------------

My suggestion:

Set the value of the cheque in the lore.
Set the name of the player in the lore (so no cheque falsification by using a anvil)

If you do your cheque based on the item name on the paper, someone can go to an anvil and set the name on a paper to another player's name and steal the cheque.

Good luck.
 
Thanks for your reply!
I fixed the problem with the mutiple cheques, but now I want that every player can collect a cheque from another player.
Can you help me fix that?

So, you are setting a variable with the player name to a value from the command (arg-1)

Code:
{cheque::%player%} to arg-1

You know that the variable will be set as the name of the player who created the cheque, right?
So, if you create the cheque, this will set the variable to your name.

When you do the "on right click holding a paper:", the %player% will be the one holding the cheque.

So you want a cheque system that you can only use it yourself?
Also, this system won't work with multiple cheques.

Example:

Player named "Roberto" creates a cheque with the value of 500.
Later, he creates another cheque with the value of 300.

The variable {cheque::%player%}, in this case, {cheque::Roberto} will be set to the last value, 300. The 500 value will be lost, and the first and second cheque will have the same value, because you set the value in this poorly done variable.

-------------

My suggestion:

Set the value of the cheque in the lore.
Set the name of the player in the lore (so no cheque falsification by using a anvil)

If you do your cheque based on the item name on the paper, someone can go to an anvil and set the name on a paper to another player's name and steal the cheque.

Good luck.
 
If you use skript 2.3 or newer, lore is built into skript.
I made the code for you.

Code:
command /cheque <integer>:
  trigger:
      remove arg-1 from {money.%player%}
      give player 1 paper of fortune 1 named "&aCheque" with lore "From: %player%", "%arg-1%"
      send "You sucefully created a cheque of $%arg-1%!" to player

On right click holding a paper of fortune 1:
    if name of tool of player contains "&aCheque":
        set {_value} to the 2nd line of the tool's lore parsed as integer
        remove paper from the player's tool
        add {_value} to {money.%player%}
        send "You sucefully cashed the cheque! $%{_value}% was added to your account, and now you have $%{money.%player%}%!" to player

I did not test it, but i think it should work.

EDIT:

Fixed the "set {_value} to the 2nd line", was 3rd line before, now is fixd.
 
Thanks, but I tested it and it gave 1 error.
Code:
> [21:35:22 INFO]: [Skript] Reloading d-skript.sk...
> [21:35:23 ERROR]:
> [21:36:38 INFO]: [Skript] Reloading d-skript.sk...
> [21:36:39 ERROR]: (lore and "%the 1st argument% ||") can't be added to a player because the former is neither an item type, an inventory nor an experience point (d-skript.sk, line 345: give player 1 paper of fortune 1 named "&aCheque" with lore "|| From: %player%", "%arg-1% ||"')
> [21:36:39 INFO]: [Skript] Encountered 1 error while reloading d-skript.sk!
Can you fix that?

If you use skript 2.3 or newer, lore is built into skript.
I made the code for you.

Code:
command /cheque <integer>:
  trigger:
      remove arg-1 from {money.%player%}
      give player 1 paper of fortune 1 named "&aCheque" with lore "From: %player%", "%arg-1%"
      send "You sucefully created a cheque of $%arg-1%!" to player

On right click holding a paper of fortune 1:
    if name of tool of player contains "&aCheque":
        set {_value} to the 2nd line of the tool's lore parsed as integer
        remove paper from the player's tool
        add {_value} to {money.%player%}
        send "You sucefully cashed the cheque! $%{_value}% was added to your account, and now you have $%{money.%player%}%!" to player

I did not test it, but i think it should work.

EDIT:

Fixed the "set {_value} to the 2nd line", was 3rd line before, now is fixd.
 
With or without it it still gives the same error.
(BTW, I did that because I used it for every lore in my skript)
You added || to the code? before the lore?
[doublepost=1563738130,1563737985][/doublepost]I edited player (line 4 of your skript) with arg-1 but now it gives this error:
Code:
> [21:42:01 INFO]: [Skript] Reloading d-skript.sk...
> [21:42:02 ERROR]: the 1st argument can't have anything added to it (d-skript.sk, line 345: give arg-1 1 paper of fortune 1 named "&aCheque" with lore "From: %player%", "%arg-1% ||"')
> [21:42:02 INFO]: [Skript] Encountered 1 error while reloading d-skript.sk!

With or without it it still gives the same error.
(BTW, I did that because I used it for every lore in my skript)
 
give player 1 paper of fortune 1 named "&aCheque" with lore "From: %player% || %arg-1%"

try this
 
The skript works but in chat it says:
You succesfully created a cheque of $150.
You succesfully cashed the cheque! $<none> was added to your account, and now you have $-150! (It only takes money from your account and it doesnt give anything

give player 1 paper of fortune 1 named "&aCheque" with lore "From: %player% || %arg-1%"

try this
 
Did the lore of the item get set? You saw if the second line of the lore was "150"?
 
upload_2019-7-21_21-52-53.png


[EDIT]
If I use this command: /testcheque 10

Did the lore of the item get set? You saw if the second line of the lore was "150"?
 
Remove the space after the ||

this:

give player 1 paper of fortune 1 named "&aCheque" with lore "From: %player% ||%arg-1%"

The problem seems to be with the variable {_value} that is not being set.
 
It fixed the problem, thank you so much for your time!!

Remove the space after the ||

this:

give player 1 paper of fortune 1 named "&aCheque" with lore "From: %player% ||%arg-1%"

The problem seems to be with the variable {_value} that is not being set.
 
I fixed some issues in the skript like, getting the cheque if your balance is lower than 0 and getting the cheque if arg-1 is greater than the balance.
If you want to use the skript you are free to do that. Use the skript (v.3).
 
Status
Not open for further replies.