#How to make a specific role to one user, in a staff list?

1 messages · Page 1 of 1 (latest)

balmy surge
#

dude

#

this code is spaghetti

robust sapphire
#

yep

#

not like i could find better o.0

balmy surge
#

wait

#
    return "owner", "headdmin" and "admin


command /stafflist:
    aliases: staff
    trigger:
        loop getStaffTypes():
            broadcast "count of %loop-value%: %size of {stafflist::%loop-value%::*}%"

on join:
    loop getStaffTypes():
        if player has permission "staff.%loop-value%":
            add player to {stafflist::%loop-value%::*}
            stop #stop for op players

on quit:
    loop getStaffTypes():
        if player has permission "staff.%loop-value%":
            remove player from {stafflist::%loop-value%::*}
            ```
#

use like this

robust sapphire
#

Alright

#

ty

#

imma test

balmy surge
robust sapphire
#

also how do i make lists in skript

#

like other programming languages?

balmy surge
#

wdym?

robust sapphire
#

for example

#

i am a python native

valid shale
#

ah, yes, python

robust sapphire
#

so if lists were to be able to be made in skript

valid shale
#

uhmmm

#

but

#

this is a skript help channel

#

gimme a second

jade rivet
#

why are you using wait 0 tick

#

you do realize you can just

#

use if size of {owner::*} > 0:?

robust sapphire
#

i copied this code so yeha

jade rivet
#

ohh

robust sapphire
#

i just modified it

#

for more roles

jade rivet
#

if you de-indent everything from line 42

#

because now the send is in the loop

#

but that shouldnt be the case

#

also please remake this it's horribly inefficient xd

robust sapphire
#

well now i am xd

weary agate
robust sapphire
#

mostly experienced in discord bots

weary agate
#

so you are familiar with dictionaries/dicts correct

robust sapphire
#

yep

weary agate
#

alright so lists in skript are not actual lists/arrays like other languages

#

they are a key value system, just like dictionaries in python

#

so when you do set {_hi::*} to "apple", "orange" and "banana" what its actually making is a dictionary or hashmap (what its referred to as in java) that looks like

{
    "1": "apple",
    "2": "orange",
    "3": "banana"
}
#

skript by default uses numerical indices when setting a list directly or when adding to it, and due to it being a dictionary, thats why all indices are strings

robust sapphire
#

ah

weary agate
#

so then when you do {_hi::1}, you are accessing the "first" element in the list, because well thats the key value pair with 1 as the key and indices are sorted alphabetically

#

so then of course you can do set {_hi::hello} to "something" to add a custom key value pair

#

and when you just use {_hi::*} its just going to return all the values, if you want the keys, you can do indices of {_hi::*}

#

and due to it being a dictionary, you can also add another dictionary inside it, so in turn you can do set {_hi::uhh::yeah} to 5, expanding the example output to something like

{
    "1": "apple",
    "2": "orange",
    "3": "banana",
    "uhh": {
        "yeah": 5
    }
}
fossil pewter
#

be a little careful with that last thing
with set {_hi::uhh::yeah} to 5
{_hi::*} will not show you any 5s or other lists
It only shows elements at that level
so {_hi::uhh} doesn't actually exist, only {_hi::uhh::*} and {_hi::uhh::yeah}

robust sapphire
#

okay

#

also how do i get a value from a nested loop

weary agate
#

just trying to get you to understand how lists work in skript given an example of what you are already familiar with

#

loop-value-n

#

n being the number of the embedded loop

robust sapphire
#

understood

robust sapphire
#

hmm so simple question,
so line 54

add player to {stafflist::%loop-value%::*}
```, does this make * player?
fossil pewter
#

it makes {stafflist::%loop-value%::1} player, given there's nothing already in the list

#

otherwise 1 is size of list + 1

robust sapphire
#

so is 1 integer value of player?

fossil pewter
#

no, it's just an index

robust sapphire
#

okay

fossil pewter
#

if you send {stafflist::%loop-value%::1}, it will send the player's name

#

{stafflist::%loop-value%::1} is the player, 1 is the index

#

and of course, 1 could be any number really, depends on how many indices are used already

robust sapphire
#

I want the player name to actually appear, like StaffRank: player's username

fossil pewter
#

as the index?

#

there's no real reason to have their name in the index in this situation, tbh

robust sapphire
#

not the index actually

#

in any way possible

robust sapphire
#

basically in a minecraft message

#

ah

fossil pewter
#

just send the variable

fossil pewter
#

if you send {stafflist::%loop-value%::*}, it will send all the names of the players in the list

wheat wraith
#

has anyone pointed out that this code would only set the last loop player to anything? Since every loop begind with clearing the lists

fossil pewter
#

i presumed they were using the code deichor sent

robust sapphire
#

hola como estas

#

another question

#

but its an error this time

balmy surge
#

send it

robust sapphire
#

i was in the process of doing that, excuse me 😂

#

but i guess i should never ask to ask

balmy surge
#

what is it?

robust sapphire
#

looks like im gonna send the whole command code

#

brb

#

apparently the last line makes an indention error

#

sorry for the late reply

wheat wraith
#

delete the indentation and place whatever indentation used in the rest of the script

robust sapphire
wheat wraith
#

see the dots? They are spaces.

#

the arrows are tabs

