How do I add arguments to a list?

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

akatas

New Member
Feb 16, 2021
7
0
1
16
So I’m trying to make a friends list on my server (adding, removing, opening friend list, all that stuff), and I’m pretty sure I might be doing something wrong. I also want to figure out how to make each person have their own friends list. I’m just learning skript, so I’m going to make plenty of mistakes, and other random stuff.


Here is an example code for adding a friend:

Code:
command /friend [add] <player>:

  if arg-1 is online   // <— this might not be real code idk:
    send “%player% has sent a friend request!” to arg-1
    send “You sent a friend request to %arg-1%!” to player
  else:
    send “%arg-1% is not online right now” to player


Here is some code for accepting the friend request:

Code:
command /friend [accept] <player>:
  if arg-1 is online:
    if {%player%friendslist::*} does not contain arg-1:
      send “%player% has accepted your request!% to arg-1
      send “You are now friends with %arg-1%”
      add arg-1 to {%player%friendslist::*}
      add player to {%arg-1%friendlist::*}   // I really don’t know what I’m doing
    else:
      send “%arg-1% is already your friend!”
  else:
    send “%arg-1% is not online right now”

But I’m wondering if you can add arguments to a list, and remove that specific argument. So if someone could help, that would be greatly appreciated! Thanks
 
So I’m trying to make a friends list on my server (adding, removing, opening friend list, all that stuff), and I’m pretty sure I might be doing something wrong. I also want to figure out how to make each person have their own friends list. I’m just learning skript, so I’m going to make plenty of mistakes, and other random stuff.


Here is an example code for adding a friend:

Code:
command /friend [add] <player>:

  if arg-1 is online   // <— this might not be real code idk:
    send “%player% has sent a friend request!” to arg-1
    send “You sent a friend request to %arg-1%!” to player
  else:
    send “%arg-1% is not online right now” to player


Here is some code for accepting the friend request:

Code:
command /friend [accept] <player>:
  if arg-1 is online:
    if {%player%friendslist::*} does not contain arg-1:
      send “%player% has accepted your request!% to arg-1
      send “You are now friends with %arg-1%”
      add arg-1 to {%player%friendslist::*}
      add player to {%arg-1%friendlist::*}   // I really don’t know what I’m doing
    else:
      send “%arg-1% is already your friend!”
  else:
    send “%arg-1% is not online right now”

But I’m wondering if you can add arguments to a list, and remove that specific argument. So if someone could help, that would be greatly appreciated! Thanks

You have to put "trigger" when you go to create a command.

code_language.skript:
command /friend [<string>] [<offline player>]:
    trigger:
        #...
[doublepost=1614041406,1614041130][/doublepost]Also, you have a bit of unnecessary code. Could reduce it to like this:

code_language.skript:
command /friend [<string>] [<offline player>]:
    trigger:
        arg 1 is "add":
            #Code
        arg 1 is "accept":
            #Code
 
  • Like
Reactions: akatas and Nikd0
I knew there was a way to check when arg-1 is a specific value! Do you need to use “trigger:”? also, my main problem is Can you add an argument value to a list? thanks!
 
I knew there was a way to check when arg-1 is a specific value! Do you need to use “trigger:”? also, my main problem is Can you add an argument value to a list? thanks!
A list? Do you mean to a variable like this?
code_language.skript:
command /friend [<string>] [<offline player>]:
   trigger:
       arg 1 is "add":
           arg 2 is set:
               add arg 2 to {friends::list::%player%::*}
       arg 1 is "list":
           send "&8                   "
           loop {friends::list::%player%::*}
           
               send "%loop-value%"
           send "&8                   "
[doublepost=1614139039,1614121514][/doublepost]Edit: i add a " to send loop-value message.
 
Status
Not open for further replies.