From 27445f17781394aa1f396c6dda8beac141a1d58b Mon Sep 17 00:00:00 2001 From: tanthius Date: Thu, 12 Feb 2026 11:57:32 +0000 Subject: [PATCH] Upload files to "server" --- server/appearance.lua | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/server/appearance.lua b/server/appearance.lua index ff18085..89a5183 100644 --- a/server/appearance.lua +++ b/server/appearance.lua @@ -34,7 +34,10 @@ RegisterNetEvent("turfwar:appearance:request", function() { license } ) + local isNew = false + if not row then + isNew = true local def = defaultRow(license) exports.oxmysql:insertSync( "INSERT INTO turfwar_appearance (license, gender, hair_drawable, hair_texture, hair_color, hair_highlight) VALUES (?, ?, ?, ?, ?, ?)", @@ -43,6 +46,50 @@ RegisterNetEvent("turfwar:appearance:request", function() row = def end + row.isNew = isNew + TriggerClientEvent("turfwar:appearance:update", src, row) +end) + +RegisterNetEvent("turfwar:appearance:setGender", function(gender) + local src = source + local license = getLicense(src) + if not license then return end + + gender = (gender == "f") and "f" or "m" + + exports.oxmysql:updateSync( + "UPDATE turfwar_appearance SET gender = ? WHERE license = ?", + { gender, license } + ) + + local row = exports.oxmysql:singleSync( + "SELECT gender, hair_drawable, hair_texture, hair_color, hair_highlight FROM turfwar_appearance WHERE license = ?", + { license } + ) + row.isNew = false + TriggerClientEvent("turfwar:appearance:update", src, row) +end) + +RegisterNetEvent("turfwar:appearance:setHair", function(drawable, texture, color, highlight) + local src = source + local license = getLicense(src) + if not license then return end + + drawable = tonumber(drawable) or 0 + texture = tonumber(texture) or 0 + color = tonumber(color) or 0 + highlight = tonumber(highlight) or color + + exports.oxmysql:updateSync( + "UPDATE turfwar_appearance SET hair_drawable=?, hair_texture=?, hair_color=?, hair_highlight=? WHERE license=?", + { drawable, texture, color, highlight, license } + ) + + local row = exports.oxmysql:singleSync( + "SELECT gender, hair_drawable, hair_texture, hair_color, hair_highlight FROM turfwar_appearance WHERE license = ?", + { license } + ) + row.isNew = false TriggerClientEvent("turfwar:appearance:update", src, row) end)