Hello, sorry for my bad english.
I’m not a good developer but I’m trying to learn.
I’m making a callout script for the police on my server. For example the fact of creating a fight of NPC and that they receive a notification. The problem is that the peds spawn by the number of players.
client.lua
RegisterNetEvent('fight:spawn')
AddEventHandler('fight:spawn', function()
positionfight = vector3(-382.4282, 110.4835, 65.7580),
SetEntityAsMissionEntity(fighter1)
DeleteEntity(fighter1)
SetEntityAsMissionEntity(fighter2)
DeleteEntity(fighter2)
fighter1Model = "a_m_m_salton_04"
fighter1ModelHash = GetHashKey(fighter1Model)
RequestModel(fighter1ModelHash)
fighter2Model = "a_m_m_hillbilly_01",
fighter2ModelHash = GetHashKey(fighter2Model)
RequestModel(fighter2ModelHash)
while not HasModelLoaded(fighter2ModelHash) and not HasModelLoaded(fighter1ModelHash) do
Wait(1)
end
Wait(1000)
fighter1 = CreatePed(26, fighter1Model, -382.4282, 110.4835, 65.7580, 45.0, true, true)
fighter2 = CreatePed(26, fighter2Model, -382.4282-1, 110.4835-1, 65.7580, 45.0, true, true)
end)
RegisterNetEvent('fight')
AddEventHandler('fight', function()
hashStreet = GetStreetNameAtCoord(-382.4282, 110.4835, 65.7580)
location = GetStreetNameFromHashKey(hashStreet)
callout = "~r~Bagarre~w~"
gps = vector2(-382.4282, 110.4835)
AddRelationshipGroup("fighter1")
AddRelationshipGroup("fighter2")
SetPedCombatAttributes(fighter1, 5, true)
SetPedCombatAttributes(fighter2, 5, true)
SetPedCombatAbility(fighter1, 100)
SetPedCombatAbility(fighter2, 100)
SetRelationshipBetweenGroups(5, GetHashKey("fighter1"), GetHashKey("fighter2"))
SetRelationshipBetweenGroups(5, GetHashKey("fighter1"), GetHashKey("PLAYER"))
SetRelationshipBetweenGroups(5, GetHashKey("fighter2"), GetHashKey("PLAYER"))
SetRelationshipBetweenGroups(5, GetHashKey("fighter2"), GetHashKey("fighter1"))
SetPedRelationshipGroupHash(fighter1, GetHashKey("fighter1"))
SetPedRelationshipGroupHash(fighter2, GetHashKey("fighter2"))
SetEntityCanBeDamagedByRelationshipGroup(fighter1, false, GetHashKey("fighter2"))
SetEntityCanBeDamagedByRelationshipGroup(fighter2, false, GetHashKey("fighter1"))
TaskCombatHatedTargetsAroundPed(fighter1, 10.0, 0)
TaskCombatHatedTargetsAroundPed(fighter2, 10.0, 0)
SetGPS()
end)
function SetGPS()
while true do
Citizen.Wait(1)
if IsControlJustPressed(0,246) then
SetNewWaypoint(gps)
end
end
end
server.lua who launches my callouts
Citizen.CreateThread(function()
local randomEventMinTime = 1500
local randomEventMaxTime = 1800
while true do
--calloutEvent = math.random(1,6)
calloutEvent = 1
randomEventWaitTime = math.random(randomEventMinTime,randomEventMaxTime) * 1000
Citizen.Wait(randomEventWaitTime)
CancelEvent()
if calloutEvent == 1 then
TriggerClientEvent('fight:spawn', -1)
Wait(2000)
TriggerClientEvent('fight', -1)
elseif calloutEvent == 2 then
end
TriggerClientEvent('pis:notification', -1)
end
end)
I think I know it’s throwing the event on all clients, but I don’t know how to fix it. Help me