Guest User

SamSung

a guest
Aug 17th, 2009
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.79 KB | None | 0 0
  1. //------------------------------------------------------------------------------
  2. //
  3. // Bus Mission Filter Script v1.0
  4. //
  5. // By SamSung
  6. //------------------------------------------------------------------------------
  7.  
  8. #include <a_samp>
  9.  
  10. #define BAJADA_DE_BANDERA 200
  11. #define PRECIO_FICHA 100
  12.  
  13. new OnBusAsPassenger[MAX_PLAYERS];
  14. new CostoDelViaje[MAX_PLAYERS];
  15. new contador[MAX_PLAYERS];
  16. new playerInMiniMission[MAX_PLAYERS];
  17. new avisado[MAX_PLAYERS];
  18. new caidadefichaTimer;
  19. new cantidadPasajeros;
  20.  
  21. forward terminarMission(playerid);
  22. forward caidadeficha();
  23.  
  24. public OnFilterScriptInit()
  25. {
  26. print("\n Bus Filter Script v1.0 Loading...\n**********************\n (SamSung)\n");
  27. for (new i=0;i<MAX_PLAYERS;i++)
  28. {
  29. playerInMiniMission[i]=-1;
  30. avisado[i]=-1;
  31. OnBusAsPassenger[i]=-1;
  32. }
  33. caidadefichaTimer=-1;
  34. cantidadPasajeros=0;
  35. SetTimer("caidadeficha",30000,1);
  36. print("Bus Filter Script fully Loaded\n**********************************\n\n");
  37. }
  38.  
  39. public OnFilterScriptExit()
  40. {
  41. print("\n**********************\n*Bus Script UnLoaded*\n**********************\n");
  42. return 1;
  43. }
  44. //------------------------------------------------------------------------------------------------------
  45. public terminarMission(playerid)
  46. {
  47. new msg[255];
  48. format(msg,sizeof(msg),"~r~Bus ~w~MiniMission cancelled~n~ You carried ~r~%d~w~ pasengers.",contador[playerid]);
  49. GameTextForPlayer(playerid,msg,3000,4);
  50. playerInMiniMission[playerid]=-1;
  51. avisado[playerid]=-1;
  52. new name[MAX_PLAYER_NAME];
  53. GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  54. format(msg,sizeof(msg),"[***] %s Is NOT a Bus driver anymore",name);
  55. GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  56. for (new i=0;i<MAX_PLAYERS;i++)
  57. {
  58. if (playerid!=i)
  59. {
  60. SendClientMessage(i,0xFFFF00AA," ");
  61. SendClientMessage(i,0xFFFF00AA,msg);
  62. }
  63. }
  64. for (new i=0;i<MAX_PLAYERS;i++)
  65. {
  66. if (OnBusAsPassenger[i]==playerid)
  67. {
  68. new Bussta = playerid;
  69. OnBusAsPassenger[i]=-1;
  70. new viaje=CostoDelViaje[i];
  71. format(msg,sizeof(msg),"~w~You pay to ~g~%s ~n~~r~$%d~w~ for the ~r~Bus~w~ ride.",name,viaje);
  72. GameTextForPlayer(i,msg,3000,4);
  73. format(msg,sizeof(msg),"~w~You get ~r~$%d~w~ ~n~for the ~r~Bus~w~ ride.",viaje);
  74. GameTextForPlayer(Bussta,msg,3000,4);
  75. GivePlayerMoney(i,-viaje);
  76. GivePlayerMoney(Bussta,viaje);
  77. cantidadPasajeros--;
  78. if (cantidadPasajeros==0)
  79. {
  80. KillTimer(caidadefichaTimer);
  81. }
  82. }
  83. }
  84. contador[playerid]=0;
  85. return 1;
  86. }
  87. //------------------------------------------------------------------------------------------------------
  88. public caidadeficha()
  89. {
  90. for (new i=0;i<MAX_PLAYERS;i++)
  91. {
  92. CostoDelViaje[i]=CostoDelViaje[i]+PRECIO_FICHA;
  93. }
  94. }
  95. //------------------------------------------------------------------------------------------------------
  96. public OnPlayerStateChange(playerid, newstate, oldstate)
  97. {
  98. new msg[255];
  99. if (newstate==PLAYER_STATE_DRIVER)
  100. {
  101. if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 431)
  102. {
  103. if (avisado[playerid]==-1)
  104. {
  105. GameTextForPlayer(playerid,"~w~Press ~b~Button 2~n~~w~to start the ~n~~r~Bus~w~ Minimission.",3000,5);
  106. }
  107. else
  108. {
  109. KillTimer(avisado[playerid]);
  110. avisado[playerid]=-1;
  111. }
  112. }
  113. }
  114. if (newstate==PLAYER_STATE_ONFOOT)
  115. {
  116. if ((playerInMiniMission[playerid]>0)&&(avisado[playerid]==-1))
  117. {
  118. GameTextForPlayer(playerid,"~w~You have ~r~10 sec ~n~~w~ to enter a ~r~Bus",3000,4);
  119. avisado[playerid]=SetTimerEx("terminarMission",10000,0,"%d",playerid);
  120. }
  121. if (OnBusAsPassenger[playerid]!=-1)
  122. {
  123. new Bussta = OnBusAsPassenger[playerid];
  124. new name[MAX_PLAYER_NAME];
  125. GetPlayerName(Bussta,name,MAX_PLAYER_NAME);
  126. OnBusAsPassenger[playerid]=-1;
  127. new viaje = CostoDelViaje[playerid];
  128. format(msg,sizeof(msg),"~w~You pay to ~g~%s ~n~~r~$%d~w~ for the ~r~Bus~w~ ride.",name,viaje);
  129. GameTextForPlayer(playerid,msg,3000,4);
  130. format(msg,sizeof(msg),"~w~You get ~r~$%d~w~ ~n~for the ~r~Bus~w~ ride.",viaje);
  131. GameTextForPlayer(Bussta,msg,3000,4);
  132. GivePlayerMoney(playerid,-viaje);
  133. GivePlayerMoney(Bussta,viaje);
  134. cantidadPasajeros--;
  135. if (cantidadPasajeros==0)
  136. {
  137. KillTimer(caidadefichaTimer);
  138. }
  139. }
  140. }
  141. if (newstate==PLAYER_STATE_PASSENGER)
  142. {
  143. if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 431)
  144. {
  145. new i=0;
  146. while (i<MAX_PLAYERS)
  147. {
  148. if ((playerInMiniMission[i]==1)&&(GetPlayerState(i)==PLAYER_STATE_DRIVER))
  149. {
  150. if (GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid))
  151. {
  152. new name[MAX_PLAYER_NAME];
  153. GetPlayerName(i,name,MAX_PLAYER_NAME);
  154. contador[i]++;
  155. format(msg,sizeof(msg),"~w~You have gotten into ~n~~g~%s's ~r~Bus~w~",name);
  156. GameTextForPlayer(playerid,msg,3000,4);
  157. format(msg,sizeof(msg),"~w~You have one new~n~~r~PASENGER~w~");
  158. GameTextForPlayer(playerid,msg,3000,4);
  159. OnBusAsPassenger[playerid]=i;
  160. CostoDelViaje[playerid]=BAJADA_DE_BANDERA;
  161. if (cantidadPasajeros==0)
  162. {
  163. caidadefichaTimer=SetTimer("caidadeficha",30000,1);
  164. }
  165. cantidadPasajeros++;
  166. i=MAX_PLAYERS;
  167. }
  168. }
  169. i++;
  170. }
  171. }
  172. }
  173. return 1;
  174. }
  175. //------------------------------------------------------------------------------------------------------
  176. MissionIni(playerid)
  177. {
  178. playerInMiniMission[playerid]=1;
  179. GameTextForPlayer(playerid,"~r~Bus ~w~MiniMision ~w~Started!",3000,4);
  180. new name[MAX_PLAYER_NAME];
  181. GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  182. new msg[255];
  183. format(msg,sizeof(msg),"[***] %s is now a Bus driver",name);
  184. for (new i=0;i<MAX_PLAYERS;i++)
  185. {
  186. if (playerid!=i)
  187. {
  188. SendClientMessage(i,0xFFFF00AA," ");
  189. SendClientMessage(i,0xFFFF00AA,msg);
  190. }
  191. }
  192. return 1;
  193. }
  194. //------------------------------------------------------------------------------------------------------
  195. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  196. {
  197. if ((newkeys==KEY_SUBMISSION)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
  198. {
  199. if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 431)
  200. {
  201. if (playerInMiniMission[playerid]<0)
  202. {
  203. MissionIni(playerid);
  204. }
  205. else
  206. {
  207. terminarMission(playerid);
  208. }
  209. }
  210. }
  211. }
  212. //------------------------------------------------------------------------------------------------------
  213. public OnPlayerDisconnect(playerid)
  214. {
  215. if (playerInMiniMission[playerid]>0)
  216. {
  217. terminarMission(playerid);
  218. }
  219. OnBusAsPassenger[playerid]=-1;
  220. return 1;
  221. }
Advertisement
Add Comment
Please, Sign In to add comment