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

🎨 Run formatter #635

Merged
merged 2 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 73 additions & 79 deletions server-data/resources/[bpt_addons]/bpt_streetfight/client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ local winner = nil
ESX = exports["es_extended"]:getSharedObject()

CreateThread(function()
CreateBlip(Config.BLIP.coords, Config.BLIP.text, Config.BLIP.sprite, Config.BLIP.color, Config.BLIP.scale)
RunThread()
CreateBlip(Config.BLIP.coords, Config.BLIP.text, Config.BLIP.sprite, Config.BLIP.color, Config.BLIP.scale)
RunThread()
end)

RegisterNetEvent('bpt_streetfight:playerJoined')
AddEventHandler('bpt_streetfight:playerJoined', function(side, id)

RegisterNetEvent("bpt_streetfight:playerJoined")
AddEventHandler("bpt_streetfight:playerJoined", function(side, id)
if side == 1 then
blueJoined = true
else
Expand All @@ -35,14 +34,12 @@ AddEventHandler('bpt_streetfight:playerJoined', function(side, id)
end
players = players + 1
fightStatus = STATUS_JOINED

end)

RegisterNetEvent('bpt_streetfight:startFight')
AddEventHandler('bpt_streetfight:startFight', function(fightData)

for _,value in ipairs(fightData) do
if(value.id ~= GetPlayerServerId(PlayerId())) then
RegisterNetEvent("bpt_streetfight:startFight")
AddEventHandler("bpt_streetfight:startFight", function(fightData)
for _, value in ipairs(fightData) do
if value.id ~= GetPlayerServerId(PlayerId()) then
rival = value.id
elseif value.id == GetPlayerServerId(PlayerId()) then
participating = true
Expand All @@ -52,49 +49,45 @@ AddEventHandler('bpt_streetfight:startFight', function(fightData)
fightStatus = STATUS_STARTED
showCountDown = true
countdown()

end)

RegisterNetEvent('bpt_streetfight:playerLeaveFight')
AddEventHandler('bpt_streetfight:playerLeaveFight', function(id)

RegisterNetEvent("bpt_streetfight:playerLeaveFight")
AddEventHandler("bpt_streetfight:playerLeaveFight", function(id)
if id == GetPlayerServerId(PlayerId()) then
ESX.ShowNotification(_U('you_toofar'))
ESX.ShowNotification(_U("you_toofar"))
SetPedMaxHealth(PlayerPedId(), 200)
SetEntityHealth(PlayerPedId(), 200)
removeGloves()
elseif participating == true then
TriggerServerEvent('bpt_streetfight:pay', betAmount)
ESX.ShowNotification(_U('you_win') .. (betAmount * 2) .. '$')
TriggerServerEvent("bpt_streetfight:pay", betAmount)
ESX.ShowNotification(_U("you_win") .. (betAmount * 2) .. "$")
SetPedMaxHealth(PlayerPedId(), 200)
SetEntityHealth(PlayerPedId(), 200)
removeGloves()
end
reset()

end)

RegisterNetEvent('bpt_streetfight:fightFinished')
AddEventHandler('bpt_streetfight:fightFinished', function(looser)

RegisterNetEvent("bpt_streetfight:fightFinished")
AddEventHandler("bpt_streetfight:fightFinished", function(looser)
if participating == true then
if(looser ~= GetPlayerServerId(PlayerId()) and looser ~= -2) then
TriggerServerEvent('bpt_streetfight:pay', betAmount)
ESX.ShowNotification(_U('you_win') .. (betAmount * 2) .. '$')
if looser ~= GetPlayerServerId(PlayerId()) and looser ~= -2 then
TriggerServerEvent("bpt_streetfight:pay", betAmount)
ESX.ShowNotification(_U("you_win") .. (betAmount * 2) .. "$")
SetPedMaxHealth(PlayerPedId(), 200)
SetEntityHealth(PlayerPedId(), 200)

TriggerServerEvent('bpt_streetfight:showWinner', GetPlayerServerId(PlayerId()))
TriggerServerEvent("bpt_streetfight:showWinner", GetPlayerServerId(PlayerId()))
end

if(looser == GetPlayerServerId(PlayerId()) and looser ~= -2) then
ESX.ShowNotification(_U('you_lost') .. betAmount .. '$' )
if looser == GetPlayerServerId(PlayerId()) and looser ~= -2 then
ESX.ShowNotification(_U("you_lost") .. betAmount .. "$")
SetPedMaxHealth(PlayerPedId(), 200)
SetEntityHealth(PlayerPedId(), 200)
end

if looser == -2 then
ESX.ShowNotification(_U('time_out'))
ESX.ShowNotification(_U("time_out"))
SetPedMaxHealth(PlayerPedId(), 200)
SetEntityHealth(PlayerPedId(), 200)
end
Expand All @@ -104,8 +97,8 @@ AddEventHandler('bpt_streetfight:fightFinished', function(looser)
reset()
end)

RegisterNetEvent('bpt_streetfight:raiseActualBet')
AddEventHandler('bpt_streetfight:raiseActualBet', function()
RegisterNetEvent("bpt_streetfight:raiseActualBet")
AddEventHandler("bpt_streetfight:raiseActualBet", function()
betAmount = betAmount * 2
if betAmount == 0 then
betAmount = 2000
Expand All @@ -114,8 +107,8 @@ AddEventHandler('bpt_streetfight:raiseActualBet', function()
end
end)

RegisterNetEvent('bpt_streetfight:winnerText')
AddEventHandler('bpt_streetfight:winnerText', function(id)
RegisterNetEvent("bpt_streetfight:winnerText")
AddEventHandler("bpt_streetfight:winnerText", function(id)
showWinner = true
winner = id
Wait(5000)
Expand All @@ -140,70 +133,71 @@ end

function putGloves()
local ped = GetPlayerPed(-1)
local hash = GetHashKey('prop_boxing_glove_01')
while not HasModelLoaded(hash) do RequestModel(hash);
Wait(0);
local hash = GetHashKey("prop_boxing_glove_01")
while not HasModelLoaded(hash) do
RequestModel(hash)
Wait(0)
end
local pos = GetEntityCoords(ped)
local gloveA = CreateObject(hash, pos.x,pos.y,pos.z + 0.50, true,false,false)
local gloveB = CreateObject(hash, pos.x,pos.y,pos.z + 0.50, true,false,false)
table.insert(Gloves,gloveA)
table.insert(Gloves,gloveB)
local gloveA = CreateObject(hash, pos.x, pos.y, pos.z + 0.50, true, false, false)
local gloveB = CreateObject(hash, pos.x, pos.y, pos.z + 0.50, true, false, false)
table.insert(Gloves, gloveA)
table.insert(Gloves, gloveB)
SetModelAsNoLongerNeeded(hash)
FreezeEntityPosition(gloveA,false)
SetEntityCollision(gloveA,false,true)
FreezeEntityPosition(gloveA, false)
SetEntityCollision(gloveA, false, true)
ActivatePhysics(gloveA)
FreezeEntityPosition(gloveB,false)
SetEntityCollision(gloveB,false,true)
FreezeEntityPosition(gloveB, false)
SetEntityCollision(gloveB, false, true)
ActivatePhysics(gloveB)
if not ped then ped = GetPlayerPed(-1); end -- gloveA = L, gloveB = R
AttachEntityToEntity(gloveA, ped, GetPedBoneIndex(ped, 0xEE4F), 0.05, 0.00, 0.04, 00.0, 90.0, -90.0, true, true, false, true, 1, true) -- object is attached to right hand
AttachEntityToEntity(gloveB, ped, GetPedBoneIndex(ped, 0xAB22), 0.05, 0.00, -0.04, 00.0, 90.0, 90.0, true, true, false, true, 1, true) -- object is attached to right hand
if not ped then
ped = GetPlayerPed(-1)
end -- gloveA = L, gloveB = R
AttachEntityToEntity(gloveA, ped, GetPedBoneIndex(ped, 0xEE4F), 0.05, 0.00, 0.04, 00.0, 90.0, -90.0, true, true, false, true, 1, true) -- object is attached to right hand
AttachEntityToEntity(gloveB, ped, GetPedBoneIndex(ped, 0xAB22), 0.05, 0.00, -0.04, 00.0, 90.0, 90.0, true, true, false, true, 1, true) -- object is attached to right hand
end

function removeGloves()
for _, v in pairs(Gloves)
do DeleteObject(v);
for _, v in pairs(Gloves) do
DeleteObject(v)
end
end

function spawnMarker(coords)
local centerRing = GetDistanceBetweenCoords(coords, vector3(-517.61,-1712.04,20.46), true)
local centerRing = GetDistanceBetweenCoords(coords, vector3(-517.61, -1712.04, 20.46), true)
if centerRing < Config.DISTANCE and fightStatus ~= STATUS_STARTED then

DrawMarker(1, Config.BETZONE.x, Config.BETZONE.y, Config.BETZONE.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 1.5, 1.5, 1.0, 204,204, 0, 100, false, true, 2, false, false, false, false)
DrawText3D(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z +1.5, 'Giocatori: ~r~' .. players .. '/2 \n ~w~Scommessa: ~r~'.. betAmount ..'$ ', 0.8)
DrawMarker(1, Config.BETZONE.x, Config.BETZONE.y, Config.BETZONE.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 1.5, 1.5, 1.0, 204, 204, 0, 100, false, true, 2, false, false, false, false)
DrawText3D(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z + 1.5, "Giocatori: ~r~" .. players .. "/2 \n ~w~Scommessa: ~r~" .. betAmount .. "$ ", 0.8)
local blueZone = GetDistanceBetweenCoords(coords, vector3(Config.BLUEZONE.x, Config.BLUEZONE.y, Config.BLUEZONE.z), true)
local redZone = GetDistanceBetweenCoords(coords, vector3(Config.REDZONE.x, Config.REDZONE.y, Config.REDZONE.z), true)
local betZone = GetDistanceBetweenCoords(coords, vector3(Config.BETZONE.x, Config.BETZONE.y, Config.BETZONE.z), true)

if blueJoined == false then
DrawText3D(Config.BLUEZONE.x, Config.BLUEZONE.y, Config.BLUEZONE.z +1.5, 'unisciti alla lotta [~b~E~w~]', 0.4)
DrawText3D(Config.BLUEZONE.x, Config.BLUEZONE.y, Config.BLUEZONE.z + 1.5, "unisciti alla lotta [~b~E~w~]", 0.4)
if blueZone < Config.DISTANCE_INTERACTION then
ESX.ShowHelpNotification(_U('press_to_join_blue'))
ESX.ShowHelpNotification(_U("press_to_join_blue"))
if IsControlJustReleased(0, Config.E_KEY) and participating == false then
TriggerServerEvent('bpt_streetfight:join', betAmount, 0 )
TriggerServerEvent("bpt_streetfight:join", betAmount, 0)
end
end
end

if redJoined == false then
DrawText3D(Config.REDZONE.x, Config.REDZONE.y, Config.REDZONE.z +1.5, 'unisciti alla lotta [~r~E~w~]', 0.4)
DrawText3D(Config.REDZONE.x, Config.REDZONE.y, Config.REDZONE.z + 1.5, "unisciti alla lotta [~r~E~w~]", 0.4)
if redZone < Config.DISTANCE_INTERACTION then
ESX.ShowHelpNotification(_U('press_to_join_red'))
ESX.ShowHelpNotification(_U("press_to_join_red"))
if IsControlJustReleased(0, Config.E_KEY) and participating == false then
TriggerServerEvent('bpt_streetfight:join', betAmount, 1)
TriggerServerEvent("bpt_streetfight:join", betAmount, 1)
end
end
end

if betZone < Config.DISTANCE_INTERACTION and fightStatus ~= STATUS_JOINED and fightStatus ~= STATUS_STARTED then
ESX.ShowHelpNotification("premi ~INPUT_CONTEXT~ per cambiare la scommessa.")
if IsControlJustReleased(0, Config.E_KEY) then
TriggerServerEvent('bpt_streetfight:raiseBet', betAmount)
TriggerServerEvent("bpt_streetfight:raiseBet", betAmount)
end
end

end
end

Expand All @@ -228,14 +222,14 @@ function DrawText3D(x, y, z, text, scale)
end

function CreateBlip(coords, text, sprite, color, scale)
local blip = AddBlipForCoord(coords.x, coords.y)
SetBlipSprite(blip, sprite)
SetBlipScale(blip, scale)
SetBlipColour(blip, color)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName('STRING')
AddTextComponentSubstringPlayerName(text)
EndTextCommandSetBlipName(blip)
local blip = AddBlipForCoord(coords.x, coords.y)
SetBlipSprite(blip, sprite)
SetBlipScale(blip, scale)
SetBlipColour(blip, color)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentSubstringPlayerName(text)
EndTextCommandSetBlipName(blip)
end

function reset()
Expand All @@ -261,8 +255,8 @@ CreateThread(function()
while true do
if fightStatus == STATUS_STARTED and participating == false and GetEntityCoords(PlayerPedId()) ~= rival then
local coords = GetEntityCoords(GetPlayerPed(-1))
if get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z,coords.x,coords.y,coords.z) < Config.TP_DISTANCE then
ESX.ShowNotification(_U('step_away'))
if get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z, coords.x, coords.y, coords.z) < Config.TP_DISTANCE then
ESX.ShowNotification(_U("step_away"))
for _ = 1, 1000 do
SetPedCoordsKeepVehicle(GetPlayerPed(-1), -521.58, -1723.58, 19.16)
local foundGround = GetGroundZFor_3dCoord(-521.58, -1723.58, 19.16)
Expand All @@ -275,34 +269,34 @@ CreateThread(function()
end
end
Wait(1000)
end
end
end)

-- Main 0 loop
CreateThread(function()
while true do
Wait(0)
if showCountDown == true then
DrawText3D(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z + 1.5, 'La lotta inizia in: ' .. actualCount, 2.0)
DrawText3D(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z + 1.5, "La lotta inizia in: " .. actualCount, 2.0)
elseif showCountDown == false and fightStatus == STATUS_STARTED then
if GetEntityHealth(PlayerPedId()) < 150 then
TriggerServerEvent('bpt_streetfight:finishFight', GetPlayerServerId(PlayerId()))
TriggerServerEvent("bpt_streetfight:finishFight", GetPlayerServerId(PlayerId()))
fightStatus = STATUS_INITIAL
end
end

if participating == true then
local coords = GetEntityCoords(GetPlayerPed(-1))
if get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z,coords.x,coords.y,coords.z) > Config.LEAVE_FIGHT_DISTANCE then
TriggerServerEvent('bpt_streetfight:leaveFight', GetPlayerServerId(PlayerId()))
if get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z, coords.x, coords.y, coords.z) > Config.LEAVE_FIGHT_DISTANCE then
TriggerServerEvent("bpt_streetfight:leaveFight", GetPlayerServerId(PlayerId()))
end
end

if showWinner == true and winner ~= nil then
local coords = GetEntityCoords(GetPlayerPed(-1))
if get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z,coords.x,coords.y,coords.z) < 15 then
DrawText3D(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z + 2.5, '~r~ID: ' .. winner .. ' gana!', 2.0)
if get3DDistance(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z, coords.x, coords.y, coords.z) < 15 then
DrawText3D(Config.CENTER.x, Config.CENTER.y, Config.CENTER.z + 2.5, "~r~ID: " .. winner .. " gana!", 2.0)
end
end
end
end)
end)
20 changes: 10 additions & 10 deletions server-data/resources/[bpt_addons]/bpt_streetfight/config.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Config = {}

Config.BLUEZONE = {x = -520.63, y = -1712.40, z = 19.45}
Config.REDZONE = {x = -514.79, y = -1711.49, z = 19.45}
Config.CENTER = {x = -517.61, y = -1712.04, z = 20.45}
Config.BETZONE = {x = -523.33, y = -1715.44, z = 18.32}
Config.BLUEZONE = { x = -520.63, y = -1712.40, z = 19.45 }
Config.REDZONE = { x = -514.79, y = -1711.49, z = 19.45 }
Config.CENTER = { x = -517.61, y = -1712.04, z = 20.45 }
Config.BETZONE = { x = -523.33, y = -1715.44, z = 18.32 }
Config.DISTANCE = 10 -- Distance to see fight indicators
Config.TP_DISTANCE = 6 -- Minimum distance between fight and spectators
Config.LEAVE_FIGHT_DISTANCE = 15 -- Distance to quit fight
Config.DISTANCE_INTERACTION = 2.0 -- Interaction for fighter events
Config.E_KEY = 38 -- Action key 'E' default
Config.Locale = 'en'
Config.Locale = "en"

Config.BLIP = {
coords = {x = -517.61, y = -1712.04, z = 20.45},
text = _U('street_fighting'),
coords = { x = -517.61, y = -1712.04, z = 20.45 },
text = _U("street_fighting"),
sprite = 491,
color = 1,
scale = 1.0
}
color = 1,
scale = 1.0,
}
38 changes: 19 additions & 19 deletions server-data/resources/[bpt_addons]/bpt_streetfight/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
fx_version 'adamant'
fx_version("adamant")

game 'gta5'
game("gta5")

description 'bpt_streetfight'
description("bpt_streetfight")

version '1.0.0'
version("1.0.0")

server_script {
'@es_extended/locale.lua',
'server/server.lua',
'locales/*.lua',
'config.lua'
}
server_script({
"@es_extended/locale.lua",
"server/server.lua",
"locales/*.lua",
"config.lua",
})

client_script {
'@es_extended/locale.lua',
'client/client.lua',
'locales/*.lua',
'config.lua'
}
client_script({
"@es_extended/locale.lua",
"client/client.lua",
"locales/*.lua",
"config.lua",
})

dependencies {
'es_extended'
}
dependencies({
"es_extended",
})
Loading
Loading