Advertisement
nandoy

TSSA Objects

Sep 5th, 2014
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.48 KB | None | 0 0
  1. /*                              **********************************************************
  2.                                 **********************************************************
  3.                                 **                                                      **
  4.                                 **   $$$$$$$$$$$$$$$                                    **
  5.                                 **   $$$$$$$$$$$$$$$                                    **
  6.                                 **        $$$$       $$$$$$$    $$$$$$$$    $$$$$$$     **
  7.                                 **        $$$$      $$$$$$$$$  $$$$$$$$$$  $$$$$$$$$    **
  8.                                 **        $$$$      $$$        $$$         $$$   $$$    **
  9.                                 **        $$$$      $$$$$$$$   $$$$$$$$$   $$$$$$$$$    **
  10.                                 **        $$$$       $$$$$$$$   $$$$$$$$$  $$$$$$$$$    **
  11.                                 **        $$$$            $$$         $$$  $$$   $$$    **
  12.                                 **        $$$$       $$$$$$$$   $$$$$$$$$  $$$   $$$    **
  13.                                 **        $$$$        $$$$$$     $$$$$$$   $$$   $$$    **
  14.                                 **                                                      **
  15.                                 **                         ~ RPG Cidade Virtual TSSA  ~ **
  16.                                 **********************************************************
  17.                                                         ~ [TSSA]Nando ~
  18.                                             ... E-mail: [email protected] ...
  19.                                             ... Site:     www.tssabr.org     ...
  20.                                             ... IP:         cv.tssabr.org:7777   ...
  21.                                 **********************************************************
  22.                                 **********************************************************
  23.                                 native GetObjectModel(objectid);
  24.                                 native IsPlayerInRangeOfObject(playerid, Float:range, objectid);
  25.                                 native IsPlayerInRangeOfModelID(playerid, Float:range, modelid);
  26.                                 native GetRangePlayerObjectID(playerid, Float:range);
  27.                                 native IsPlayerInRangeOfAnyObject(playerid, Float:range);
  28.                                 native GetPlayerDistanceToObject(playerid, objectid);
  29.                                 native CreateExplosionOnObject(objectid, type, Float:radius);                              
  30. */
  31. #include <a_samp>
  32. #include <dutils>
  33. enum oInfo
  34. {
  35.     infoid,
  36.     infomodel,
  37.     Float:infoX,
  38.     Float:infoY,
  39.     Float:infoZ,
  40.     Float:infoDrawD
  41. };
  42. new ObjectInfo[MAX_OBJECTS][oInfo];
  43.  
  44. Float:GetDistanceToPoint(playerid,Float:x2,Float:y2,Float:z2)
  45. {
  46.     if (IsPlayerConnected(playerid))
  47.     {
  48.         new Float:x1,Float:y1,Float:z1;
  49.         GetPlayerPos(playerid,x1,y1,z1);
  50.         return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  51.     }
  52.     return 9999.9;
  53. }
  54.  
  55. stock CreateTSSAObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DrawDistance = 300.0)
  56. {
  57.     new objectid = CreateObject(modelid, X, Y, Z, rX, rY, rZ, DrawDistance);
  58.     ObjectInfo[objectid][infoid] = objectid;
  59.     ObjectInfo[objectid][infomodel] = modelid;
  60.     ObjectInfo[objectid][infoX] = X;
  61.     ObjectInfo[objectid][infoY] = Y;
  62.     ObjectInfo[objectid][infoZ] = Z;
  63.     ObjectInfo[objectid][infoDrawD] = DrawDistance;
  64.     return objectid;
  65. }
  66.  
  67. stock DestroyTSSAObject(objectid)
  68. {
  69.     DestroyObject(objectid);
  70.     ObjectInfo[objectid][infoid] = -1;
  71.     ObjectInfo[objectid][infomodel] = -1;
  72.     ObjectInfo[objectid][infoX] = 0.0;
  73.     ObjectInfo[objectid][infoY] = 0.0;
  74.     ObjectInfo[objectid][infoZ] = -15.0 + random(5000);
  75.     ObjectInfo[objectid][infoDrawD] = -1;
  76.     return 1;
  77. }
  78.  
  79. stock MoveTSSAObject(objectid, Float:X, Float:Y, Float:Z, Float:Speed, Float:RotX = -1000.0, Float:RotY = -1000.0, Float:RotZ = -1000.0)
  80. {
  81.     MoveObject(objectid, Float:X, Float:Y, Float:Z, Float:Speed, Float:RotX, Float:RotY, Float:RotZ);
  82.     ObjectInfo[objectid][infoX] = X;
  83.     ObjectInfo[objectid][infoY] = Y;
  84.     ObjectInfo[objectid][infoZ] = Z;
  85.     return 1;
  86. }
  87.  
  88. stock GetObjectModel(objectid)
  89. {
  90.     if(!IsValidObject(objectid)) return 0;
  91.     return ObjectInfo[objectid][infomodel];
  92. }
  93.  
  94. stock IsPlayerInRangeOfObject(playerid, Float:range, objectid)
  95. {
  96.     if(IsValidObject(objectid) && IsPlayerConnected(playerid))
  97.     {
  98.         if(IsPlayerInRangeOfPoint(playerid, range, ObjectInfo[objectid][infoX], ObjectInfo[objectid][infoY], ObjectInfo[objectid][infoZ])) return 1;
  99.         else return 0;
  100.     }
  101. }
  102.  
  103. stock IsPlayerInRangeOfModelID(playerid, Float:range, modelid)
  104. {
  105.     new FindM = -1;
  106.     for(new I = 0; I < MAX_OBJECTS; I++)
  107.     {
  108.         if(IsValidObject(objectid) && GetObjectModel(I) == modelid)
  109.         {
  110.             if(IsPlayerInRangeOfPoint(playerid, range, ObjectInfo[objectid][infoX], ObjectInfo[objectid][infoY], ObjectInfo[objectid][infoZ])) { AchouM = I; break; }
  111.         }
  112.     }
  113.     return FindM;
  114. }
  115.  
  116. stock IsPlayerInRangeOfAnyObject(playerid, Float:range)
  117. {
  118.     for(new I = 0; I < MAX_OBJECTS; I++)
  119.     {
  120.         if(ObjectInfo[I][infoid] != 999999) if(IsPlayerInRangeOfPoint(playerid, range, ObjectInfo[I][infoX], ObjectInfo[I][infoY], ObjectInfo[I][infoZ])) return 1;
  121.     }
  122.     return 0;
  123. }
  124.  
  125. stock GetRangePlayerObjectID(playerid, Float:range)
  126. {
  127.     new objectid = -1;
  128.     for(new I = 0; I < MAX_OBJECTS; I++)
  129.     {
  130.         if(ObjectInfo[I][infoid] != 999999) { if(IsPlayerInRangeOfPoint(playerid, range, ObjectInfo[I][infoX], ObjectInfo[I][infoY], ObjectInfo[I][infoZ])) { objectid = I; break; } }
  131.     }
  132.     return objectid;
  133. }
  134.  
  135. stock GetPlayerDistanceToObject(playerid, objectid)
  136. {
  137.     new Float:dist = 99999.9;
  138.     if(IsValidObject(objectid) && IsPlayerConnected(playerid)) dist = GetDistanceToPoint(playerid, ObjectInfo[objectid][infoX], ObjectInfo[objectid][infoY], ObjectInfo[objectid][infoZ]);
  139.     return trunc(dist);
  140. }
  141.  
  142. stock CreateExplosionOnObject(objectid, type, Float:radius) CreateExplosion(ObjectInfo[objectid][infoX], ObjectInfo[objectid][infoY], ObjectInfo[objectid][infoZ], type, Float:radius);
  143.  
  144. #define ExplodeObject CreateExplosionOnObject
  145. #define CreateObject CreateTSSAObject
  146. #define DestroyObject DestroyTSSAObject
  147. #define MoveObject MoveTSSAObject
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement