|
Returns
|
ClientStaticObject
|
|
Prototype
|
ClientStaticObject.Create(table)
|
|
Description
|
Spawns a ClientStaticObject using an argument table.
|
Required values
Optional values
| Type |
Name |
Default |
Notes |
| string |
collision |
"" |
Path to the collision file. See the model viewer for the full list. |
| boolean |
fixed |
true |
If false, the object will move smoothly and players can be transported while standing on it. |
Notes
- If collision isn't provided, or is invalid, the object will have no collision.
- If fixed is false, you must provide a collision argument.
Example
Create a ramp in front of you when the horn button is pressed
Client
pressed = false
objects = {}
function SpawnRamp()
local vehicle = LocalPlayer:GetVehicle()
if not IsValid(vehicle) then
return
end
local angle = vehicle:GetAngle()
local direction = angle * Vector3.Forward
local position = vehicle:GetPosition() + direction * 35
angle = angle * Angle(math.pi * -0.5, 0, 0)
spawnArgs = {}
spawnArgs.position = position
spawnArgs.angle = angle
spawnArgs.model = "17x48.fl/go666-b.lod"
spawnArgs.collision = "17x48.fl/go666_lod1-b_col.pfx"
local object = ClientStaticObject.Create(spawnArgs)
table.insert(objects, object)
end
Events:Subscribe("PreTick", function()
local currentlyPressed = Input:GetValue(Action.SoundHornSiren) > 0
if currentlyPressed then
if pressed == false then
SpawnRamp()
end
end
pressed = currentlyPressed
end)
Events:Subscribe("ModuleUnload", function()
for index, object in ipairs(objects) do
object:Remove()
end
end)