Solved Save players inventory in function

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

HumbleMC

Member
Nov 8, 2018
18
1
0
26
Hi everyone,

I am working on a save function for players inventory's but I have ran into a little problem.

I am trying to pass through the player to the function then save the inventory based off their name, no custom names.

But trying to achieve this is a bit difficult..

Here is my current code:
code_language.skript:
command /test:
    trigger:
        SaveInv(player)
        
function SaveInv(p: player):
    set helmet of {_p} to leather helmet
    set {_pText} to "%{_p}%"
    set {_count} to 0
    loop 36 times:
        set {inv.%_p%.%{_count}%.%_p%} to slot {_count} of {_p}'s inventory
        add 1 to {_count}
    message "%{_pText}%" to {_p}

Here is the error message:
upload_2018-11-12_1-19-4.png


If someone can help me that would be great :emoji_slight_smile:

Thanks in advance.
 
It's because you're using %_p% but you should use %{_p}%. There is also no need to put the player variable in there twice.
 
It's because you're using %_p% but you should use %{_p}%. There is also no need to put the player variable in there twice.
I tried this and removed the second player variable in the set line but I am now getting an error of

"Can't understand this Expression: slot {_count} of _p inventory set {inv.%{_p}%.%{_count}%} to slot {_count} of _p inventory"
 
I tried this and removed the second player variable in the set line but I am now getting an error of

"Can't understand this Expression: slot {_count} of _p inventory set {inv.%{_p}%.%{_count}%} to slot {_count} of _p inventory"
Use
code_language.skript:
set {inv.%{_p}%.%{_count}%} to slot {_count} of {_p}'s inventory
 
Status
Not open for further replies.