SetObjectMaterial

From SA-MP Wiki

Revision as of 16:10, 30 June 2012; view current revision
←Older revision | Newer revision→
Jump to: navigation, search


SetObjectMaterial was added in SA-MP 0.3x This function was added in SA-MP 0.3e and will not work in earlier versions!


Replace the texture of an object with the texture from another model in the game.


Parameters:
(objectid, materialindex, modelid, txdname[], texturename[], materialcolor)
objectidThe ID of the object to change the texture of
materialindexThe material index on the object to change
modelidThe modelid on which the replacement texture is located (use 0 for alpha)
txdnameThe name of the txd file which contains the replacement texture (use "none" for alpha)
texturenameThe name of the texture to use as the replacement (use "none" for alpha)
materialcolorThe object color to set, as an integer or hex in ARGB color format. Using 0 keeps the existing material color.


ReturnsThis function doesn't return a specific value


public OnPlayerCommandText(playerid,cmdtext[])
{
    if(!strcmp(cmdtext,"/mycommand",true))
    {
        new Float:X, Float:Y, Float:Z;
        new myobject;
        GetPlayerPos(playerid, X, Y, Z);
        myobject = CreateObject(19371, X, Y, Z+0.5, 0.0, 0.0, 0.0, 300.0);
        SetObjectMaterial(myobject, 0, 19341, "egg_texts", "easter_egg01", 0xFFFFFFFF);
        //Replaces the texture of our object with the texture of object 19341
        return 1;
    }
    return 0;
}


Image:32px-Circle-style-warning.png Important Note: You MUST use ARGB color format, not RGBA like used in client messages etc.



Related Functions

The following functions may be useful, as they are related to this function in one way or another.

Personal tools