Guest User

laser pointer

a guest
Jul 25th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.57 KB | None | 0 0
  1. #include <a_samp>
  2. #include <foreach>
  3. #include <sscanf2>
  4. #include <zcmd>
  5.  
  6. //====================================================
  7.  
  8. #define C_GREY 0xAFAFAFAA
  9. #define C_VIOLET 0x9955DEEE
  10.  
  11. //====================================================
  12.  
  13. public OnFilterScriptInit()
  14. {
  15. foreach(new i: Player)
  16. {
  17. SetPVarInt(i, "laser", 0);
  18. SetPVarInt(i, "color", 18643);
  19. }
  20. return 1;
  21. }
  22.  
  23. public OnFilterScriptExit()
  24. {
  25. foreach(new i: Player)
  26. {
  27. SetPVarInt(i, "laser", 0);
  28. RemovePlayerAttachedObject(i, 0);
  29. }
  30. return 1;
  31. }
  32.  
  33. //====================================================
  34.  
  35. public OnPlayerSpawn(playerid)
  36. {
  37. if (!GetPVarInt(playerid, "color")) SetPVarInt(playerid, "color", 18643);
  38. SetPVarInt(playerid, "laser", 1);
  39. SetPVarInt(playerid, "color", GetPVarInt(playerid, "color"));
  40. }
  41.  
  42. public OnPlayerDisconnect(playerid)
  43. {
  44. RemovePlayerAttachedObject(playerid, 0);
  45. return 1;
  46. }
  47.  
  48. //====================================================
  49.  
  50.  
  51. /*CMD:lasercol(playerid, params[])
  52. {
  53. new color[16];
  54. if(sscanf(params, "s[15]", color)) return SendClientMessage(playerid, C_GREY, "USAGE: /lasercol [color]");
  55.  
  56. if(!strcmp(color, "red", true)) SetPVarInt(playerid, "color", 18643);
  57. else if(!strcmp(color, "blue", true)) SetPVarInt(playerid, "color", 19080);
  58. else if(!strcmp(color, "pink", true)) SetPVarInt(playerid, "color", 19081);
  59. else if(!strcmp(color, "orange", true)) SetPVarInt(playerid, "color", 19082);
  60. else if(!strcmp(color, "green", true)) SetPVarInt(playerid, "color", 19083);
  61. else if(!strcmp(color, "yellow", true)) SetPVarInt(playerid, "color", 19084);
  62. else SendClientMessage(playerid, C_VIOLET, "Color not available!");
  63. return 1;
  64. }*/
  65.  
  66. public OnPlayerUpdate(playerid)
  67. {
  68. if(GetPVarInt(playerid, "laser") == 1)
  69. {
  70. RemovePlayerAttachedObject(playerid, 0);
  71. if ((IsPlayerInAnyVehicle(playerid)) || (IsPlayerInWater(playerid))) return 1;
  72. switch (GetPlayerWeapon(playerid))
  73. {
  74. case 23:
  75. {
  76. if (IsPlayerAiming(playerid))
  77. {
  78. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  79. {
  80. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SP standing aiming
  81. 0.108249, 0.030232, 0.118051, 1.468254, 350.512573, 364.284240);
  82. }
  83. else
  84. {
  85. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SP crouched aiming
  86. 0.108249, 0.030232, 0.118051, 1.468254, 349.862579, 364.784240);
  87. }
  88. }
  89. else
  90. {
  91. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  92. {
  93. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SP standing not aiming
  94. 0.078248, 0.027239, 0.113051, -11.131746, 350.602722, 362.384216);
  95. }
  96. else
  97. {
  98. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SP crouched not aiming
  99. 0.078248, 0.027239, 0.113051, -11.131746, 350.602722, 362.384216);
  100. }
  101. }
  102. }
  103. case 27:
  104. {
  105. if (IsPlayerAiming(playerid))
  106. {
  107. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  108. {
  109. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SPAS standing aiming
  110. 0.588246, -0.022766, 0.138052, -11.531745, 347.712585, 352.784271);
  111. }
  112. else
  113. {
  114. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SPAS crouched aiming
  115. 0.588246, -0.022766, 0.138052, 1.468254, 350.712585, 352.784271);
  116. }
  117. }
  118. else
  119. {
  120. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  121. {
  122. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SPAS standing not aiming
  123. 0.563249, -0.01976, 0.134051, -11.131746, 351.602722, 351.384216);
  124. }
  125. else
  126. {
  127. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SPAS crouched not aiming
  128. 0.563249, -0.01976, 0.134051, -11.131746, 351.602722, 351.384216);
  129. }
  130. }
  131. }
  132. case 30:
  133. {
  134. if (IsPlayerAiming(playerid))
  135. {
  136. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  137. {
  138. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // AK standing aiming
  139. 0.628249, -0.027766, 0.078052, -6.621746, 352.552642, 355.084289);
  140. }
  141. else
  142. {
  143. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // AK crouched aiming
  144. 0.628249, -0.027766, 0.078052, -1.621746, 356.202667, 355.084289);
  145. }
  146. }
  147. else
  148. {
  149. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  150. {
  151. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // AK standing not aiming
  152. 0.663249, -0.02976, 0.080051, -11.131746, 358.302734, 353.384216);
  153. }
  154. else
  155. {
  156. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // AK crouched not aiming
  157. 0.663249, -0.02976, 0.080051, -11.131746, 358.302734, 353.384216);
  158. }
  159. }
  160. }
  161. case 31:
  162. {
  163. if (IsPlayerAiming(playerid))
  164. {
  165. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  166. {
  167. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // M4 standing aiming
  168. 0.528249, -0.020266, 0.068052, -6.621746, 352.552642, 355.084289);
  169. }
  170. else
  171. {
  172. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // M4 crouched aiming
  173. 0.528249, -0.020266, 0.068052, -1.621746, 356.202667, 355.084289);
  174. }
  175. }
  176. else
  177. {
  178. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  179. {
  180. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // M4 standing not aiming
  181. 0.503249, -0.02376, 0.065051, -11.131746, 357.302734, 354.484222);
  182. }
  183. else
  184. {
  185. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // M4 crouched not aiming
  186. 0.503249, -0.02376, 0.065051, -11.131746, 357.302734, 354.484222);
  187. }
  188. }
  189. }
  190. /*case 34:
  191. {
  192. if (IsPlayerAiming(playerid))
  193. {
  194. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  195. {
  196. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // Sniper standing aiming
  197. 0.528249, -0.020266, 0.068052, -6.621746, 352.552642, 355.084289);
  198. }
  199. else
  200. {
  201. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // Sniper crouched aiming
  202. 0.528249, -0.020266, 0.068052, -1.621746, 356.202667, 355.084289);
  203. }
  204. }
  205. else
  206. {
  207. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  208. {
  209. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // Sniper standing not aiming
  210. 0.658248, -0.03276, 0.133051, -11.631746, 355.302673, 353.584259);
  211. }
  212. else
  213. {
  214. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // Sniper crouched not aiming
  215. 0.658248, -0.03276, 0.133051, -11.631746, 355.302673, 353.584259);
  216. }
  217. }
  218. }*/
  219. case 29:
  220. {
  221. if (IsPlayerAiming(playerid))
  222. {
  223. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  224. {
  225. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // MP5 standing aiming
  226. 0.298249, -0.02776, 0.158052, -11.631746, 359.302673, 357.584259);
  227. }
  228. else
  229. {
  230. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // MP5 crouched aiming
  231. 0.298249, -0.02776, 0.158052, 8.368253, 358.302673, 352.584259);
  232. }
  233. }
  234. else
  235. {
  236. if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK)
  237. {
  238. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // MP5 standing not aiming
  239. 0.293249, -0.027759, 0.195051, -12.131746, 354.302734, 352.484222);
  240. }
  241. else
  242. {
  243. SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // MP5 crouched not aiming
  244. 0.293249, -0.027759, 0.195051, -12.131746, 354.302734, 352.484222);
  245. }
  246. }
  247. }
  248. }
  249. }
  250. return 1;
  251. }
  252.  
  253. stock IsPlayerInWater(playerid)
  254. {
  255. new anim = GetPlayerAnimationIndex(playerid);
  256. if (((anim >= 1538) && (anim <= 1542)) || (anim == 1544) || (anim == 1250) || (anim == 1062)) return 1;
  257. return 0;
  258. }
  259.  
  260. stock IsPlayerAiming(playerid)
  261. {
  262. new anim = GetPlayerAnimationIndex(playerid);
  263. if (((anim >= 1160) && (anim <= 1163)) || (anim == 1167) || (anim == 1365) || (anim == 1643) || (anim == 1453) || (anim == 220)) return 1;
  264. return 0;
  265. }
Advertisement
Add Comment
Please, Sign In to add comment