Custom Models (0.3.DL)
Custom skins and objects with a safe 0.3.7 fallback.
SA-MP 0.3.DL lets clients download custom character models and objects. Knight detects the client version and only sends model data to DL clients.
Register a model
knight
system::start() {
// Custom skin: base skin 305, new id 20001 (range 20001-30000)
AddCharModel(305, 20001, "skins/cop.dff", "skins/cop.txd");
// Custom object: base object 19379, new id -2000 (range -30000..-1000)
AddSimpleModel(-1, 19379, -2000, "/srv/models/crate.dff", "/srv/models/crate.txd");
AddPlayerClass(20001, 1958.4, 1343.2, 15.4, 270.0, 24, 50);
};
Where do files live?
Anywhere you like. Paths work like C++ includes:
knight
AddSimpleModel(-1, 19379, -2000, "/srv/models/a.dff", "/srv/models/a.txd"); // absolute
AddSimpleModel(-1, 19379, -2001, "assets/a.dff", "assets/a.txd"); // relative to CWD
AddSimpleModel(-1, 19379, -2002, "a.dff", "a.txd"); // bare -> artpath
Download flow
knight
player::request_download(int playerid, int type, int crc) {
// type 1 = model, 2 = texture. Return false to deny.
Log("download request type={type} crc={crc}");
return true; // serve from artwork_cdn / artpath
};
player::finished_downloading(int playerid, int virtualworld) {
SendClientMessage(playerid, "Custom models ready!");
};
0.3.7 fallback
- 0.3.7 clients never receive custom-model RPCs.
- Custom skin ids are sent as their base skin.
- Custom object ids are sent as their base object.
- The gamemode keeps the real id, so
GetPlayerCustomSkinstays correct.
Tip
IsValidCustomModel(id) checks whether an id is in a custom range.