Guest User

SVRS FS by TonyII

a guest
Sep 26th, 2013
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.63 KB | None | 0 0
  1. //Filterscript by TonyII, do not remove this.
  2. //You are allowed to edit the entire FS except the comment above.
  3. //Includes
  4. #include <a_samp>
  5. #include <zcmd>
  6. //Variables
  7. new Bomb[MAX_PLAYERS];
  8. new FBTimer;
  9. new CountTime;
  10. new Counting;
  11. new BagTime;
  12. new BagCounting;
  13. new VanMoved;
  14. new SMoney;
  15. new DetonateBomb[MAX_PLAYERS];
  16. new SecurityVanID[MAX_PLAYERS];
  17. new SVBeingRobbed[MAX_VEHICLES];
  18. new FullBag[MAX_PLAYERS];
  19. new MoneyLeft[MAX_VEHICLES];
  20. new Float:VanX,Float:VanY,Float:VanZ;
  21. //Forwards
  22. forward VanMovedTimer(playerid,Float:X,Float:Y,Float:Z);
  23. forward FillingBags(playerid);
  24. forward SecureMoney(playerid);
  25. //Publics
  26. public OnFilterScriptInit()
  27. {
  28. print("\n--------------------------------------");
  29. print("Security Van rob system. [By TonyII]");
  30. print("--------------------------------------\n");
  31. return 1;
  32. }
  33.  
  34. public OnFilterScriptExit()
  35. {
  36. return 1;
  37. }
  38.  
  39. public OnPlayerDeath(playerid, killerid, reason)
  40. {
  41. if(FullBag[playerid] == 1)
  42. {
  43. GivePlayerMoney(playerid, -100000);
  44. KillTimer(SMoney);
  45. FullBag[playerid] = 0;
  46. SendClientMessage(playerid, -1,"You failed the robbery, you died.");
  47. }
  48. return 1;
  49. }
  50.  
  51. public VanMovedTimer(playerid)
  52. {
  53. new Float:X,Float:Y,Float:Z;
  54. if(!Counting)
  55. {
  56. KillTimer(VanMoved);
  57. Bomb[playerid] = 0;
  58. DetonateBomb[playerid] = 1;
  59. SendClientMessage(playerid, -1,"Alright, the bomb is planted.[/detonatebomb]");
  60. //ClearAnimations
  61. }
  62. else
  63. {
  64. new SVID = SecurityVanID[playerid];
  65. GetVehiclePos(SVID, X,Y,Z);
  66. if(X == VanX && Y == VanY && Z == VanZ)
  67. {
  68. new string[128];
  69. format(string,sizeof(string),"%i",CountTime);
  70. GameTextForPlayer(playerid,string,1000,5);
  71. CountTime --;
  72. if(CountTime == 0)
  73. {
  74. Counting = 0;
  75. }
  76. }
  77. else
  78. {
  79. KillTimer(VanMoved);
  80. SendClientMessage(playerid, -1,"The van moved while planting the bomb!");
  81. }
  82. }
  83. return 1;
  84. }
  85.  
  86. public SecureMoney(playerid)
  87. {
  88. SendClientMessage(playerid, -1,"The money is secure now.");
  89. FullBag[playerid] = 0;
  90. KillTimer(SMoney);
  91. return 1;
  92. }
  93.  
  94. public FillingBags(playerid)
  95. {
  96. if(!BagCounting)
  97. {
  98. KillTimer(FBTimer);
  99. FullBag[playerid] = 1;
  100. GivePlayerMoney(playerid, 100000);
  101. SendClientMessage(playerid, -1,"Your bag is full, your bag contains $100,000");
  102. SendClientMessage(playerid, -1,"Leave the area, if you die you lose the money![10 minutes untill the money is secure]");
  103. //ClearAnimations
  104. SMoney = SetTimerEx("SecureMoney",600000,false,"i",playerid);
  105. }
  106. else
  107. {
  108. new string[128];
  109. format(string,sizeof(string),"%i",BagTime);
  110. GameTextForPlayer(playerid,string,1000,5);
  111. BagTime --;
  112. if(BagTime == 0)
  113. {
  114. BagCounting = 0;
  115. }
  116. }
  117. return 1;
  118. }
  119. //Stocks
  120. stock SecurityVan(vehicleid)
  121. {
  122. switch(GetVehicleModel(vehicleid))
  123. {
  124. case 428: return 1;
  125. }
  126. return 0;
  127. }
  128.  
  129. stock GetDistanceToCar(playerid, veh, Float: posX = 0.0, Float: posY = 0.0, Float: posZ = 0.0)
  130. {
  131. new Float: Floats[2][3];
  132. if(posX == 0.0 && posY == 0.0 && posZ == 0.0)
  133. {
  134. if(!IsPlayerInAnyVehicle(playerid)) GetPlayerPos(playerid, Floats[0][0], Floats[0][1], Floats[0][2]);
  135. else GetVehiclePos(GetPlayerVehicleID(playerid), Floats[0][0], Floats[0][1], Floats[0][2]);
  136. }
  137. else
  138. {
  139. Floats[0][0] = posX;
  140. Floats[0][1] = posY;
  141. Floats[0][2] = posZ;
  142. }
  143. GetVehiclePos(veh, Floats[1][0], Floats[1][1], Floats[1][2]);
  144. return floatround(floatsqroot((Floats[1][0] - Floats[0][0]) * (Floats[1][0] - Floats[0][0]) + (Floats[1][1] - Floats[0][1]) * (Floats[1][1] - Floats[0][1]) + (Floats[1][2] - Floats[0][2]) * (Floats[1][2] - Floats[0][2])));
  145. }
  146.  
  147. stock GetClosestCar(playerid, exception = INVALID_VEHICLE_ID)
  148. {
  149. new Float: Distance,target = -1,Float: vPos[3];
  150. if(!IsPlayerInAnyVehicle(playerid)) GetPlayerPos(playerid, vPos[0], vPos[1], vPos[2]);
  151. else GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
  152. for(new v; v < MAX_VEHICLES; v++) if(GetVehicleModel(v) >= 400)
  153. {
  154. if(v != exception && (target < 0 || Distance > GetDistanceToCar(playerid, v, vPos[0], vPos[1], vPos[2])))
  155. {
  156. target = v;
  157. Distance = GetDistanceToCar(playerid, v, vPos[0], vPos[1], vPos[2]);
  158. }
  159. }
  160. return target;
  161. }
  162. //Commands
  163. CMD:buybomb(playerid, params[])
  164. {
  165. if(GetPlayerMoney(playerid) <= 10000) return SendClientMessage(playerid, -1,"Insufficient funds.");
  166. if(Bomb[playerid] == 1) return SendClientMessage(playerid, -1,"You already got a bomb.");
  167. Bomb[playerid] = 1;
  168. SendClientMessage(playerid, -1,"You've successfully bought a bomb.");
  169. SendClientMessage(playerid, -1,"Get close to a Security Van and plant it on the rear doors.[/plantbomb]");
  170. GivePlayerMoney(playerid, -10000);
  171. return 1;
  172. }
  173.  
  174. CMD:plantbomb(playerid, params[])
  175. {
  176. new ClosestCar = GetClosestCar(playerid);
  177. GetVehiclePos(ClosestCar, VanX,VanY,VanZ);
  178. if(Bomb[playerid] == 0) return SendClientMessage(playerid, -1,"You don't have a bomb.");
  179. if(IsPlayerInRangeOfPoint(playerid, 7.0, VanX,VanY,VanZ))
  180. {
  181. if(SecurityVan(ClosestCar))
  182. {
  183. SecurityVanID[playerid] = ClosestCar;
  184. VanMoved = SetTimerEx("VanMovedTimer",1000,true,"i",playerid);
  185. CountTime = 5;
  186. Counting = 1;
  187. SendClientMessage(playerid, -1,"You're planting the bomb!");
  188. //ApplyAnimation
  189. }
  190. else return SendClientMessage(playerid, -1,"This vehicle isn't a Security Van.");
  191. }
  192. else return SendClientMessage(playerid, -1,"There aren't any Security Vans near.");
  193. return 1;
  194. }
  195.  
  196. CMD:detonatebomb(playerid, params[])
  197. {
  198. new Float:X,Float:Y,Float:Z;
  199. if(DetonateBomb[playerid] == 1)
  200. {
  201. new SVID = SecurityVanID[playerid];
  202. GetVehiclePos(SVID, X,Y,Z);
  203. CreateExplosion(X, Y, Z, 7, 10);
  204. SetVehicleHealth(SVID, 350);
  205. SVBeingRobbed[SVID] = 1;
  206. DetonateBomb[playerid] = 0;
  207. MoneyLeft[SVID] = 5;
  208. SendClientMessage(playerid, -1,"The bomb went off, fill the bags and get out of here![/fillbags]");
  209. }
  210. else return SendClientMessage(playerid, -1,"You don't have a bomb planted anywhere.");
  211. return 1;
  212. }
  213.  
  214. CMD:fillbags(playerid, params[])
  215. {
  216. new ClosestCar = GetClosestCar(playerid);
  217. if(BagCounting == 1) return SendClientMessage(playerid, -1,"You're filling your bags already!");
  218. if(MoneyLeft[ClosestCar] == 0) return SendClientMessage(playerid, -1,"This van is empty!");
  219. if(FullBag[playerid] == 1) return SendClientMessage(playerid, -1,"Your bags are full!");
  220. if(SVBeingRobbed[ClosestCar] == 1)
  221. {
  222. SendClientMessage(playerid, -1,"You're filling your bags with money.");
  223. FBTimer = SetTimerEx("FillingBags",1000,true,"i",playerid);
  224. BagTime = 5;
  225. BagCounting = 1;
  226. MoneyLeft[ClosestCar] -= 1;
  227. //ApplyAnimation
  228. }
  229. else return SendClientMessage(playerid, -1,"This van isn't being robbed.");
  230. return 1;
  231. }
Advertisement
Add Comment
Please, Sign In to add comment