#

choose one and stick with it

#

let me know if that still doesn't make sense xD

robust sapphire
#

i've always indented using tabs

#

and since i use python i know how to indent in a python-y way, so it feels confusing to see a different indention system

#

you feel me?

fossil pewter
#

it's the same

#

just use tabs

#

the problems happen when you use both at the same time

robust sapphire
#

so i reindent them?

#

ahh

wheat wraith
#

yeah just go for tabs

#

skript accepts all kinds of indentation, you just need to be consistent

robust sapphire
#

yeah thats what i was trying to do

#

it fixed 3 errors for reindenting a command

#

now for the very final question

#

how do i access loop values outside the loop, if somehow possible

#

why cucumber?

balmy surge
#

loop-value-1 loop-value-2 ....

weary agate
#

just reference the list with an index

robust sapphire
#

did you get auto cucumbered?

weary agate
robust sapphire
#

true

weary agate
#

so just access the list with an index of what you want

robust sapphire
#

imma try

balmy surge
#

btw skript harder than python smirk_face

robust sapphire
#

even though it is english-ish

#

skript is basically java, but simplified

#

so there will be lots of stuff

#

in conclusion, pure skript is harder than pure python

#

unless you use python to send actual emails

#

good luck doing that with skriptnootnoot

weary agate
#

skemail exists, just for sending emails within skript

balmy surge
#

just a joke dude, just a joke...

weary agate
#

dont ask me why it exists, it just does

robust sapphire
#

why the hell does that exist ;-;

#

that means skript is overall better than python

#

well not really

balmy surge
#

nope it isn't better than python

robust sapphire
#

does skript have sql support

balmy surge
#

for what?

robust sapphire
#

economy

balmy surge
#

whaat...

#

skript isn't economy plugin

fossil pewter
#

skriptdb allows you to use sql (if it works, idk if it still does)

balmy surge
#

don't use skript-db

robust sapphire
#

im used to mongodb anyways

fossil pewter
#

but skript has vanilla hook into vault, which means most economy plugins can just be accessed by using player's balance

weary agate
#

skript has "built in" sql support for variables but it doesnt work

weary agate
balmy surge
robust sapphire
#

yeah ik

#

i've been a discord bot developer for months

weary agate
balmy surge
#

Skript's data storage is really bad.

robust sapphire
#

yeah i know

#

fun fact, discord's first database was actually mongodb

weary agate
#

now its csv like skript

#

for legal reasons thats a joke

balmy surge
robust sapphire
#

if you would use csv for a database

#

you are an absolute idiot

#

even json is better

weary agate
#

csv is faster to parse and easier for noobs to edit

fossil pewter
#

yeah skript's variables are not meant to be used as a database

balmy surge
#

I think the skript should support mongodb and redis combo. This makes it an excellent plugin.

robust sapphire
#

i guess its for storing simple stuff

#

like players

weary agate
robust sapphire
weary agate
robust sapphire
#

usding a database sudch as csv and json could break very fast

weary agate
#

because well skript just stores the variables in ram all at the same time because its not a database

fossil pewter
#

it's a ✨ map ✨

robust sapphire
#

website dbs are the best

weary agate
#

im a map im a map im a map

balmy surge
robust sapphire
#

because you dont rely on your ram

weary agate
#

do do do dorra

balmy surge
#

I guess you don't know much about data

robust sapphire
robust sapphire
fossil pewter
#

the problem with dbs is that they're relatively slow
so for things like variables you want fast things like a map in ram

balmy surge
#

yes that's why we use redis.

robust sapphire
#

i've used mongodb for like 5 months

#

and it treated me well

#

it adds data in collections in a snap

weary agate
#

well yes for things like player data you can use variables and when they leave, push to the db to update, and when they join pull from the db for that session and then periodically push to the db for redundancy

balmy surge
#

MongoDB is good but it doesn't keep the data in ram for you.

robust sapphire
#

look hear me out

weary agate
#

but it does cache things to increase speed

#

which is nice

robust sapphire
#

you need a host to actually use csv

#

relying on local ram is just the worse

#

especially when you have a low end pc... like me unfortunately

fossil pewter
#

what?
csv is just a file format
skript reads the file and loads it into a map in memory
no host needed

balmy surge
#

i mean it is good

robust sapphire
#

am i the only one realizing this help thread just became a second general chat

fossil pewter
#

in some aspects yes

robust sapphire
#

nice

robust sapphire
robust sapphire
fossil pewter
#

eg:
list[index_variable]
->
{list::%{_index_variable}%}

balmy surge
robust sapphire
#

works, now another error came to me 😩😩 do these end?
anyways so there is no error but it says I am JrHelper, but i am op so i have all the perms anyways, how do i do if the loop-player is op then we check their username, if they are a certain username then it sends another message

#

or is it basically just

#
if loop-player is op:
  if loop-player's username is "something":
    send "..." to player
robust sapphire
#

so its 2:38 am rn and i need to get some sleep, ill respond to this forum tomorrow, gn everyone!

robust sapphire
#

i still need a lil help

robust sapphire
#

well i did it myself anyways

#

thank you guys so much for your time <3

balmy surge
#

Do not write here without trying some things.

robust sapphire
#

well i did try things

balmy surge
robust sapphire
#

okay that makes sense