Guest User

Untitled

a guest
Apr 13th, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #define MAX_DYN_OBJECTS 1000
  7.  
  8. public OnFilterScriptInit()
  9. {
  10. print("\n--------------------------------------");
  11. print(" Streamer на Pawn by Caypen v0.1.2");
  12. print("--------------------------------------\n");
  13. return 1;
  14. }
  15.  
  16. public OnFilterScriptExit()
  17. {
  18. return 1;
  19. }
  20. new DynObjects;
  21. enum ObjInf
  22. {
  23. modelid2,
  24. used,
  25. Float:X2,
  26. Float:Y2,
  27. Float:Z2,
  28. Float:rX2,
  29. Float:rY2,
  30. Float:rZ2,
  31. Float:DrawDistance2
  32. };
  33. new Oinf[MAX_DYN_OBJECTS][ObjInf];
  34. new timerupdate[MAX_PLAYERS];
  35. CreateDynObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DrawDistance = 0.0)
  36. {
  37. if(DynObjects >= MAX_DYN_OBJECTS-1) return INVALID_OBJECT_ID;
  38. new rands = AddObject();
  39. Oinf[rands][modelid2] = modelid;
  40. Oinf[rands][X2] = X;
  41. Oinf[rands][Y2] = Y;
  42. Oinf[rands][Z2] = Z;
  43. Oinf[rands][rX2] = rX;
  44. Oinf[rands][rY2] = rY;
  45. Oinf[rands][rZ2] = rZ;
  46. Oinf[rands][DrawDistance2] = DrawDistance;
  47. DynObjects ++;
  48. return rands;
  49. }
  50. new bool:Created[MAX_PLAYERS][MAX_DYN_OBJECTS];
  51. forward UpdateObjects(player);
  52. public UpdateObjects(player)
  53. {
  54. for(new obj = 0;obj < MAX_DYN_OBJECTS;obj++)
  55. {
  56. if(Oinf[obj][used] == 0) continue;
  57. if(IsPlayerInRangeOfPoint(player,Oinf[obj][DrawDistance2],Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2]))
  58. {
  59. if(Created[player][obj] == false)
  60. {
  61. CreatePlayerObject(player, Oinf[obj][modelid2], Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2], Oinf[obj][rX2],Oinf[obj][rY2],Oinf[obj][rZ2], Oinf[obj][DrawDistance2]);
  62. Created[player][obj] = true;
  63. }
  64. }
  65. else
  66. {
  67. if(Created[player][obj] == true)
  68. {
  69. DestroyPlayerObject(player, obj);
  70. Created[player][obj] = false;
  71. }
  72. }
  73. }
  74. return true;
  75. }
  76. AddObject()
  77. {
  78. for(new rands = 0;rands < MAX_DYN_OBJECTS;rands++)
  79. {
  80. if(Oinf[rands][used] == 0)
  81. {
  82. Oinf[rands][used] = 1;
  83. return rands;
  84. }
  85. }
  86. return INVALID_OBJECT_ID;
  87. }
  88. stock DestroyDynObject(objectid)
  89. {
  90. Oinf[objectid][used] = 0;
  91. Oinf[objectid][modelid2] = -1;
  92. Oinf[objectid][X2] = -1;
  93. Oinf[objectid][Y2] = -1;
  94. Oinf[objectid][Z2] = -1;
  95. Oinf[objectid][rX2] = -1;
  96. Oinf[objectid][rY2] = -1;
  97. Oinf[objectid][rZ2] = -1;
  98. Oinf[objectid][DrawDistance2] = -1;
  99. DynObjects--;
  100. return true;
  101. }
  102. public OnPlayerConnect(playerid)
  103. {
  104. if(IsPlayerNPC(playerid))return true;
  105. timerupdate[playerid] = SetTimerEx("UpdateObjects", 2000, true, "i", playerid);
  106. return 1;
  107. }
  108.  
  109. public OnPlayerDisconnect(playerid, reason)
  110. {
  111. if(IsPlayerNPC(playerid)) return true;
  112. KillTimer(timerupdate[playerid]);
  113. for(new obj = 0;obj < MAX_DYN_OBJECTS;obj++)
  114. {
  115. if(Oinf[obj][used] == 0) continue;
  116. if(IsPlayerInRangeOfPoint(playerid,Oinf[obj][DrawDistance2],Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2]))
  117. {
  118. if(Created[playerid][obj] == true)
  119. {
  120. DestroyPlayerObject(playerid, obj);
  121. Created[playerid][obj] = false;
  122. }
  123. }
  124. Created[playerid][obj] = false;
  125. }
  126. return 1;
  127. }
Advertisement
Add Comment
Please, Sign In to add comment