1
0

PPC_Toll.inc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // This file holds all functions for the toll-system
  2. forward Toll();
  3. public Toll()
  4. {
  5. // Loop through all players
  6. for(new playerid; playerid < MAX_PLAYERS; playerid++)
  7. {
  8. // If the player isn't connected, skip to the next player
  9. if(APlayerData[playerid][LoggedIn] == false) continue;
  10. // Check if the player is the driver of a vehicle
  11. if (GetPlayerVehicleSeat(playerid) == 0)
  12. {
  13. // Loop through all toll-gates
  14. for (new TollGate; TollGate < MAX_TOLLGATES; TollGate++)
  15. {
  16. // Check if this toll-gate exists
  17. if (ATollGates[TollGate][GateID] != 0)
  18. {
  19. // Check if the player is in range of the tollgate
  20. if(IsPlayerInRangeOfPoint(playerid, 7.5, ATollGates[TollGate][CloseX], ATollGates[TollGate][CloseY], ATollGates[TollGate][CloseZ]))
  21. {
  22. // Check if the toll-gate is closed
  23. if(ATollGates[TollGate][GateStatus] == 0)
  24. {
  25. // Open the gate
  26. MoveObject(ATollGates[TollGate][GateID], ATollGates[TollGate][OpenX], ATollGates[TollGate][OpenY], ATollGates[TollGate][OpenZ], 3.0);
  27. // Set status to OPEN
  28. ATollGates[TollGate][GateStatus] = 1;
  29. // Let the player pay the toll
  30. RewardPlayer(playerid, -ATollGates[TollGate][TollPrice], 0);
  31. new string[50];
  32. format(string, sizeof(string), TXT_PlayerPaysToll, ATollGates[TollGate][TollPrice]);
  33. GameTextForPlayer(playerid, string, 3000, 4);
  34. // Start a timer that closes the gate after 5 seconds
  35. SetTimerEx("CloseGate", 5000, false, "i", TollGate);
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }
  42. }
  43. forward CloseGate(TollGate);
  44. public CloseGate(TollGate)
  45. {
  46. // Close the gate
  47. MoveObject(ATollGates[TollGate][GateID], ATollGates[TollGate][CloseX], ATollGates[TollGate][CloseY], ATollGates[TollGate][CloseZ], 3.0);
  48. // Set status to CLOSED
  49. ATollGates[TollGate][GateStatus] = 0;
  50. }