Advertisement
Guest User

SA-MP automatic Toll Gate Script

a guest
May 5th, 2020
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. new modelid = 968;
  2. new PlayerPaid[MAX_PLAYERS] = {false, ...};
  3.  
  4. new Float:GatePos[29][9] =
  5. {
  6. {x, y, z, r-x, r-y, r-z, x_open, y_close, z_close}
  7. }
  8.  
  9. public OnFilterScriptInit()
  10. {
  11. for(new a; a<sizeof(GatePos); a++)
  12. {
  13. Gate[a] = CreateObject(modelid, GatePos[a][0],GatePos[a][1],GatePos[a][2],GatePos[a][3],GatePos[a][4],GatePos[a][5], 150.0);
  14. }
  15.  
  16. return 1;
  17. }
  18.  
  19. public OnPlayerSpawn(playerid)
  20. {
  21. SetTimer("TollGate_Open", 1500, 1);
  22. return 1;
  23. }
  24.  
  25. public TollGate_Open()
  26. {
  27. new vehicleid;
  28. new open;
  29.  
  30. for(new i=GetMaxPlayers(); i > -1; i--)
  31. {
  32. //Iterates through an array of Created Object toll gate
  33. for(new a; a<sizeof(GatePos); a++)
  34. {
  35. //If Player is in range of toll gate AND if open is false
  36. if(IsPlayerInRangeOfPoint(i, 6.0, GatePos[a][0],GatePos[a][1],GatePos[a][2]))
  37. {
  38.  
  39. vehicleid = GetPlayerVehicleID(i);
  40. if(IsPlayerInVehicle(i, vehicleid))
  41. {
  42. open = true;
  43.  
  44. //Moves the object barrier 968
  45. MoveObject(Gate[a], GatePos[a][0],GatePos[a][1],GatePos[a][2], 2000, GatePos[a][3], 0.0, GatePos[a][5]);
  46.  
  47. //Prevents the closing of toll gate when the player's vehicle is still in range
  48. if(open && !PlayerPaid[i]){
  49. GivePlayerMoney(i,-20);
  50. GameTextForPlayer(i,"$20\nToll Paid",3000,4);
  51. PlayerPaid[i] = true;
  52. }else{
  53. continue;
  54. }
  55.  
  56. break;
  57. }
  58. }
  59.  
  60. if(!open){
  61. //SendClientMessage(PlayerPaid[i], -1, "Toll gate closed");
  62. MoveObject(Gate[a], GatePos[a][0],GatePos[a][1],GatePos[a][2], 2000, GatePos[a][3], GatePos[a][4], GatePos[a][5]);
  63. //PlayerPaid[i] = false;
  64. }
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement