|
Returns
|
StaticObject
|
|
Prototype
|
StaticObject.Create(Vector3 position, Angle angle, string model)
|
|
Description
|
Spawns a StaticObject with the specified model at position and angle.
|
Examples
Spawn a barrel model at the player
function PlayerChat(args)
if args.text == "/barrel" then
local path = "34x09.flz/go001-a.lod"
StaticObject.Create(args.player:GetPosition(), Angle(0, 0, 0), path)
return false
end
return true
end
Events:Subscribe("PlayerChat", PlayerChat)
|
Returns
|
StaticObject
|
|
Prototype
|
StaticObject.Create(table)
|
|
Description
|
No description
|
Description
Spawns a StaticObject using an argument table.
The following arguments are supported:
Required values
Optional values
| Type |
Name |
Default |
Notes |
| string |
collision |
"" |
Path to the collision file. See the model viewer for the full list. |
| World |
world |
DefaultWorld |
|
| boolean |
enabled |
true |
|
| 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.
Examples
Create a ramp in front of you when the horn button is pressed
Server
function SpawnRamp(arg, player)
local vehicle = player:GetVehicle()
if vehicle == nil then
return
end
Chat:Broadcast("Spawning ramp for "..tostring(player), Color(255, 255, 255))
local angle = vehicle:GetAngle()
local direction = angle * Vector3.Forward
local distance = 30 + vehicle:GetLinearVelocity():Length() * 0.5
local position = vehicle:GetPosition() + direction * distance
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"
spawnArgs.world = vehicle:GetWorld()
StaticObject.Create(spawnArgs)
end
Network:Subscribe("SpawnRamp", SpawnRamp)
Client
pressed = false
function PreTick()
local currentlyPressed = Input:GetValue(Action.SoundHornSiren) > 0
if currentlyPressed then
if pressed == false then
Network:Send("SpawnRamp")
end
end
pressed = currentlyPressed
end
Events:Subscribe("PreTick", PreTick)