header.banner.textheader.banner.link

📋 switcore.core.sections.overview.title

switcore.core.sections.overview.description

    switcore.core.sections.overview.required

    switcore.core.sections.features.title

    ⚙️ switcore.core.sections.config.title

    switcore.core.sections.config.description

    Config = {}
    
    -- Identifiers care vor fi ignorate (low-trust/high-variance)
    Config.IDENTIFIER_BLOCKLIST = {
        ['ip'] = true
    }
    
    -- Interval pentru actualizarea playtime în baza de date (în secunde)
    Config.PLAYTIME_UPDATE_INTERVAL = 60
    
    -- Activează logging-ul comenzilor
    Config.LOG_COMMANDS = true
    
    -- Grupuri default care vor fi create automat
    Config.DefaultGroups = {
        {
            name = 'player',
            display_name = 'Player',
            priority = 0,
            description = 'Grupul default pentru toți jucătorii'
        },
        {
            name = 'vip',
            display_name = 'VIP',
            priority = 10,
            description = 'Grupul pentru jucători VIP'
        },
        {
            name = 'moderator',
            display_name = 'Moderator',
            priority = 50,
            description = 'Grupul pentru moderatori'
        },
        {
            name = 'admin',
            display_name = 'Administrator',
            priority = 100,
            description = 'Grupul pentru administratori'
        }
    }
    
    -- Permisiuni default pentru fiecare grup
    Config.DefaultGroupPermissions = {
        ['admin'] = {
            'admin.all',
            'admin.kick',
            'admin.ban',
            'admin.teleport',
            'admin.vehicle',
            'admin.money',
            'admin.weapon'
        },
        ['moderator'] = {
            'moderator.kick',
            'moderator.teleport'
        },
        ['vip'] = {
            'vip.vehicle',
            'vip.weapon'
        },
        ['player'] = {} -- Fără permisiuni speciale
    }
    
    return Config

    🗄️ switcore.core.sections.database.title

    switcore.core.sections.database.description

    switcore.core.sections.database.tables.players.title

    switcore.core.sections.database.tables.players.description

    CREATE TABLE players (
        id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        name VARCHAR(255) NOT NULL,
        created_at TIMESTAMP DEFAULT NOW() NOT NULL,
        updated_at TIMESTAMP,
        last_seen TIMESTAMP,
        playtime INTEGER DEFAULT 0 NOT NULL
    );

    switcore.core.sections.database.tables.player_identifiers.title

    switcore.core.sections.database.tables.player_identifiers.description

    CREATE TABLE player_identifiers (
        id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        player_id INTEGER NOT NULL REFERENCES players(id) ON DELETE CASCADE,
        type VARCHAR(50) NOT NULL,
        value VARCHAR(255) NOT NULL,
        created_at TIMESTAMP DEFAULT NOW() NOT NULL,
        CONSTRAINT unique_identifier UNIQUE (type, value)
    );

    switcore.core.sections.database.tables.groups_permissions.title

    switcore.core.sections.database.tables.groups_permissions.description

    CREATE TABLE groups (
        id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        name VARCHAR(50) UNIQUE NOT NULL,
        display_name VARCHAR(100) NOT NULL,
        priority INTEGER DEFAULT 0 NOT NULL,
        description TEXT,
        created_at TIMESTAMP DEFAULT NOW() NOT NULL
    );
    
    CREATE TABLE permissions (
        id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        name VARCHAR(100) UNIQUE NOT NULL,
        description TEXT,
        created_at TIMESTAMP DEFAULT NOW() NOT NULL
    );
    
    CREATE TABLE player_groups (
        id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        player_id INTEGER NOT NULL REFERENCES players(id) ON DELETE CASCADE,
        group_id INTEGER NOT NULL REFERENCES groups(id) ON DELETE CASCADE,
        assigned_at TIMESTAMP DEFAULT NOW() NOT NULL,
        assigned_by INTEGER REFERENCES players(id),
        expires_at TIMESTAMP,
        CONSTRAINT unique_player_group UNIQUE (player_id, group_id)
    );

    switcore.core.sections.database.tables.player_activity_log.title

    switcore.core.sections.database.tables.player_activity_log.description

    CREATE TABLE player_activity_log (
        id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
        player_id INTEGER NOT NULL REFERENCES players(id) ON DELETE CASCADE,
        event_type VARCHAR(50) NOT NULL,
        command VARCHAR(255),
        metadata JSONB,
        created_at TIMESTAMP DEFAULT NOW() NOT NULL
    );

    switcore.core.sections.database.schemaIncluded

    switcore.core.sections.database.schemaNote

    📚 switcore.core.sections.api.title

    switcore.core.sections.api.playerManagement.title

    switcore.core.sections.api.playerManagement.methods.getPlayerId.name

    switcore.core.sections.api.playerManagement.methods.getPlayerId.description

    local dbId = exports.core:getPlayerId(source)
    if dbId then
        print('ID jucător: ' .. dbId)
    end

    switcore.core.sections.api.playerManagement.methods.getPlayerById.name

    switcore.core.sections.api.playerManagement.methods.getPlayerById.description

    local player = exports.core:getPlayerById(dbId)
    if player then
        print('Nume: ' .. player.name)
        print('Playtime: ' .. player.playtime .. ' secunde')
    end

    switcore.core.sections.api.playerManagement.methods.getPlayerData.name

    switcore.core.sections.api.playerManagement.methods.getPlayerData.description

    local player = exports.core:getPlayerData(source)
    if player then
        print('ID: ' .. player.dbId)
        print('Nume: ' .. player.name)
        print('Playtime: ' .. player.playtime)
        print('Identifiers: ' .. json.encode(player.identifiers))
    end

    switcore.core.sections.api.playerManagement.methods.getPlayerIdentifiers.name

    switcore.core.sections.api.playerManagement.methods.getPlayerIdentifiers.description

    local identifiers = exports.core:getPlayerIdentifiers(dbId)
    for _, identifier in ipairs(identifiers) do
        print('Identifier: ' .. identifier)
    end

    switcore.core.sections.api.playerManagement.methods.updatePlayerPlaytime.name

    switcore.core.sections.api.playerManagement.methods.updatePlayerPlaytime.description

    local success = exports.core:updatePlayerPlaytime(source, 3600) -- 1 oră
    if success then
        print('Playtime actualizat')
    end

    switcore.core.sections.api.playerManagement.methods.logPlayerActivity.name

    switcore.core.sections.api.playerManagement.methods.logPlayerActivity.description

    exports.core:logPlayerActivity(source, 'custom_event', {
        action = 'purchase',
        item = 'weapon_pistol',
        price = 500
    })

    switcore.core.sections.api.events.title

    switcore.core.sections.api.events.playerLoaded.name

    switcore.core.sections.api.events.playerLoaded.description

    AddEventHandler('switcore:playerLoaded', function(source, dbId, playerData)
        print('Jucător încărcat: ' .. playerData.name .. ' (ID: ' .. dbId .. ')')
        -- Aici poți face inițializări specifice jucătorului
    end)

    🔐 switcore.core.sections.api.permissions.title

    switcore.core.sections.api.permissions.verification.title

    switcore.core.sections.api.permissions.verification.methods.hasPermission.name

    switcore.core.sections.api.permissions.verification.methods.hasPermission.description

    if exports.core:hasPermission(source, 'admin.kick') then
        -- Jucătorul are permisiunea de a da kick
        KickPlayer(targetId, reason)
    else
        TriggerClientEvent('chat:addMessage', source, {
            color = {255, 0, 0},
            args = {'Sistem', 'Nu ai permisiunea necesară!'}
        })
    end

    Notă: switcore.core.sections.api.permissions.verification.methods.hasPermission.note

    switcore.core.sections.api.permissions.verification.methods.hasGroup.name

    switcore.core.sections.api.permissions.verification.methods.hasGroup.description

    if exports.core:hasGroup(source, 'admin') then
        -- Jucătorul este admin
    end

    switcore.core.sections.api.permissions.verification.methods.getPlayerPermissions.name

    switcore.core.sections.api.permissions.verification.methods.getPlayerPermissions.description

    local permissions = exports.core:getPlayerPermissions(source)
    for _, permission in ipairs(permissions) do
        print('Permisiune: ' .. permission)
    end

    switcore.core.sections.api.permissions.verification.methods.getPlayerGroups.name

    switcore.core.sections.api.permissions.verification.methods.getPlayerGroups.description

    local groups = exports.core:getPlayerGroups(source)
    for _, group in ipairs(groups) do
        print('Grup: ' .. group.name .. ' (Priority: ' .. group.priority .. ')')
    end

    switcore.core.sections.api.permissions.management.title

    switcore.core.sections.api.permissions.management.methods.addPlayerGroup.name

    switcore.core.sections.api.permissions.management.methods.addPlayerGroup.description

    -- Grup permanent
    exports.core:addPlayerGroup(source, 'vip')
    
    -- Grup temporar (expiră peste 7 zile)
    local expiresAt = os.time() + (7 * 24 * 60 * 60)
    exports.core:addPlayerGroup(source, 'vip', expiresAt, adminSource)

    switcore.core.sections.api.permissions.management.methods.removePlayerGroup.name

    switcore.core.sections.api.permissions.management.methods.removePlayerGroup.description

    exports.core:removePlayerGroup(source, 'vip')

    switcore.core.sections.api.permissions.management.methods.createGroup.name

    switcore.core.sections.api.permissions.management.methods.createGroup.description

    exports.core:createGroup('helper', 'Helper', 25, 'Grup pentru helpers')

    switcore.core.sections.api.permissions.management.methods.getAllGroups.name

    switcore.core.sections.api.permissions.management.methods.getAllGroups.description

    local groups = exports.core:getAllGroups()
    for _, group in ipairs(groups) do
        print('Grup: ' .. group.display_name .. ' (' .. group.name .. ')')
    end

    switcore.core.sections.api.permissions.management.methods.reloadPlayerPermissions.name

    switcore.core.sections.api.permissions.management.methods.reloadPlayerPermissions.description

    -- Util după ce ai modificat grupuri/permisiuni
    exports.core:reloadPlayerPermissions(source)

    💻 switcore.core.sections.api.examples.title

    switcore.core.sections.api.examples.commandWithPermission.title

    RegisterCommand('kick', function(source, args)
        if not exports.core:hasPermission(source, 'admin.kick') then
            TriggerClientEvent('chat:addMessage', source, {
                color = {255, 0, 0},
                args = {'Sistem', 'Nu ai permisiunea necesară!'}
            })
            return
        end
        
        local targetId = tonumber(args[1])
        local reason = table.concat(args, ' ', 2) or 'Fără motiv'
        
        if targetId then
            DropPlayer(targetId, 'Ai fost dat afară: ' .. reason)
            TriggerClientEvent('chat:addMessage', -1, {
                color = {255, 165, 0},
                args = {'Sistem', 'Jucătorul ' .. GetPlayerName(targetId) .. ' a fost dat afară: ' .. reason}
            })
        end
    end, false)

    switcore.core.sections.api.examples.playtimeRewards.title

    AddEventHandler('switcore:playerLoaded', function(source, dbId, playerData)
        local playtimeHours = math.floor(playerData.playtime / 3600)
        
        -- Recompensă pentru 10 ore
        if playtimeHours >= 10 and not exports.core:hasGroup(source, 'veteran') then
            exports.core:addPlayerGroup(source, 'veteran')
            TriggerClientEvent('chat:addMessage', source, {
                color = {0, 255, 0},
                args = {'Sistem', 'Felicitări! Ai primit grupul Veteran pentru ' .. playtimeHours .. ' ore de joc!'}
            })
        end
    end)

    switcore.core.sections.api.examples.temporaryGroup.title

    RegisterCommand('givevip', function(source, args)
        if not exports.core:hasPermission(source, 'admin.groups') then
            return
        end
        
        local targetId = tonumber(args[1])
        local days = tonumber(args[2]) or 7
        
        if targetId then
            local expiresAt = os.time() + (days * 24 * 60 * 60)
            local success = exports.core:addPlayerGroup(targetId, 'vip', expiresAt, source)
            
            if success then
                TriggerClientEvent('chat:addMessage', source, {
                    color = {0, 255, 0},
                    args = {'Sistem', 'Grup VIP adăugat pentru ' .. days .. ' zile!'}
                })
            end
        end
    end, false)