The-Programmer Forum

AltisLifeDev a écrit le dernier message :
#5
Got it working with this update :
fn_banplayer.sqf:
Développer Réduire Copier
/*
    File: fn_banplayer.sqf
    Description:
    Bans a player and logs the event to the database.

    Parameters:
        0: OBJECT (Player to be banned)
        1: STRING (Reason for the ban)
*/

// Validate parameters
params ["_cheater", "_banReason"];
if (!isPlayer _cheater) exitWith {};
if (isNil "_banReason") then { _banReason = "No reason provided"; };

_cheatID = getPlayerUID _cheater;
_cheaterName = name _cheater;

format['#exec ban "%1"', _cheatID] call TON_fnc_sendCommand;

diag_log format ["Player: %1 (UID: %2) has been banned for: %3", _cheaterName, _cheatID, _banReason];
private _query = format [ // Prepare SQL query
    "INSERT INTO ban_log (cheater_name, cheater_uid, ban_reason) VALUES ('%1', '%2', '%3')",
    _cheaterName, _cheatID, _banReason
];
[_query, 1, false] call DB_fnc_asyncCall;