Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear Inventory if the player is offline #109

Open
aymanos12345 opened this issue Jun 15, 2024 · 3 comments
Open

Clear Inventory if the player is offline #109

aymanos12345 opened this issue Jun 15, 2024 · 3 comments
Labels
question Further information is requested

Comments

@aymanos12345
Copy link

I added this to zdiscordAs\server\commands\qb-inventory.js :

const mysql = require('mysql2/promise');

// Database configuration
const dbConfig = {
    host: "", 
    user: "",           
    password: "",        
    database: "" 
};
module.exports = {
    name: "inventory",
    description: "Manage player's in-city items",
    role: "admin",

    options: [{
            type: "SUB_COMMAND",
            name: "wipeinventory",
            description: "Wipe a player's inventory by citizenid",
            options: [
                {
                    name: "citizenid",
                    description: "Player's citizenid",
                    required: true,
                    type: "STRING",
                },
            ],
        },
    ],
 run: async (client, interaction, args) => {
        const amount = args.count || 1;

        // ... (your existing code for 'give', 'take', 'inspect')

        else if (args.wipeinventory) {
            const citizenid = args.citizenid;

            try {
                const connection = await mysql.createConnection(dbConfig);

                const [result] = await connection.execute(
                    "UPDATE `players` SET `inventory` = '[]' WHERE `citizenid` = ?",
                    [citizenid]
                );

                if (result.affectedRows > 0) {
                    client.utils.log.info(`[${interaction.member.displayName}] wiped inventory of player with citizenid: ${citizenid}`);
                    interaction.reply({ content: `Inventory wiped for player with citizenid: ${citizenid} (offline/online)`, ephemeral: false });
                } else {
                    interaction.reply({ content: "No player found with that citizenid.", ephemeral: true });
                }

                await connection.end();

            } catch (error) {
                console.error("Error wiping inventory:", error);
                interaction.reply({ content: "An error occurred while wiping the inventory.", ephemeral: true });
            }
        }
    },
};

and i got this error :

Capture d’écran 2024-06-15 193132

i did yarn cache clean and script doesn't start

@aymanos12345 aymanos12345 added the question Further information is requested label Jun 15, 2024
@zfbx
Copy link
Owner

zfbx commented Jun 17, 2024

Why did you clear the yarn cache? The change you mentioned shouldn't of had anything to do with the error you're getting

@aymanos12345
Copy link
Author

They told to Run 'yarn cache clan' to fix the problem on cfx i knew that was not right but i tried xD
So is there something i can provide to help me with this problem

@zfbx
Copy link
Owner

zfbx commented Jun 18, 2024

you could try and delete the node_modules and yarn.installed file and restart the script to see if it pulls the modules again properly or you could just use this one that was generated a few years ago to fix some people's permissions issues on zap hosting https://cdn.discordapp.com/attachments/862934532110024734/967320705609904148/zdiscord_modules.zip?ex=66732c5c&is=6671dadc&hm=0b52da0d17ab8b6de0ebf1aacf45c88f4314296567b457794dcd589972a7221f&

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants