Objects
Server scripts can put objects into the world with the FiveM functions CreateObject, DeleteEntity and FreezeEntityPosition. Every player sees them. The arguments are the same as in FiveM, the models are not: GAMPEON has its own.
RegisterCommand('crate', function(src) local ped = GetPlayerPed(src) local pos = GetEntityCoords(ped) local obj = CreateObject('prop_cube', pos.x + 2.0, pos.y, pos.z + 1.0, true, true, false) if obj == 0 then return -- unknown model or too many objects, the server log says which end FreezeEntityPosition(obj, true) -- stays in the air, no physicsend, false)Models
Section titled “Models”Pass the model name as a string or its hash from GetHashKey. Both work everywhere a model is expected.
| Model | Shape |
|---|---|
prop_cube |
Cube, 1 m |
prop_sphere |
Sphere, 1 m |
prop_cylinder |
Cylinder, 1 m |
prop_cone |
Cone, 1 m |
prop_plane |
Flat square, 1 m |
These five exist on every server. A game can add its own models; creators will be able to ship models with their content once the package format is ready.
GTA model names like prop_atm_01 do not exist. CreateObject then returns 0 and writes a hint into the server log, once per resource run. A ported script keeps running and the log shows which models are missing. IsModelValid(model) tells you beforehand.
GetHashKey computes the same hash as in FiveM. Hashes work signed and unsigned, so GetHashKey('prop_cube') and the unsigned value from a FiveM table both match.
Physics
Section titled “Physics”Objects are physical but rest until something touches them, like props in GTA. A player who walks into a cube pushes it. FreezeEntityPosition(obj, true) turns physics off and holds the object where it is; false turns it back on.
The server computes the physics and sends the movement to the players. SetEntityCoords and SetEntityHeading move objects like characters.
Who owns an object
Section titled “Who owns an object”Every object belongs to the resource that created it. When the resource stops, the server deletes its objects after onResourceStop. A restart therefore never leaves copies behind.
DeleteEntity deletes any object a script created, also those of other resources. It never deletes player characters.
Limits
Section titled “Limits”| Limit | Value |
|---|---|
| Objects per resource | 1000 |
| Objects per server | 10 000 |
Above the limit CreateObject returns 0 and writes a hint into the server log. The values are preliminary and may change after load tests.
Not yet available
Section titled “Not yet available”- Client scripts cannot create objects.
CreateObjectonly works on the server. Local objects for one player come later. - Network IDs.
NetworkGetNetworkIdFromEntityandNetworkGetEntityFromNetworkIdcome later, so client scripts cannot address server objects yet. - Vehicles.
CreateVehiclechecks its arguments but returns 0 with a hint, because there are no vehicle models yet.
All functions and their arguments are in World and entities. In gampeon-server objects stand where the script puts them, without physics; gp_entities lists them.