Hello all, I’ve been trying to spawn ped in my one sync server and for some reason it is not spawning at all, even on my local host which is not one sync. Any help would be great on why this is not working.
Client.LUA
local sceneguards = {}
local pedCop = "s_m_y_hwaycop_01"
local crimeReference = ""
Citizen.CreateThread(function()
TriggerEvent('chat:addSuggestion', '/sceneguard', 'Places a Scene Guard'){
{name = "Crime ID: ", help = "Provide a FMS Crime ID If Possible"}
}
end)
-- Make MP Compatable -// Server Event > Client Event > Function
RegisterCommand('sceneguard', function(source, args, rawCommand)
local ped = GetPlayerPed(-1)
local PC = GetEntityCoords(ped)
local PH = GetEntityHeading(ped)
TriggerServerEvent("SG_SV:Create", PC, PH)
end)
RegisterNetEvent("SG_CL:Create")
AddEventHandler("SG_CL:Create", function(coords, heading)
local playerCoords = coords
local playerHeading = heading
while not HasModelLoaded(GetHashKey("pedCop")) do
RequestModel(GetHashKey("pedCop"))
Wait(50)
end
local guard = CreatePed(4, GetHashKey(pedCop), playerCoords.x, playerCoords.y, playerCoords.z, playerHeading, true, true)
while not DoesEntityExist(guard) do
print('Waiting')
Wait(50)
end
TaskSetBlockingOfNonTemporaryEvents(guard, true)
SetEntityInvincible(guard, true)
SetPedComponentVariation(guard, 3, 0, 1, 1)
SetPedComponentVariation(guard, 8, 1, 1, 1)
SetPedComponentVariation(guard, 9, 0, 0, 1)
Citizen.Wait(1000)
SetPedCombatMovement(guard, true)
FreezeEntityPosition(guard, true)
TaskStartScenarioInPlace(guard, "WORLD_HUMAN_GUARD_STAND", 0, false)
local guardBlip = AddBlipForCoord(playerCoords.x, playerCoords.y, playerCoords.z)
SetBlipSprite(guardBlip, 487)
SetBlipDisplay(guardBlip, 4)
SetBlipScale(guardBlip, 1.0)
SetBlipAsShortRange(guardBlip, true)
BeginTextCommandSetBlipName("STRING");
AddTextComponentString("Scene Guard")
EndTextCommandSetBlipName(guardBlip)
-- Notification W/ Crime Reference
end)
Server.LUA
RegisterNetEvent('SG_SV:Create')
AddEventHandler('SG_SV:Create', function(coords, heading, source)
TriggerClientEvent('SG_CL:Create', -1, coords, heading) -- Pass Source to fixw
end)