Guest User

Untitled

a guest
Oct 29th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.94 KB | None | 0 0
  1. #include <a_samp>
  2. #include <core>
  3. #include <float>
  4.  
  5.  
  6. /*
  7. Commands - /baitcar
  8. Requirements - You are a member of the SASD or LSPD, you are over rank 6.#
  9. Information - You go to a car you privately own or have a set of duplicate keys to. You park the vehicle, use /baitcar and then exit it.
  10. You then wait for a criminal to break into the car and steal it. When he is driving the person who used the /baitcar command can use it again, turning the car's engine off and locking the doors
  11. by freezing the player in place. /exitcar and other unfreezing methods should be unavailable at this time. To unlock the doors and let the criminals out or arrest them just use the /lock command on the car.
  12. It will unlock the car, unfreezing the suspects.
  13. This can work on more than one person in the same car.
  14. */
  15.  
  16. // Don't add, for testing purposes
  17. enum pInfo
  18. {
  19. Faction,
  20. Rank,
  21. DupKeys,
  22. CarKeys
  23.  
  24. };
  25.  
  26. enum vInfo
  27. {
  28. Engine,
  29. Locked
  30. };
  31.  
  32. new PlayerInfo[MAX_PLAYERS][pInfo];
  33. new VehicleInfo[MAX_VEHICLES][vInfo];
  34. // End of "Don't Add" list
  35.  
  36. new VehicleBaited[MAX_VEHICLES]; // Temp vehicle cach
  37.  
  38. main()
  39. {
  40. print("\n----------------------------------");
  41. print(" Baitcar Script - Made by Giacomand\n");
  42. print("----------------------------------\n");
  43. }
  44.  
  45. public OnPlayerConnect(playerid)
  46. {
  47. // Don't add these - Testing Purposes
  48. GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
  49. PlayerInfo[playerid][Faction] = 1; // We're a cop now
  50. PlayerInfo[playerid][Rank] = 1; // We're the Chief of Police, woot!
  51. PlayerInfo[playerid][CarKeys] = 1; // We got vehicle 1's carkeys.
  52. PlayerInfo[playerid][DupKeys] = -1; // Nothing
  53. SendClientMessage(playerid, 0xFFFFFFAA, "You were made The Chief of Police. (Rank 6 and over)");
  54. return 1;
  55. }
  56.  
  57. public OnPlayerCommandText(playerid, cmdtext[])
  58. {
  59. if(!strcmp(cmdtext, "/baitcar"))
  60.  
  61. {
  62. if((PlayerInfo[playerid][Faction] == 1 || PlayerInfo[playerid][Faction] == 6) && (PlayerInfo[playerid][Rank] <= 6)) // LSPD faction and SASD
  63. {
  64. if(GetPVarInt(playerid, "UsedBaitCar") == 1)
  65. {
  66. new vehicleidG;
  67. for(new i = 0; i < MAX_PLAYERS; i++)
  68. {
  69. vehicleidG = GetPlayerVehicleID(i);
  70. if(VehicleBaited[vehicleidG] >= 1)
  71. {
  72. TogglePlayerControllable(i, 0);
  73. SendClientMessage(i, 0xFF0000AA, "The Engine turns off and the doors are locked. The windows are strongly made and hard to break. To get out you need the keys.");
  74. // Don't want to stop here because there could be passengers in the car.
  75. }
  76. }
  77. VehicleInfo[vehicleidG][Locked] = 1; // Sets the car to locked.
  78. VehicleInfo[vehicleidG][Engine] = 1; // Sets the car's engine off. If the robbers don't have the keys then they can't turn it back on.
  79. SendClientMessage(playerid, 0xFF0000AA, "The car has been disabled. To get the suspects out you must unlock the car.");
  80. SetPVarInt(playerid, "UsedBaitCar", 0);
  81. }
  82. else if (IsPlayerInAnyVehicle(playerid))
  83. {
  84. new vehicleidG = GetPlayerVehicleID(playerid);
  85. if(PlayerInfo[playerid][CarKeys] == vehicleidG || PlayerInfo[playerid][DupKeys] == vehicleidG)
  86. {
  87. VehicleBaited[vehicleidG] = playerid+1;
  88. SetPVarInt(playerid, "UsedBaitCar", 1);
  89. SendClientMessage(playerid, 0xFFFFFFAA, "The car is now baited. Use /baitcar again to stop the car's engine and lock the people inside.");
  90. SendClientMessage(playerid, 0xFFFFFFAA, "To allow the suspect(s) to exit just open the car with the /lock command, it'll allow them to /exitcar and engine.");
  91. }
  92. else
  93. {
  94. SendClientMessage(playerid, 0xFF0000AA, "Get into a car you own or have the keys to (Duplicated).");
  95. }
  96. }
  97. else
  98. {
  99. SendClientMessage(playerid, 0xFF0000AA, "Get into a car you own or have the keys to (Duplicated).");
  100. }
  101. }
  102. else
  103. {
  104. SendClientMessage(playerid, 0xFF0000AA, "You're not a cop of any department or you aren't rank 6 and above.");
  105. }
  106. }
  107.  
  108. {
  109.  
  110. if(!strcmp(cmdtext, "/lock"))
  111. {
  112. //if near car, blablabla
  113. new vehicleid; // remove this when adding to script, I'm just using it to remove error since it's not in the LS-RP script.
  114. if(VehicleBaited[vehicleid] >= 1) // Should be on top before all commands. The vehicleid is the intergar that you collected by checking for nearby cars.
  115. {
  116. if(PlayerInfo[playerid][CarKeys] == vehicleid || PlayerInfo[playerid][DupKeys] == vehicleid) // Anyone with the keys can use this.
  117. {
  118. for(new i = 0; i < MAX_PLAYERS; i++)
  119. {
  120. if(GetPlayerVehicleID(i) == vehicleid)
  121. {
  122. TogglePlayerControllable(i, 1);
  123. SendClientMessage(i, 0xFFFFFFAA, "The door is now unlocked are you are free to exit.");
  124. // Don't end yet because there might be passengers.
  125. }
  126. }
  127. VehicleBaited[vehicleid] = -1; // Unbaited
  128.  
  129. }
  130. else
  131. {
  132. SendClientMessage(playerid, 0xFF0000AA, "You need the keys to the car or duplicates.");
  133. }
  134. }
  135. // Place the rest of the lock command here.
  136. }
  137. return 0;
  138. }
  139.  
  140. }
  141.  
  142.  
  143.  
  144.  
  145. // Use this function in the commands which could unfreeze the player. Such as /exitcar and /engine.
  146.  
  147. //if(CheckBaited(playerid, vehicleid) == true) return 0;
  148.  
  149. stock CheckBaited(playerid, vehicleid)
  150. {
  151. if(VehicleBaited[vehicleid] >= 1)
  152. {
  153. SendClientMessage(playerid, 0xFF0000AA, "The doors are locked and the engine is disabled");
  154. return true;
  155. }
  156. return false;
  157. }
  158.  
  159.  
  160. public OnPlayerSpawn(playerid)
  161. {
  162. SetPlayerInterior(playerid, 0);
  163. SetPlayerPos(playerid, 0.0, 0.0, 10.0);
  164. return 1;
  165. }
  166.  
  167. public OnPlayerDeath(playerid, killerid, reason)
  168. {
  169. return 1;
  170. }
  171.  
  172. public OnGameModeInit()
  173. {
  174. SetGameModeText("Bare Script");
  175. AddStaticVehicle(451, 0.0, 5.0, 10.0, 0.0, 0, 60); // For testing, this will be vehicle 0, we cannot use this as we don't own this car.
  176. AddStaticVehicle(451, 0.0, -5.0, 10.0, 0.0, 0, 60); // For testing, this will be vehicle 1, we can use for /baitcar since we privately own it.
  177. AddPlayerClass(265,0.0, 0.0, 0.0, 0.0,0,0,0,0,-1,-1);
  178.  
  179.  
  180. return 1;
  181. }
Advertisement
Add Comment
Please, Sign In to add comment