#Custom Commands issue

1 messages · Page 1 of 1 (latest)

oak galleon
#

So i have a small issue with my custom commands, where when i use a command it still sends the message of the command instead of hiding it
Code:

world.beforeEvents.chatSend.subscribe((eventData) => {
    const player = eventData.sender;

    if (!player.hasTag('owner' || 'admin' || 'staff')) {
        const commandMapping = {
            '!help': 'say test',
            '!lobby': 'function tp/lobby'
        };

        const command = commandMapping[eventData.message];
        if (command) {
            player.runCommandAsync(command);
            eventData.cancel = true;
        }
    } else {
        const commandMapping = {
            '!gmc': 'gamemode c',
            '!gma': 'gamemode a',
            '!gms': 'gamemode spectator'
        };

        const command = commandMapping[eventData.message];
        if (command) {
            player.runCommandAsync(command);
            eventData.cancel = true;
        }
    }
});
west crow
#

This works fine

pulsar rock
#
if (!["owner","admin","staff"].some(tag => player.hasTag(tag)))
pulsar rock
#

exchange to the 1st if statement

oak galleon
#

but in what way is yours better than mine? They both work?

#

i just need my scripts to work enough, not be optimized

pulsar rock
#
console.warn("admin" || "staff")
inner scrollBOT
pulsar rock
#

thats how || works

oak galleon
#

yea, its an or operator

pulsar rock
#

ye, but it wont check for staff tag

oak galleon
#

from my tests it did

pulsar rock
#

without admin and owner tag?

oak galleon
#

ye

pulsar rock
#

can u use !gmc with just staff tag?

oak galleon
#

ye

pulsar rock
#

ah ye, but owner tag would be different

oak galleon
#

oh wait, it doesnt work lmao

#

i thought it did, but apparently it doenst anymore

fading hamlet