It’s the very beginning of the idea: a mix between Hunger Games and Battle Royal inside a limited zone:
Client:
centerZone = {-894.991, 4820.33, 0.635}
weaponPlaced = false
x = 1
local maxTimerCount = 0
local newTimerTick = true
startCoords = {
{-887.754, 4808.6001, 301.719},
{-899.4501, 4795.47, 302.164},
{-912.142, 4798.32, 304.263},
{-927.669, 4808.37, 308.387},
{-937.618, 4821.66, 310.792},
{-947.295, 4841.00001, 312.859},
{-930.011, 4854.23, 309.717},
{-910.177, 4850.34, 30.569},
{-891.45, 4849.11, 301.881},
{-871.776, 4852.59, 295.675},
{-885.558, 4854.29, 293.803},
{-844.075, 4841.63, 296.5},
{-838.079, 4823.21, 295.012},
{-841.344, 4799.51, 297.968},
{-870.867, 4785.86, 300.176},
{-901.063, 4780.73, 298.851},
{-902.648, 4811.57, 303.749}
}
-- blip courone: 437, cible avec mec dedans: 458,
weaponCoords = { --blip 110 (pistolet) ou, 313 (arme dans cible) ou, 408 (attaché case),
{-1137.32, 4873.58, 215.169},
{-1112.26, 4897.08, 214.364},
{-1062.24, 4966.88, 213.215},
{-1170.51, 4926.65, 224.327},
{-1002.78, 4857.37, 274.606},
{-826.116, 5174.91, 107.886},
{-481.692, 4917.72, 146.825},
{-537.135, 4507.65, 79.9888},
{-740.425, 4435.74, 16.5733},
{-1142.47, 4388.8, 21.2187},
{-1290.21, 4497.25, 14.6273},
{-902.648, 4811.57, 303.749}
}
weaponsList = {"WEAPON_KNIFE", "WEAPON_GOLFCLUB", "WEAPON_CROWBAR", "WEAPON_PISTOL", "WEAPON_SMG", "WEAPON_ASSAULTSMG"," WEAPON_MG", "WEAPON_PUMPSHOTGUN", "WEAPON_STUNGUN", "WEAPON_SNIPERRIFLE","WEAPON_GRENADELAUNCHER","WEAPON_GRENADELAUNCHER_SMOKE","WEAPON_RPG","WEAPON_MINIGUN","WEAPON_GRENADE","WEAPON_STICKYBOMB","WEAPON_SMOKEGRENADE","WEAPON_BZGAS","WEAPON_MOLOTOV","WEAPON_FIREEXTINGUISHER","WEAPON_BRIEFCASE","WEAPON_FLARE","WEAPON_BARBED_WIRE","WEAPON_BOTTLE","WEAPON_GUSENBERG","WEAPON_SPECIALCARBINE","WEAPON_HEAVYPISTOL","WEAPON_SNSPISTOL","WEAPON_BULLPUPRIFLE","WEAPON_DAGGER","WEAPON_VINTAGEPISTOL","WEAPON_FIREWORK","WEAPON_MUSKET","WEAPON_HEAVYSHOTGUN","WEAPON_MARKSMANRIFLE","WEAPON_HOMINGLAUNCHER","WEAPON_PROXMINE","WEAPON_SNOWBALL","WEAPON_FLAREGUN","WEAPON_GARBAGEBAG","WEAPON_COMBATPDW","WEAPON_MARKSMANPISTOL","WEAPON_KNUCKLE"}
local function EndScreen(text, type)
Citizen.CreateThread(function()
-- while true do
Citizen.Wait(100)
if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), -921.1211, 4828.44, 1.635, false) > 500.981 then
StartScreenEffect(type, 0, 0)
PlaySoundFrontend(-1, "Bed", "WastedSounds", 1)
local scaleform = RequestScaleformMovie("MP_BIG_MESSAGE_FREEMODE")
if HasScaleformMovieLoaded(scaleform) then
Citizen.Wait(0)
PushScaleformMovieFunction(scaleform, "SHOW_SHARD_WASTED_MP_MESSAGE")
BeginTextComponent("STRING")
AddTextComponentString(text)
EndTextComponent()
PopScaleformMovieFunctionVoid()
--Citizen.Wait(500)
PlaySoundFrontend(-1, "TextHit", "WastedSounds", 1)
while GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), -921.1211, 4828.44, 1.635, false) > 500.981 do
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
Citizen.Wait(0)
end
--Citizen.Wait(1000)
end
else
StopScreenEffect(type)
end
--end
end)
end
local function GiveAWeapon()
Citizen.CreateThread(function()
Citizen.Wait(0)
RemoveAllPedWeapons(GetPlayerPed(-1), true)
weaponNum = GetRandomIntInRange(1, #weaponsList)
givenWeapon = weaponsList[weaponNum]
weaponHash = GetHashKey(givenWeapon)
GiveWeaponToPed(GetPlayerPed(-1), weaponHash, 10, 0, true)
TriggerEvent('chatMessage', '', { 0, 0, 0 }, 'Arme donnée: '..givenWeapon)
end)
end
RegisterNetEvent('br:placeWeapon')
AddEventHandler('br:placeWeapon', function()
Citizen.CreateThread(function()
Citizen.Wait(0)
while not weaponPlaced do -- Récuperer distance entre coordonnée et player puis nil la valeur dans la table, envoyer l'info au serveur qu'il l'a renvoie a tous les autres joueurs
--TriggerEvent('chatMessage', '', { 0, 0, 0 }, 'Préparation armes')
-- RemoveAllPedWeapons(GetPlayerPed(-1), true)
weaponPlace = weaponCoords[x]
--weaponNum = GetRandomIntInRange(1, #weaponsList)
givenWeapon = weaponsList[GetRandomIntInRange(1, #weaponsList)]
--while not HasModelLoaded(GetHashKey(givenWeapon)) do
-- Citizen.Wait(0)
--end
weaponHash = GetHashKey(givenWeapon)
weapon = CreatePickupRotate(weaponHash, weaponPlace[1], weaponPlace[2], weaponPlace[3], 0.0, 0.0, 0.0, 8, 1.0, 24, 24, true, weaponHash)
--CreateWeaponObject(weaponHash, 10, weaponPlace[1], weaponPlace[2], weaponPlace[3], true, 220.20, 1)
SetEntityDynamic(weapon, true)
SetEntityRecordsCollisions(weapon, true)
SetEntityHasGravity(weapon, true)
FreezeEntityPosition(weapon, false)
SetEntityVelocity(weapon, 0.0, 0.0, -0.2)
TriggerEvent('chatMessage', '', { 0, 0, 0 }, 'Arme donnée '..x..' : '..givenWeapon)
x = x + 1
if x == #weaponCoords then
weaponPlaced = true
end
end
end)
end)
Citizen.CreateThread(function()
while true do
Wait(0)
if NetworkIsSessionStarted() then
TriggerServerEvent('br:firstJoin')
return
end
end
end)
Citizen.CreateThread(function()
while true do
local playerPos = GetEntityCoords(GetPlayerPed(-1))
local distance = Vdist(playerPos.x, playerPos.y, playerPos.z, -921.1211, 4828.44, 1.635)
Citizen.Wait(1)
DrawMarker(1, -921.1211, 4828.44, 1.635, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1000.0, 1000.0, 1000.0, 255, 0, 0, 75, 0, 0, 2, 0, 0, 0, 0)
if distance > 500.981 then
Wait(100)
EndScreen("You have 10 seconds to come back", "DeathFailOut")
timer = GetGameTimer()
if distance > 500.981 then
if (newTimerTick) then
maxTimerCount = GetGameTimer() + 10000
newTimerTick = false
end
if GetGameTimer() > maxTimerCount then
SetEntityHealth(GetPlayerPed(-1), 0)
newTimerTick = true
end
end
Wait(10000)
end
if distance < 500.981 then
StopScreenEffect("DeathFailOut")
end
if IsPedFatallyInjured(PlayerPedId()) then
Wait(2500)
GiveAWeapon()
end
for i = 1, #weaponCoords do
weaponPos = weaponCoords[i]
if Vdist(playerPos.x, playerPos.y, playerPos.z, weaponPos[1], weaponPos[2], weaponPos[3]) > 2 then
DrawMarker(1, weaponPos[1], weaponPos[2], weaponPos[3] - 10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 300.0, 255, 255, 0, 75, 0, 0, 2, 0, 0, 0, 0)
end
end
end
end)
--[[RegisterNetEvent('br:setBlip')
AddEventHandler('br:setBlip', function()
zoneBlip = AddBlipForCoord(-921.1211, 4828.44, 150.635)
SetBlipScale(zoneBlip, 100)
SetBlipSprite(zoneBlip, 4)
SetBlipColour(zoneBlip, 1)
SetBlipAlpha(zoneBlip, 64)
SetBlipAsShortRange(zoneBlip, true)
end)]]
RegisterNetEvent('br:giveWeapon')
AddEventHandler('br:giveWeapon', function()
GiveAWeapon()
end)
Server:
local list = {}
playerCount = 0
battleInProgress = false
RegisterServerEvent('br:firstJoin')
AddEventHandler('br:firstJoin', function()
TriggerClientEvent('br:placeWeapon', source)
if not list[source] then
playerCount = playerCount + 1
list[source] = true
print("nombre de joueur: "..#list)
end
-- TriggerClientEvent('br:setBlip', source)
end)
I test it alone, but in future, I will not let other player than the first in a player list to place weapons on map (and placing weapons don’t work too)