You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dynamic server-side ped spawner for Onesync Infinity spawns peds when a player enters a defined radius and removes them when no players remain within that radius. It supports bucket functionality and is heavily optimized for performance
2 server exports to utilize in external resources
create
---creates an instance of the Ped class, stores it in an storage, and returns the ped's unique key---@parampedModelnumber | string---@parampedCoordsvector4---@parampedRadiusnumber---@parampedBucketnumber---@paramclientOnEnterScript?string---@returnstring the unique key of the ped instance that was just createdexports["x-pedSpawner"]:create(pedModel, pedCoords, pedRadius, pedBucket, clientOnEnterScript)
remove
---removes the specified instance of the Ped with the specified key from the storage, returns if the process was successful or not---@parampedKeystring---@returnbooleanexports["x-pedSpawner"]:remove(pedKey)
Example
-- SERVER-- ** anything that is inside clientScript will be executed 1 time for each player on client once they are inside the ped's radius **localclientScript=[[ local entityId = %entity -- the actual id of the entity in client will replace automatically with all instances of the %entity SetEntityInvincible(entityId, true) FreezeEntityPosition(entityId, true) SetEntityProofs(entityId, true, true, true, false, true, true, true, true) SetPedDiesWhenInjured(entityId, false) SetPedFleeAttributes(entityId, 2, true) SetPedCanPlayAmbientAnims(entityId, false) SetPedCanLosePropsOnDamage(entityId, false, 0) SetPedRelationshipGroupHash(entityId, `PLAYER`) SetBlockingOfNonTemporaryEvents(entityId, true) SetPedCanRagdollFromPlayerImpact(entityId, false) local ox_target = exports.ox_target if ox_target then ox_target:addLocalEntity(entityId, { label = "isn't this nice?" }) end]]RegisterCommand("addPed", function(source, args)
localplayerPed=GetPlayerPed(source)
localplayerCoords=GetEntityCoords(playerPed)
localplayerHeading=GetEntityHeading(playerPed)
localpedKey=exports["x-pedSpawner"]:create(joaat(args[1] or"a_m_m_eastsa_01"), vector4(playerCoords.x, playerCoords.y, playerCoords.z, playerHeading), 10.0, GetPlayerRoutingBucket(source), clientScript)
print(("Created a ped with the unique key of %s"):format(pedKey))
end, false)
RegisterCommand("removePed", function(source, args)
localpedKey=args[1]
localresult=exports["x-pedSpawner"]:remove(pedKey)
print(("%s the ped with the unique key of %s"):format(resultand"Removed" or"Could not remove", pedKey))
end, false)
About
Server-side ped spawner for OneSync Infinity with bucket support