Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.51 KB | None | 0 0
  1. /*-----------------------------------------------------/
  2. NOTE:
  3. Yes this only has 5 "functions", but don't worry, It's still beeing developed.
  4. This is like a, early early beta.
  5.  
  6. |* GetOnlinePlayers()
  7. |- Returns amount of online players.
  8. |- Thanks to: Meller for scripting.
  9.  
  10. |* AttachMapIconToPlayerForPlayer(playerid, targetid, iconid, icontype, color = 0)
  11. |- Name explains it.
  12. |- Thanks to: Meller for scripting.
  13. |- Thanks to: Manyula for idea.
  14.  
  15. |* AttachMapIconToPlayerForAll(playerid, iconid, icontype, color = 0)
  16. |- Name explains it.
  17. |- Thanks to: Meller for scripting.
  18. |- Thanks to: Manyula for idea.
  19.  
  20. |* OnVehicleUpdate(vehicleid)
  21. |- This calls everything a vehicle updates. (DOES NOT RUN ON POSITION OR VELOCITY)
  22. |- Thanks to: Meller for scripting.
  23.  
  24. |* GetVehicleSpeed(vehicleid, meter[])
  25. |- Meter options: KM/H, MP/H
  26. |- Thanks to: Meller for scripting.
  27. /-----------------------------------------------------*/
  28. stock GetOnlinePlayers()
  29. {
  30. new OnlinePlayers = 0;
  31. for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  32. if(IsPlayerConnected(playerid))
  33. OnlinePlayers++;
  34. return OnlinePlayers;
  35. }
  36. /*-----------------------------------------------------*/
  37. #include <YSI\y_hooks>
  38. new AttachedPlayerIcon[MAX_PLAYERS],
  39. AttachedPlayerIconID[MAX_PLAYERS],
  40. AttachedPlayerIconType[MAX_PLAYERS],
  41. AttachedPlayerIconColor[MAX_PLAYERS],
  42. AttachedPlayerIconTarget[MAX_PLAYERS],
  43. Float:AttachedPlayerIconLastPos[MAX_PLAYERS][4];
  44. hook OnPlayerConnect(playerid) { AttachedPlayerIcon[playerid] = 0; } // Only one is needed, because once we use Attach, we will re-set them.
  45. hook OnPlayerDisconnect(playerid, reason) { if(AttachedPlayerIcon[playerid] == 1) RemovePlayerMapIcon(AttachedPlayerIconTarget[playerid], AttachedPlayerIconID[playerid]); }
  46. stock AttachMapIconToPlayerForPlayer(playerid, targetid, iconid, icontype, color = 0)
  47. {
  48. if((IsPlayerConnected(playerid)) && (IsPlayerConnected(targetid)) && (iconid >= 0) && (iconid <= 100) && (icontype >= 0) && (icontype <= 63))
  49. {
  50. AttachedPlayerIcon[playerid] = 1;
  51. AttachedPlayerIconID[playerid] = iconid;
  52. AttachedPlayerIconType[playerid] = icontype;
  53. AttachedPlayerIconColor[playerid] = color;
  54. AttachedPlayerIconTarget[playerid] = targetid;
  55. GetPlayerPos(playerid, AttachedPlayerIconLastPos[playerid][1], AttachedPlayerIconLastPos[playerid][2], AttachedPlayerIconLastPos[playerid][3]);
  56. }
  57. }
  58. hook OnPlayerUpdate(playerid)
  59. {
  60. if(AttachedPlayerIcon[playerid] == 1)
  61. {
  62. new Float:PlayerPos[4];
  63. GetPlayerPos(playerid, PlayerPos[1], PlayerPos[2], PlayerPos[3]);
  64. if(PlayerPos[1] != AttachedPlayerIconLastPos[playerid][1])
  65. {
  66. RemovePlayerMapIcon(AttachedPlayerIconTarget[playerid], AttachedPlayerIconID[playerid]);
  67. SetPlayerMapIcon(AttachedPlayerIconTarget[playerid], AttachedPlayerIconID[playerid], PlayerPos[1], PlayerPos[2], PlayerPos[3], AttachedPlayerIconType[playerid], AttachedPlayerIconColor[playerid], MAPICON_GLOBAL);
  68. }
  69. else if(PlayerPos[2] != AttachedPlayerIconLastPos[playerid][2])
  70. {
  71. RemovePlayerMapIcon(AttachedPlayerIconTarget[playerid], AttachedPlayerIconID[playerid]);
  72. SetPlayerMapIcon(AttachedPlayerIconTarget[playerid], AttachedPlayerIconID[playerid], PlayerPos[1], PlayerPos[2], PlayerPos[3], AttachedPlayerIconType[playerid], AttachedPlayerIconColor[playerid], MAPICON_GLOBAL);
  73. }
  74. GetPlayerPos(playerid, AttachedPlayerIconLastPos[playerid][1], AttachedPlayerIconLastPos[playerid][2], AttachedPlayerIconLastPos[playerid][3]);
  75. }
  76. }
  77. /*-----------------------------------------------------*/
  78. #include <YSI\y_hooks>
  79. new AttachedPlayerIconEx[MAX_PLAYERS],
  80. AttachedPlayerIconIDEx[MAX_PLAYERS],
  81. AttachedPlayerIconTypeEx[MAX_PLAYERS],
  82. AttachedPlayerIconColorEx[MAX_PLAYERS],
  83. Float:AttachedPlayerIconLastPosEx[MAX_PLAYERS][4];
  84. hook OnPlayerConnect(playerid) { AttachedPlayerIconEx[playerid] = 0; }
  85. hook OnPlayerDisconnect(playerid, reason) { if(AttachedPlayerIconEx[playerid] == 1) for(new targetids = 0; targetids < MAX_PLAYERS; targetids++) if(IsPlayerConnected(targetids)) RemovePlayerMapIcon(targetids, AttachedPlayerIconIDEx[playerid]); }
  86. stock AttachMapIconToPlayerForAll(playerid, iconid, icontype, color = 0)
  87. {
  88. if((IsPlayerConnected(playerid)) && (iconid >= 0) && (iconid <= 100) && (icontype >= 0) && (icontype <= 63))
  89. {
  90. AttachedPlayerIconEx[playerid] = 1;
  91. AttachedPlayerIconIDEx[playerid] = iconid;
  92. AttachedPlayerIconTypeEx[playerid] = icontype;
  93. AttachedPlayerIconColorEx[playerid] = color;
  94. GetPlayerPos(playerid, AttachedPlayerIconLastPosEx[playerid][1], AttachedPlayerIconLastPosEx[playerid][2], AttachedPlayerIconLastPosEx[playerid][3]);
  95. }
  96. }
  97. hook OnPlayerUpdate(playerid)
  98. {
  99. if(AttachedPlayerIconEx[playerid] == 1)
  100. {
  101. new Float:PlayerPos[4];
  102. GetPlayerPos(playerid, PlayerPos[1], PlayerPos[2], PlayerPos[3]);
  103. if(PlayerPos[1] != AttachedPlayerIconLastPosEx[playerid][1])
  104. {
  105. for(new targetids = 0; targetids < MAX_PLAYERS; targetids++)
  106. {
  107. if(IsPlayerConnected(targetids))
  108. {
  109. RemovePlayerMapIcon(targetids, AttachedPlayerIconIDEx[playerid]);
  110. SetPlayerMapIcon(targetids, AttachedPlayerIconIDEx[playerid], PlayerPos[1], PlayerPos[2], PlayerPos[3], AttachedPlayerIconTypeEx[playerid], AttachedPlayerIconColorEx[playerid], MAPICON_GLOBAL);
  111. }
  112. }
  113. }
  114. else if(PlayerPos[2] != AttachedPlayerIconLastPosEx[playerid][2])
  115. {
  116. for(new targetids = 0; targetids < MAX_PLAYERS; targetids++)
  117. {
  118. if(IsPlayerConnected(targetids))
  119. {
  120. RemovePlayerMapIcon(targetids, AttachedPlayerIconIDEx[playerid]);
  121. SetPlayerMapIcon(targetids, AttachedPlayerIconIDEx[playerid], PlayerPos[1], PlayerPos[2], PlayerPos[3], AttachedPlayerIconTypeEx[playerid], AttachedPlayerIconColorEx[playerid], MAPICON_GLOBAL);
  122. }
  123. }
  124. }
  125. GetPlayerPos(playerid, AttachedPlayerIconLastPosEx[playerid][1], AttachedPlayerIconLastPosEx[playerid][2], AttachedPlayerIconLastPosEx[playerid][3]);
  126. }
  127. }
  128. /*-----------------------------------------------------*/
  129. #include <YSI\y_hooks>
  130. forward OnVehicleUpdate(vehicleid);
  131. hook OnVehicleDeath(vehicleid, killerid)
  132. {
  133. CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
  134. }
  135. hook OnVehicleSpawn(vehicleid)
  136. {
  137. CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
  138. }
  139. hook OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  140. {
  141. CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
  142. }
  143. hook OnPlayerExitVehicle(playerid, vehicleid)
  144. {
  145. CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
  146. }
  147. hook OnVehicleDamageStatusUpdate(vehicleid, playerid)
  148. {
  149. CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
  150. }
  151. hook OnVehicleRespray(playerid, vehicleid, color1, color2)
  152. {
  153. CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
  154. }
  155. hook OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  156. {
  157. CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
  158. }
  159. hook OnVehicleMod(playerid, vehicleid, componentid)
  160. {
  161. CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
  162. }
  163. hook OnTrailerUpdate(playerid, vehicleid)
  164. {
  165. CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
  166. }
  167. /*-----------------------------------------------------*/
  168. stock GetVehicleSpeed(vehicleid, meter[])
  169. {
  170. new Float:x,
  171. Float:y,
  172. Float:z,
  173. result;
  174. GetVehicleVelocity(vehicleid, x, y, z);
  175. if(!strcmp(meter, "KM/H"))
  176. result = floatround(floatsqroot(x*x + y*y + z*z) * 180);
  177. else
  178. result = floatround(floatsqroot(x*x + y*y + z*z) * 180 / 1.609344);
  179. return vel;
  180. }
  181. /*-----------------------------------------------------*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement