Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <streamer>
- #include <evf>
- #if defined MAX_OBJECTS_NAMED
- #undef MAX_OBJECTS_NAMED
- #endif
- #if defined MAX_OBJECT_NAME
- #undef MAX_OBJECT_NAME
- #endif
- #if defined MAX_OBJECTS
- #undef MAX_OBJECTS
- #endif
- #define MAX_MODELS 20000 // Source : sa-mp.de object list
- #define MAX_MODEL_NAME 128
- #define MAX_OBJECTS 1024
- new modNames[MAX_MODELS][MAX_MODEL_NAME], chestCt[MAX_VEHICLES][4][MAX_MODEL_NAME], oMod[MAX_OBJECTS];
- stock PutObjectInChest(objectid, vehicleid, slot, objecttype = 1, Float:rx = 0.0, Float:ry = 0.0, Float:rz = 0.0) // objecttype 1 = dynamic object, 2 = static object
- {
- new Float:off[3];
- GetVehicleBoot(vehicleid, off[0], off[1], off[2]);
- switch(slot)
- {
- case 0: off[0] -= 0.75; // Solution alternative : off[1] -= 0.75;
- case 1: off[0] -= 0.25; // Solution alternative : off[1] -= 0.25;
- case 2: off[0] += 0.25; // Solution alternative : off[1] += 0.25;
- case 3: off[0] += 0.75; // Solution alternative : off[1] += 0.75;
- }
- if(objecttype == 1)
- {
- AttachDynamicObjectToVehicle(objectid, vehicleid, off[0], off[1], off[2], rx, ry, rz);
- GetModelName(GetDynamicObjectModel(objectid), chestCt[vehicleid][slot]);
- }
- else if(objecttype == 2)
- {
- AttachObjectToVehicle(objectid, vehicleid, off[0], off[1], off[2], rx, ry, rz);
- GetModelName(GetObjectModel(objectid), chestCt[vehicleid][slot]);
- }
- SetVehicleParams(vehicleid, VEHICLE_TYPE_BOOT, 1);
- return 1;
- }
- stock SetModelName(modelid, const name[])
- {
- if((strlen(name) >= 128) || (0 > modelid > 19999) return -1; // Nom trop long, model invalide, c'est pour pas faire crash le serveur au cas où avec un run time error upper bound
- strdel(modNames[modelid]);
- strcat(modNames[modelid], name);
- }
- stock GetModelName(modelid, name[])
- {
- strdel(name, 0, sizeof name);
- strcat(name, modNames[modelid]);
- if(strlen(name) < 2) name = {NULL, ...};
- }
- stock GetModelIDByName(name[], bool:ignorecase = true, maxsize = sizeof name)
- {
- for(new i = 0; i < MAX_MODELS; i++)
- {
- if(!strcmp(name, modNames[i], ignorecase, maxsize)) return i;
- }
- return 1;
- }
- stock GetDynamicObjectModel(objectid)
- {
- if(!IsValidDynamicObject(objectid)) return -1;
- return oMod[objectid];
- }
- stock NEW_CreateDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 200.0, Float:drawdistance = 0.0)
- {
- new obj = CreateDynamicObject(modelid, x, y, z, rx, ry, rz, worldid, interiorid, playerid, streamdistance, drawdistance);
- oMod[obj] = modelid;
- return obj;
- }
- stock NEW_CreateDynamicObjectEx(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:drawdistance = 0.0, Float:streamdistance = 200.0, worlds[] = { -1 }, interiors[] = { -1 }, players[] = { -1 }, maxworlds = sizeof worlds, maxinteriors = sizeof interiors, maxplayers = sizeof players)
- {
- new obj = CreateDynamicObjectEx(modelid, x, y, z, rx, ry, rz, drawdistance, streamdistance, worlds, interiors, players, maxworlds, maxinteriors, maxplayers);
- oMod[obj] = modelid;
- return obj;
- }
- stock GetChestContent(vehicleid, slot, dest[])
- {
- strdel(dest, 0, sizeof dest);
- strcat(chestCt[vehicleid][slot], dest);
- if(strlen(name) < 2) name = {NULL, ...};
- }
- #if defined _ALS_CreateDynamicObject
- #undef CreateDynamicObject
- #else
- #define _ALS_CreateDynamicObject
- #endif
- #if defined _ALS_CreateDynamicObjectEx
- #undef CreateDynamicObjectEx
- #else
- #define _ALS_CreateDynamicObjectEx
- #endif
- #define CreateDynamicObjectEx NEW_CreateDynamicObjectEx
- #define CreateDynamicObject NEW_CreateDynamicObject
Advertisement
Add Comment
Please, Sign In to add comment