Guest User

Deinol

a guest
Mar 4th, 2009
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.67 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3.  
  4. // Interior del camion de los perritos By Deinol / Krroza.
  5. // No se olviden los creditos si lo distribuyen.
  6. //
  7. //
  8. // HotDogs truck's interior by Deinol / Krroza.
  9. // Dont forget the credits.
  10.  
  11.  
  12.  
  13. forward Timer();
  14. forward SetPlayerPosWithObjects(playerid,Float:x,Float:y,Float:z);
  15.  
  16. new InHotDog[MAX_PLAYERS];
  17.  
  18. public OnPlayerConnect(playerid)
  19. {
  20. InHotDog[playerid]=0;
  21. return 1;
  22. }
  23.  
  24. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  25. {
  26. if (GetVehicleModel(vehicleid) == 588 && ispassenger == 1)
  27. {
  28. SetPlayerInterior(playerid,15);
  29. SetPlayerFacingAngle(playerid,0.0);
  30. SetPlayerPos(playerid, 1476.6495, -1435.6868, 14.3984);
  31. SetCameraBehindPlayer(playerid);
  32. InHotDog[playerid]=vehicleid;
  33. }
  34. return 1;
  35. }
  36.  
  37. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  38. {
  39. if (newkeys & 16 && InHotDog[playerid] > 0)
  40. {
  41. new Float:X,Float:Y,Float:Z,Float:A;
  42. GetVehiclePos(InHotDog[playerid],X,Y,Z);
  43. GetVehicleZAngle(InHotDog[playerid],A);
  44. X+=(5*floatsin(-floatsub(A,45.0),degrees)),
  45. Y+=(5*floatcos(-floatsub(A,45.0),degrees));
  46. SetPlayerInterior(playerid,0);
  47. SetPlayerPos(playerid,X,Y,floatsub(Z,0.94));
  48. SetPlayerFacingAngle(playerid,A);
  49. SetCameraBehindPlayer(playerid);
  50. InHotDog[playerid]=0;
  51. }
  52. return 1;
  53. }
  54.  
  55.  
  56. enum object_info
  57. {
  58. modelid,
  59. Float:ox,
  60. Float:oy,
  61. Float:oz,
  62. Float:orx,
  63. Float:ory,
  64. Float:orz,
  65. Float:viewdist
  66. }
  67.  
  68. new Objects[][object_info] = {
  69. {3881, 1476.6495, -1435.6868, 14.3984, 0.0000, 0.0000, 0.0000, 500.0},
  70. {936, 1475.0850, -1437.4669, 13.1216, 0.0000, 0.0000, 90.0000, 500.0},
  71. {937, 1475.0568, -1435.4692, 13.1216, 0.0000, 0.0000, 270.0000, 500.0},
  72. {1959, 1475.0399, -1437.9623, 13.5957, 0.0000, 0.0000, 90.0000, 500.0},
  73. {2500, 1474.6616, -1434.9496, 13.5946, 0.0000, 0.0000, 90.0000, 500.0},
  74. {2541, 1474.9764, -1435.9662, 13.6014, 0.0000, 0.0000, 90.0000, 500.0},
  75. {2542, 1475.4663, -1438.1422, 13.5946, 0.0000, 0.0000, 180.0002, 500.0},
  76. {2543, 1474.6903, -1434.8959, 13.6387, 0.0000, 0.0000, 90.0000, 500.0},
  77. {2589, 1475.4150, -1433.2513, 17.9290, 0.0000, 0.0000, 0.0000, 500.0},
  78. {2601, 1475.1350, -1435.1896, 13.7793, 0.0000, 0.0000, 0.0000, 500.0},
  79. {2804, 1475.5050, -1435.7753, 13.7554, 0.0000, 0.0000, 0.0000, 500.0},
  80. {2414, 1478.9999, -1437.1278, 12.6411, 0.0000, 0.0000, 270.0000, 500.0},
  81. {2414, 1478.7667, -1435.1379, 13.0976, 0.0000, 0.0000, 270.0000, 500.0},
  82. {2414, 1478.7850, -1435.0863, 12.6411, 0.0000, 0.0000, 270.0000, 500.0},
  83. {2414, 1478.7906, -1433.1378, 12.6411, 0.0000, 0.0000, 270.0000, 500.0},
  84. {2414, 1478.7909, -1431.8584, 12.6411, 0.0000, 0.0000, 270.0000, 500.0},
  85. {2557, 1478.2776, -1435.0341, 12.6469, 0.0000, 0.0000, 270.0000, 500.0},
  86. {2557, 1478.2549, -1435.9938, 12.6469, 0.0000, 0.0000, 270.0000, 500.0},
  87. {2804, 1478.5315, -1432.6281, 13.8536, 0.0000, 0.0000, 247.5000, 500.0},
  88. {2803, 1475.3384, -1434.0157, 13.3036, 0.0000, 0.0000, 0.0000, 500.0},
  89. {2806, 1478.4901, -1433.7827, 13.9151, 0.0000, 0.0000, 11.2500, 500.0},
  90. {2871, 1478.5090, -1437.9728, 13.5746, 0.0000, 0.0000, 270.0000, 500.0},
  91. {2871, 1478.5090, -1437.1484, 13.5837, 0.0000, 0.0000, 270.0000, 500.0},
  92. {1513, 1474.9342, -1436.6986, 13.8738, 0.0000, 0.0000, 360.0000, 500.0},
  93. {1518, 1474.5245, -1437.2278, 14.7626, 0.0000, 0.0000, 90.0000, 500.0},
  94. {2344, 1475.4017, -1436.6493, 13.6072, 0.0000, 0.0000, 270.0000, 500.0},
  95. {2417, 1477.8164, -1432.1445, 12.6442, 0.0000, 0.0000, 0.0000, 500.0},
  96. {2632, 1476.6541, -1435.7738, 12.6932, 0.0000, 0.0000, 270.0000, 500.0},
  97. {14527, 1476.9280, -1435.9486, 13.4152, 0.0000, 0.0000, 0.0000, 500.0},
  98. {1651, 1474.2395, -1437.8748, 13.4732, 0.0000, 0.0000, 0.0000, 500.0},
  99. {1553, 1474.4269, -1437.2815, 13.5767, 0.0000, 0.0000, 270.0000, 500.0},
  100. {1716, 1476.4191, -1436.7744, 12.7468, 0.0000, 0.0000, 0.0000, 500.0},
  101. {1510, 1475.4889, -1436.2865, 13.6089, 0.0000, 0.0000, 0.0000, 500.0},
  102. {1485, 1475.3800, -1436.3567, 13.5864, 0.0000, 0.0000, 33.7499, 500.0},
  103. {1546, 1475.5022, -1437.5734, 13.6863, 0.0000, 0.0000, 0.0000, 500.0},
  104. {1665, 1475.5070, -1436.3196, 13.6589, 0.0000, 0.0000, 0.0000, 500.0},
  105. {1455, 1475.1350, -1435.0344, 13.7761, 0.0000, 0.0000, 0.0000, 500.0},
  106. {1898, 1474.5533, -1436.9283, 14.0673, 0.0000, 0.0000, 0.0000, 500.0},
  107. {1965, 1477.2278, -1438.7129, 13.8807, 0.0000, 0.0000, 90.0000, 500.0},
  108. {1814, 1477.8198, -1435.0029, 12.6358, 0.0000, 0.0000, 270.0000, 500.0},
  109. {2007, 1476.5740, -1438.4814, 12.6425, 0.0000, 0.0000, 180.0000, 500.0},
  110. {2007, 1476.5745, -1438.4840, 13.9674, 0.0000, 0.0000, 180.0000, 500.0},
  111. {1562, 1476.6025, -1432.3632, 13.3021, 0.0000, 0.0000, 0.0000, 500.0},
  112. {1563, 1476.5896, -1431.9851, 13.8272, 0.0000, 0.0000, 0.0000, 500.0},
  113. {3515, 1477.8840, -1435.6686, 18.0321, 0.0000, 0.0000, 0.0000, 500.0},
  114. {1574, 1477.8783, -1434.2631, 12.6850, 0.0000, 0.0000, 0.0000, 500.0},
  115. {2222, 1474.9329, -1437.2195, 13.6655, 0.0000, 0.0000, 0.0000, 500.0},
  116. {3280, 1475.3812, -1432.5619, 12.6469, 0.0000, 0.0000, 0.0000, 500.0},
  117. {2690, 1478.7773, -1435.6411, 14.5112, 0.0000, 0.0000, 258.7500, 500.0},
  118. {2709, 1477.2467, -1432.2721, 12.7865, 0.0000, 0.0000, 236.2501, 500.0},
  119. {1210, 1477.1710, -1432.3081, 12.7953, 0.0000, 0.0000, 270.0000, 500.0},
  120. {1247, 1479.3058, -1434.2609, 15.1638, 0.0000, 0.0000, 270.0000, 500.0},
  121. {2194, 1474.9445, -1431.9647, 12.9778, 0.0000, 0.0000, 0.0000, 500.0}
  122.  
  123.  
  124. };
  125.  
  126. enum player_info
  127. {
  128. objid[sizeof(Objects)],
  129. bool:view[sizeof(Objects)]
  130. }
  131. new Player[MAX_PLAYERS][player_info];
  132.  
  133. //------------------------------------------------------------------------------
  134.  
  135. bool:IsInReach(Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:z2,Float:dist)
  136. {
  137. x = (x > x2) ? x - x2 : x2 - x;
  138. if(x > dist) return false;
  139. y = (y > y2) ? y - y2 : y2 - y;
  140. if(y > dist) return false;
  141. z = (z > z2) ? z - z2 : z2 - z;
  142. if(z > dist) return false;
  143. return true;
  144. }
  145.  
  146. //------------------------------------------------------------------------------
  147.  
  148. new timer;
  149.  
  150. public OnFilterScriptInit()
  151. {
  152. print("---\nLoaded xObjects by Deinol / Krroza\n---");
  153. timer = SetTimer("Timer",500,1);
  154. return 1;
  155. }
  156.  
  157. public OnFilterScriptExit()
  158. {
  159. for(new i = 0; i < MAX_PLAYERS; i++)
  160. {
  161. for(new o = 0; o < sizeof(Objects); o++)
  162. {
  163. if(Player[i][view][o])
  164. {
  165. Player[i][view][o] = false;
  166. DestroyPlayerObject(i,Player[i][objid][o]);
  167. }
  168. }
  169. }
  170.  
  171. KillTimer(timer);
  172. }
  173.  
  174. //------------------------------------------------------------------------------
  175.  
  176.  
  177.  
  178. public OnPlayerDisconnect(playerid)
  179. {
  180. for(new i = 0; i < sizeof(Objects); i++)
  181. {
  182. if(Player[playerid][view][i])
  183. {
  184. Player[playerid][view][i] = false;
  185. DestroyPlayerObject(playerid,Player[playerid][objid][i]);
  186. }
  187. }
  188. }
  189.  
  190. //------------------------------------------------------------------------------
  191.  
  192. public Timer()
  193. {
  194. for(new i = 0; i < MAX_PLAYERS; i++)
  195. if(IsPlayerConnected(i))
  196. PlayerObjectUpdate(i);
  197. }
  198.  
  199. PlayerObjectUpdate(playerid)
  200. {
  201. new Float:pos[3];
  202. GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
  203. for(new i = 0; i < sizeof(Objects); i++)
  204. {
  205. if(!Player[playerid][view][i])
  206. {
  207. if(IsInReach(pos[0],pos[1],pos[2],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
  208. {
  209. Player[playerid][view][i] = true;
  210. Player[playerid][objid][i] = CreatePlayerObject(playerid,Objects[i][modelid],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][orx],Objects[i][ory],Objects[i][orz]);
  211. }
  212. } else if(!IsInReach(pos[0],pos[1],pos[2],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
  213. {
  214. Player[playerid][view][i] = false;
  215. DestroyPlayerObject(playerid,Player[playerid][objid][i]);
  216. }
  217. }
  218. }
  219.  
  220. public SetPlayerPosWithObjects(playerid,Float:x,Float:y,Float:z)
  221. {
  222. for(new i = 0; i < sizeof(Objects); i++)
  223. {
  224. if(!Player[playerid][view][i])
  225. {
  226. if(IsInReach(x,y,z,Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
  227. {
  228. Player[playerid][view][i] = true;
  229. Player[playerid][objid][i] = CreatePlayerObject(playerid,Objects[i][modelid],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][orx],Objects[i][ory],Objects[i][orz]);
  230. }
  231. } else if(!IsInReach(x,y,z,Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
  232. {
  233. Player[playerid][view][i] = false;
  234. DestroyPlayerObject(playerid,Player[playerid][objid][i]);
  235. }
  236. }
  237. SetPlayerPos(playerid,Float:x,Float:y,Float:z);
  238. }
  239.  
  240. public OnPlayerSpawn(playerid)
  241. PlayerObjectUpdate(playerid);
Advertisement
Add Comment
Please, Sign In to add comment