S4T3K

chest include

Jun 19th, 2014
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.74 KB | None | 0 0
  1. #include <a_samp>
  2. #include <streamer>
  3. #include <evf>
  4.  
  5. #if defined MAX_OBJECTS_NAMED
  6.     #undef MAX_OBJECTS_NAMED
  7. #endif
  8. #if defined MAX_OBJECT_NAME
  9.     #undef MAX_OBJECT_NAME
  10. #endif
  11. #if defined MAX_OBJECTS
  12.     #undef MAX_OBJECTS
  13. #endif
  14. #define MAX_MODELS 20000 // Source : sa-mp.de object list
  15. #define MAX_MODEL_NAME 128
  16. #define MAX_OBJECTS 1024
  17.  
  18. new modNames[MAX_MODELS][MAX_MODEL_NAME], chestCt[MAX_VEHICLES][4][MAX_MODEL_NAME], oMod[MAX_OBJECTS];
  19.  
  20.  
  21.  
  22. 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
  23. {
  24.     new Float:off[3];
  25.     GetVehicleBoot(vehicleid, off[0], off[1], off[2]);
  26.     switch(slot)
  27.     {
  28.         case 0: off[0] -= 0.75; // Solution alternative : off[1] -= 0.75;
  29.         case 1: off[0] -= 0.25; // Solution alternative : off[1] -= 0.25;
  30.         case 2: off[0] += 0.25; // Solution alternative : off[1] += 0.25;
  31.         case 3: off[0] += 0.75; // Solution alternative : off[1] += 0.75;
  32.     }
  33.     if(objecttype == 1)
  34.     {
  35.         AttachDynamicObjectToVehicle(objectid, vehicleid, off[0], off[1], off[2], rx, ry, rz);
  36.         GetModelName(GetDynamicObjectModel(objectid), chestCt[vehicleid][slot]);
  37.     }
  38.     else if(objecttype == 2)
  39.     {
  40.         AttachObjectToVehicle(objectid, vehicleid, off[0], off[1], off[2], rx, ry, rz);
  41.         GetModelName(GetObjectModel(objectid), chestCt[vehicleid][slot]);
  42.     }
  43.     SetVehicleParams(vehicleid, VEHICLE_TYPE_BOOT, 1);
  44.     return 1;
  45. }
  46.  
  47. stock SetModelName(modelid, const name[])
  48. {
  49.     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
  50.     strdel(modNames[modelid]);
  51.     strcat(modNames[modelid], name);
  52. }
  53.  
  54. stock GetModelName(modelid, name[])
  55. {
  56.     strdel(name, 0, sizeof name);
  57.     strcat(name, modNames[modelid]);
  58.     if(strlen(name) < 2) name = {NULL, ...};
  59. }
  60.  
  61. stock GetModelIDByName(name[], bool:ignorecase = true, maxsize = sizeof name)
  62. {
  63.     for(new i = 0; i < MAX_MODELS; i++)
  64.     {
  65.         if(!strcmp(name, modNames[i], ignorecase, maxsize)) return i;
  66.     }
  67.     return 1;
  68. }
  69.  
  70. stock GetDynamicObjectModel(objectid)
  71. {
  72.     if(!IsValidDynamicObject(objectid)) return -1;
  73.     return oMod[objectid];
  74. }
  75.  
  76. 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)
  77. {
  78.     new obj = CreateDynamicObject(modelid, x, y, z, rx, ry, rz, worldid, interiorid, playerid, streamdistance, drawdistance);
  79.     oMod[obj] = modelid;
  80.     return obj;
  81. }
  82.  
  83. 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)
  84. {
  85.     new obj = CreateDynamicObjectEx(modelid, x, y, z, rx, ry, rz, drawdistance, streamdistance, worlds, interiors, players, maxworlds, maxinteriors, maxplayers);
  86.     oMod[obj] = modelid;
  87.     return obj;
  88. }
  89.  
  90. stock GetChestContent(vehicleid, slot, dest[])
  91. {
  92.     strdel(dest, 0, sizeof dest);
  93.     strcat(chestCt[vehicleid][slot], dest);
  94.     if(strlen(name) < 2) name = {NULL, ...};
  95. }
  96.  
  97.  
  98. #if defined _ALS_CreateDynamicObject
  99.     #undef CreateDynamicObject
  100. #else
  101.     #define _ALS_CreateDynamicObject
  102. #endif
  103.  
  104.  
  105. #if defined _ALS_CreateDynamicObjectEx
  106.     #undef CreateDynamicObjectEx
  107. #else
  108.     #define _ALS_CreateDynamicObjectEx
  109. #endif
  110.  
  111.  
  112. #define CreateDynamicObjectEx NEW_CreateDynamicObjectEx
  113. #define CreateDynamicObject NEW_CreateDynamicObject
Advertisement
Add Comment
Please, Sign In to add comment