Guest User

Untitled

a guest
Jun 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.86 KB | None | 0 0
  1. #include <a_samp>
  2. #include <bfx_objects>
  3.  
  4. /*
  5. Scriptname : S.W.A.T Rope
  6. Version : 1.0
  7. Copyright : Trooper (c) 2009
  8. Release : German & English
  9. Credits : Blackfox_UD -> Streamer
  10. */
  11.  
  12. //Easy Edit Section
  13. #define howmanyropes 20 //how many ropes server should contain (increasing number,decreases server power)
  14. #define zcatchtimer 1200 //in ms, time to calculate height
  15. #define r_maxping 275 //highest ping of sliding units, dont set too high, or death-bugs will increase
  16. #define falltime 25 //low = the best, but beware of server weakness (25 isnt incredible high, think, that you slide around 2-5 secs)
  17. #define ropelength 100 //in meter, after what amount of meters you start falling (and rope ends)... Increasing will take server power and realism
  18. #define abfangen 6 //at what height above ground should player get stopped ?
  19.  
  20. // DO NOT EDIT BELOW, IF YOU DO NOT KNOW, WHATS IT !
  21.  
  22. new Float:tempx[MAX_PLAYERS],Float:tempy[MAX_PLAYERS],Float:tempz[MAX_PLAYERS],Float:tempa[MAX_PLAYERS];
  23. new Float:lowz[MAX_PLAYERS],vworld[MAX_PLAYERS],chopper[MAX_PLAYERS];
  24. new Float:tx[MAX_PLAYERS],Float:ty[MAX_PLAYERS],Float:tz[MAX_PLAYERS],Text:blind;
  25. new Float:helix[MAX_PLAYERS],Float:heliy[MAX_PLAYERS],Float:heliz[MAX_PLAYERS];
  26. new seile[9999][MAX_PLAYERS],issliding[MAX_PLAYERS],tempplayerid[MAX_PLAYERS],notstarted[MAX_PLAYERS];
  27. forward lowzcatch(playerid,Float:x2,Float:y2,Float:z2);
  28. forward SetPosTimer(playerid);
  29. forward OnPlayerUpdate(playerid);
  30. forward checkseil(heliid,Float:seilx,Float:seily,Float:seilz);
  31. #define COLOR_GREY 0xAFAFAFAA
  32. #define COLOR_GREEN 0x33AA33AA
  33. #define COLOR_RED 0xAA3333AA
  34. #define COLOR_ORANGE 0xFF9900FF
  35. #define COLOR_BLUE 0x0000FF00
  36.  
  37.  
  38. public OnFilterScriptInit()
  39. {
  40. TextDrawUseBox(blind,1);
  41. TextDrawBoxColor(blind,0x000000FF);
  42. TextDrawTextSize(blind,641.000000,10.000000);
  43. TextDrawAlignment(blind,0);
  44. TextDrawBackgroundColor(blind,0x00000000);
  45. TextDrawFont(blind,3);
  46. TextDrawLetterSize(blind,1.000000,51.000000);
  47. TextDrawColor(blind,0x000000AA);
  48. TextDrawSetOutline(blind,1);
  49. TextDrawSetProportional(blind,1);
  50. TextDrawSetShadow(blind,1);
  51. print("\n--------------------------------------");
  52. print(" Rope RC1 v1 (c) Trooper 2009");
  53. print("--------------------------------------\n");
  54. for(new p=0; p<howmanyropes; p++)
  55. {
  56. for(new i=0; i<ropelength; i++)
  57. { //alte model id = 338
  58. seile[p] = b_CreateObject(3004,0,0,-90000-i,87.640026855469,342.13500976563, 350.07507324219);
  59. }
  60. }
  61. return 1;
  62. }
  63.  
  64. public OnFilterScriptExit()
  65. {
  66. TextDrawDestroy(blind);
  67. for(new p=0; p<howmanyropes; p++)
  68. {
  69. for(new i=0; i<ropelength; i++)
  70. {
  71. b_DestroyObject(seile[p]);
  72. }
  73. }
  74. return 1;
  75. }
  76.  
  77. public OnPlayerConnect(playerid)
  78. {
  79. issliding[playerid] = 0,tempplayerid[playerid] = -1,notstarted[playerid] = 0;
  80. return 1;
  81. }
  82.  
  83. public OnPlayerDisconnect(playerid, reason)
  84. {
  85. TextDrawHideForPlayer(playerid,blind);
  86. b_PlayerDisconnect(playerid);
  87. return 1;
  88. }
  89.  
  90. public OnPlayerUpdate(playerid)
  91. {
  92. b_OnPlayerUpdate(playerid);
  93. return 1;
  94. }
  95.  
  96. public OnPlayerSpawn(playerid)
  97. {
  98. return 1;
  99. }
  100.  
  101. public OnPlayerDeath(playerid, killerid, reason)
  102. {
  103. if(issliding[playerid] != 0)
  104. {
  105. //OnPlayerDeathBug
  106.  
  107. //end
  108. SendClientMessage(playerid,COLOR_ORANGE,"Your hands got off the rope. Try again .");
  109. for(new i=0; i<ropelength; i++)
  110. {
  111. b_SetObjectPos(seile[tempplayerid[playerid]],0,0,-90000);
  112. notstarted[playerid] = 0;
  113. }
  114. issliding[playerid] = 0;
  115. issliding[tempplayerid[playerid]] = 0;
  116. ClearAnimations(playerid);
  117. }
  118. return 1;
  119. }
  120.  
  121. public checkseil(heliid,Float:seilx,Float:seily,Float:seilz)
  122. {
  123. if(!HeliToPoint(5,heliid,seilx,seily,seilz))
  124. {
  125. for(new p=0; p<MAX_PLAYERS; p++) // seil reißen
  126. {
  127. if(IsPlayerConnected(p) && issliding[p] == heliid)
  128. {
  129. //OnPlayerSnatchRope
  130.  
  131. //end
  132. issliding[p] = 0;
  133. GameTextForPlayer(p,"Rope snatched",1000,1);
  134. ClearAnimations(p);
  135. notstarted[p] = 0;
  136. issliding[tempplayerid[p]] = 0;
  137. for(new i=0; i<ropelength; i++)
  138. {
  139. b_SetObjectPos(seile[tempplayerid[p]],0,0,-90000+i);
  140. }
  141. }
  142. }
  143. }
  144. else
  145. {
  146. SetTimerEx("checkseil",500,0,"ifff",heliid,seilx,seily,seilz);
  147. }
  148. return 1;
  149. }
  150.  
  151. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  152. {
  153. if(newkeys == KEY_SUBMISSION && GetPlayerState(playerid) == 3 && issliding[playerid] == 0 && notstarted[playerid] == 0)
  154. {
  155. if(GetPlayerPing(playerid) > r_maxping) { return GameTextForPlayer(playerid,"Zu hoher Ping !",1000,1); }
  156. if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 548 && GetPlayerSkin(playerid) == 285)
  157. {
  158. //OnPlayerStartSliding (use for other conditions)
  159.  
  160. //end
  161. for(new p=0; p<howmanyropes; p++)
  162. {
  163. if(issliding[p] == 0) { tempplayerid[playerid] = p; }
  164. }
  165. if(tempplayerid[playerid] == -1) { return GameTextForPlayer(playerid,"Technical Problem",1000,1); }
  166.  
  167. GetVehiclePos(GetPlayerVehicleID(playerid),helix[playerid],heliy[playerid],heliz[playerid]);
  168. issliding[playerid] = GetPlayerVehicleID(playerid);
  169. issliding[tempplayerid[playerid]] = 1;
  170. notstarted[playerid] = 2;
  171. GetPlayerPos(playerid,tempx[playerid],tempy[playerid],tempz[playerid]); //alte position speichern
  172. GetPlayerFacingAngle(playerid,tempa[playerid]);
  173. SetTimerEx("checkseil",1000,0,"ifff",GetPlayerVehicleID(playerid),helix[playerid],heliy[playerid],heliz[playerid]);
  174. vworld[playerid] = GetPlayerVirtualWorld(playerid);
  175. RemovePlayerFromVehicle(playerid); //spieler aus heli raus
  176. SetPlayerVirtualWorld(playerid,10);
  177. ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,0); //animation startem
  178. SetVehiclePos(chopper[playerid],tempx[playerid],tempy[playerid],tempz[playerid]);
  179. SetPlayerPosFindZ(playerid,tempx[playerid],tempy[playerid],tempz[playerid]);
  180. SetPlayerCameraPos(playerid,tempx[playerid],tempy[playerid]+10,tempz[playerid]+10);
  181. SetPlayerCameraLookAt(playerid,helix[playerid],heliy[playerid],heliz[playerid]);
  182. TextDrawShowForPlayer(playerid,blind);
  183. SetTimerEx("lowzcatch",zcatchtimer,0,"ifff",playerid,tempx[playerid],tempy[playerid],tempz[playerid]);
  184.  
  185. //OnCalculateZ (use for messages or optical things)
  186.  
  187. //end
  188.  
  189. for(new i=0; i<ropelength; i++)
  190. {
  191. b_SetObjectPos(seile[tempplayerid[playerid]],tempx[playerid],tempy[playerid],tempz[playerid] - i);
  192. }
  193. return 1;
  194. }
  195. return 0;
  196. }
  197. if(newkeys == KEY_SUBMISSION && GetPlayerState(playerid) == 3 && issliding[playerid] != 0 && notstarted[playerid] == 1)
  198. {
  199. //OnPlayerLetFall
  200.  
  201. //end
  202. new Float:landex,Float:landey,Float:landez;
  203. GetPlayerPos(playerid,landex,landey,landez);
  204. SetPlayerPos(playerid,landex,landey,landez);
  205. issliding[playerid] = 0;
  206. issliding[tempplayerid[playerid]] = 0;
  207. notstarted[playerid] = 0;
  208. GameTextForPlayer(playerid,"You let yourself falling",1000,1);
  209. for(new i=0; i<ropelength; i++)
  210. {
  211. b_SetObjectPos(seile[tempplayerid[playerid]],tempx[playerid],tempy[playerid],tempz[playerid] - i);
  212. }
  213. return 1;
  214. }
  215. return 1;
  216. }
  217.  
  218. /* UNCOMMENT IF YOU WANT TO TEST IT
  219. public OnPlayerCommandText(playerid, cmdtext&#91;])
  220. {
  221. if (strcmp("/heli", cmdtext, true, 5) == 0)
  222. {
  223. new Float:x1,Float:y1,Float:z1;
  224. GetPlayerPos(playerid,x1,y1,z1);
  225. CreateVehicle(548,x1+3,y1+3,z1,0,0,0,9999);
  226. return 1;
  227. }
  228. if (strcmp("/test", cmdtext, true, 5) == 0)
  229. {
  230. SetPlayerPosFindZ(playerid,0,0,1000);
  231. SetPlayerSkin(playerid,285);
  232. return 1;
  233. }
  234. return 0;
  235. }
  236. */
  237.  
  238.  
  239. public SetPosTimer(playerid)
  240. {
  241. if(issliding[playerid] == 0) { return 0; }
  242. //OnPlayerCheck
  243.  
  244. //end
  245. GetPlayerPos(playerid,tx[playerid],ty[playerid],tz[playerid]);
  246. if(tz[playerid]-lowz[playerid] < abfangen && tz[playerid]-lowz[playerid] > -abfangen)
  247. {
  248. //OnPlayerReady
  249.  
  250. //end
  251. new Float:temphealth;
  252. GetPlayerHealth(playerid,temphealth);
  253. if(temphealth <= 0) { return 0; }
  254. ClearAnimations(playerid);
  255. SetPlayerPos(playerid,tx[playerid],ty[playerid],tz[playerid]);
  256. issliding[playerid] = 0;
  257. notstarted[playerid] = 0;
  258. issliding[tempplayerid[playerid]] = 0;
  259. for(new i=0; i<ropelength; i++)
  260. {
  261. b_SetObjectPos(seile[tempplayerid[playerid]],0,0,-90000-i);
  262. }
  263. return 1;
  264. }
  265. if(heliz[playerid]-tz[playerid] > ropelength)
  266. {
  267. //OnPlayerRopeEnd
  268.  
  269. //end
  270. ClearAnimations(playerid);
  271. issliding[playerid] = 0;
  272. notstarted[playerid] = 0;
  273. issliding[tempplayerid[playerid]] = 0;
  274. GameTextForPlayer(playerid,"Ropes over",1000,1);
  275. for(new i=0; i<ropelength; i++)
  276. {
  277. b_SetObjectPos(seile[tempplayerid[playerid]],0,0,-90000-i);
  278. }
  279. return 1;
  280. }
  281. ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,0);
  282. SetTimerEx("SetPosTimer",falltime,0,"i",playerid);
  283. return 1;
  284. }
  285.  
  286. stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  287. {
  288. new Float:oldposx, Float:oldposy, Float:oldposz;
  289. new Float:tempposx, Float:tempposy, Float:tempposz;
  290. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  291. tempposx = (oldposx -x);
  292. tempposy = (oldposy -y);
  293. tempposz = (oldposz -z);
  294. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  295. {
  296. return 1;
  297. }
  298. return 0;
  299. }
  300.  
  301. stock ObjectToPoint(Float:radi, objectid, Float:x, Float:y, Float:z)
  302. {
  303. new Float:oldposx, Float:oldposy, Float:oldposz;
  304. new Float:tempposx, Float:tempposy, Float:tempposz;
  305. GetObjectPos(playerid, oldposx, oldposy, oldposz);
  306. tempposx = (oldposx -x);
  307. tempposy = (oldposy -y);
  308. tempposz = (oldposz -z);
  309. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  310. {
  311. return 1;
  312. }
  313. return 0;
  314. }
  315.  
  316. stock HeliToPoint(Float:radi, heliid, Float:x, Float:y, Float:z)
  317. {
  318. new Float:oldposx, Float:oldposy, Float:oldposz;
  319. new Float:tempposx, Float:tempposy, Float:tempposz;
  320. GetVehiclePos(heliid, oldposx, oldposy, oldposz);
  321. tempposx = (oldposx -x);
  322. tempposy = (oldposy -y);
  323. tempposz = (oldposz -z);
  324. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  325. {
  326. return 1;
  327. }
  328. return 0;
  329. }
  330.  
  331. public lowzcatch(playerid,Float:x2,Float:y2,Float:z2)
  332. {
  333. new Float:unsinnx[MAX_PLAYERS],Float:unsinny[MAX_PLAYERS];
  334. GetPlayerPos(playerid,unsinnx[playerid],unsinny[playerid],lowz[playerid]);
  335. SetPlayerPos(playerid,unsinnx[playerid],unsinny[playerid],z2-2);
  336. SetCameraBehindPlayer(playerid);
  337. SetPlayerVirtualWorld(playerid,vworld[playerid]);
  338. TextDrawHideForPlayer(playerid,blind);
  339. SetVehiclePos(chopper[playerid],unsinnx[playerid],unsinny[playerid],z2);
  340. SetTimerEx("SetPosTimer",300,0,"i",playerid);
  341. notstarted[playerid] = 1;
  342. return 1;
  343. }
Add Comment
Please, Sign In to add comment