setObjectMaterial
Client-side
Applies an SA-MP-style texture and/or color override to one DFF material slot on a client object.
Syntax
bool setObjectMaterial(object theObject, int slot, int sourceModel, string txdName, string textureName [, int materialColor = 0])Arguments
theObjectobjectClient object to modify.
slotintMaterial slot from 0 through 15.
sourceModelintModel that owns the source TXD, or 0/-1 for color-only behavior.
txdNamestringSource TXD name.
textureNamestringSource texture name; none may be used for color-only behavior.
materialColorintoptional · default 0SA-MP ARGB material color; 0 preserves the target color.
Returns
true when the material definition and source texture were accepted; false otherwise.
Ownership and lifecycle
Parsing creates inert data. Objects, custom models, material overrides, removals, and any temporary streaming-limit split remain owned by the calling client resource and must be cleaned up when that resource stops.
Important behavior
- The override survives object stream-out and is reapplied when the GTA object is recreated.
- Slot N is applied to material N on every atomic in the model, matching SA-MP indexing.
OOP aliases
object:setMaterial(slot, sourceModel, txdName, textureName, materialColor)
Where this comes from
SOURCECLuaObjectDefs.cppClient/mods/deathmatch/logic/luadefs/CLuaObjectDefs.cpp INTRODUCED / EXTENDED28dfcff23Read the commit and why the change was made TEST RESOURCE samp-map-loader test-resources/samp-map-loader
RELATED NEON APIS
Read the system guide → Continue exploring
← Back to the Neon Lua API · How SA-MP maps and object streaming works →