Guest User

Untitled

a guest
Sep 3rd, 2012
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1.  
  2.  
  3. #define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7.  
  8. #define COLOR_WHITE 0xFFFFFFAA
  9.  
  10.  
  11. new SeatbeltStatus[MAX_PLAYERS];
  12.  
  13. public OnPlayerConnect(playerid) {
  14. SeatbeltStatus[playerid] = 0;
  15. return 1;
  16. }
  17.  
  18. public OnFilterScriptInit()
  19. {
  20. print("\n---------------------------------------------------------");
  21. print(" Seatbelt System for Roleplay. Dafuq's second Fs. ");
  22. print("---------------------------------------------------------\n");
  23. return 1;
  24. }
  25.  
  26. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  27. {
  28. SeatbeltStatus[playerid] = 0;
  29. }
  30.  
  31. public OnPlayerExitVehicle(playerid, vehicleid)
  32. {
  33. new string[50 + MAX_PLAYER_NAME];
  34. if(SeatbeltStatus[playerid] == 1)
  35. {
  36. format(string, sizeof(string), "* %s reaches for their seatbelt, and unbuckles it.", GetPlayerNameEx(playerid));
  37. SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
  38. SendClientMessage(playerid, COLOR_WHITE, "You have taken off your seatbelt.");
  39. }
  40. return 1;
  41. }
  42.  
  43.  
  44. CMD:seatbelt(playerid, params[])
  45. {
  46. if(IsPlayerInAnyVehicle(playerid) == 0)
  47. {
  48. SendClientMessage(playerid, COLOR_WHITE, "You are not in a vehicle!");
  49. return 1;
  50. }
  51. new string[50 + MAX_PLAYER_NAME];
  52. if(IsPlayerInAnyVehicle(playerid) == 1 && SeatbeltStatus[playerid] == 0)
  53. {
  54. SeatbeltStatus[playerid] = 1;
  55. if(IsAMotorBike(GetPlayerVehicleID(playerid)))
  56. {
  57. format(string, sizeof(string), "* %s reaches for their helmet, and puts it on.", GetPlayerNameEx(playerid));
  58. SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
  59. SendClientMessage(playerid, COLOR_WHITE, "You have put on your helmet.");
  60. }
  61. else
  62. {
  63. format(string, sizeof(string), "* %s reaches for their seatbelt, and buckles it up.", GetPlayerNameEx(playerid));
  64. SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
  65. SendClientMessage(playerid, COLOR_WHITE, "You have put on your seatbelt.");
  66. }
  67.  
  68. }
  69. else if(IsPlayerInAnyVehicle(playerid) == 1 && SeatbeltStatus[playerid] == 1)
  70. {
  71. SeatbeltStatus[playerid] = 0;
  72. if(IsAMotorBike(GetPlayerVehicleID(playerid)))
  73. {
  74. format(string, sizeof(string), "* %s reaches for their helmet, and takes it off.", GetPlayerNameEx(playerid));
  75. SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
  76. SendClientMessage(playerid, COLOR_WHITE, "You have taken off your helmet.");
  77. }
  78. else
  79. {
  80. format(string, sizeof(string), "* %s reaches for their seatbelt, and unbuckles it.", GetPlayerNameEx(playerid));
  81. SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
  82. SendClientMessage(playerid, COLOR_WHITE, "You have taken off your seatbelt.");
  83. }
  84. }
  85. return 1;
  86. }
  87.  
  88. CMD:checkseatbelt(playerid, params[])
  89. {
  90. if(SeatbeltStatus[playerid] == 1)
  91. {
  92. SendClientMessage(playerid, 0xFFFF00AA, "You have your seatbelt on.");
  93. }
  94. else
  95. {
  96. SendClientMessage(playerid, 0xFFFF00AA, "Your seatbelt is off !! Put it on fast before you crash your car.");
  97. }
  98. return 1;
  99. }
  100.  
  101. stock GetPlayerNameEx(playerid) {
  102.  
  103. new
  104. sz_playerName[MAX_PLAYER_NAME],
  105. i_pos;
  106.  
  107. GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  108. while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
  109. return sz_playerName;
  110. }
  111.  
  112.  
  113. stock IsAMotorBike(carid) {
  114. switch(GetVehicleModel(carid)) {
  115. case 509, 510, 462, 448, 581, 522, 461, 521, 523, 463, 586, 468, 471: return 1;
  116. }
  117. return 0;
  118. }
  119.  
  120.  
  121. stock SCBubble(playerid,stringtext[],bool:selftext,color,range,time)
  122. {
  123. SetPlayerChatBubble(playerid,stringtext,color,range,time);
  124. if(selftext)
  125. {
  126. if(strlen(stringtext) > 64)
  127. {
  128. new strings1[65];
  129. strmid(strings1,stringtext,64,128);
  130. strdel(stringtext,64,128);
  131. format(stringtext,66,"%s-",stringtext);
  132. format(strings1,66,"-%s",strings1);
  133. SendClientMessage(playerid,color,stringtext);
  134. SendClientMessage(playerid,color,strings1);
  135. }
  136. else SendClientMessage(playerid,color,stringtext);
  137. }
  138. return 1;
  139. }
  140.  
  141. new Float:CarHealth[MAX_PLAYERS];
  142. public OnPlayerUpdate(playerid)
  143. {
  144. if(IsPlayerInAnyVehicle(playerid) == 1 && SeatbeltStatus[playerid] == 0)
  145. {
  146. new Float:TempCarHealth;
  147. GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
  148. new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
  149. if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
  150. {
  151. Difference = floatdiv(Difference, 10.0);
  152. new Float:OldHealth;
  153. GetPlayerHealth(playerid, OldHealth);
  154. SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
  155. }
  156. CarHealth[playerid] = TempCarHealth;
  157. }
  158. else
  159. {
  160. CarHealth[playerid] = 0.0;
  161. }
  162. return 1;
  163. }
Advertisement
Add Comment
Please, Sign In to add comment