vending.pwn 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Vending Machine System (Serversided Health)
  11. by Hector & Shane Roberts
  12. Next Generation Gaming, LLC
  13. (created by Next Generation Gaming Development Team)
  14. * Copyright (c) 2016, Next Generation Gaming, LLC
  15. *
  16. * All rights reserved.
  17. *
  18. * Redistribution and use in source and binary forms, with or without modification,
  19. * are not permitted in any case.
  20. *
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  26. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  27. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  28. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  30. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  31. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. /*
  35. If a vending machine says "you are not at a candy/spunk vending machine" when pressing F and the animation starts, you need to add it's coordinate.
  36. Vending Machine coordinates are located in callbacks.inc at like 216. You also need to specify if it's a Candy or Sprunk machine. Make sure to update callbacks.inc on Github when updating.
  37. */
  38. public OnPlayerUseVending(playerid, type) {
  39. if(!IsPlayerNearVending(playerid, type)) return SendClientMessageEx(playerid, COLOR_GRAD1, "You're not near a %s machine!", (type == 1) ? ("Sprunk") : ("Candy"));
  40. new Float:healtha;
  41. GetHealth(playerid, healtha);
  42. if(gettime() - LastShot[playerid] < 60) return SendClientMessageEx(playerid, COLOR_GRAD2, "You have been injured within the last 60 seconds, you cannot use the vending machine");
  43. if((PlayerInfo[playerid][pConnectHours] > 5 && GetPlayerCash(playerid) < 750)) return SendClientMessageEx(playerid, COLOR_GRAD1, "You need at least $750 to buy %s!", (type == 1) ? ("a Sprunk") : ("some Candy")), ClearAnimationsEx(playerid);
  44. if((PlayerInfo[playerid][pConnectHours] < 5 && GetPlayerCash(playerid) < 150)) return SendClientMessageEx(playerid, COLOR_GRAD1, "You need at least $150 to buy %s!", (type == 1) ? ("a Sprunk") : ("some Candy")), ClearAnimationsEx(playerid);
  45. if((healtha > 99.0)) return SendClientMessageEx(playerid, COLOR_GRAD2, "Your health is already at 100");
  46. // if((healtha + 35.0) > 100.0) SetHealth(playerid, 100);
  47. // else SetHealth(playerid, healtha+35);
  48. SetTimerEx("SprunkTimer", 3000, false, "i", playerid);
  49. if((PlayerInfo[playerid][pConnectHours] > 5)) {
  50. SendClientMessageEx(playerid, COLOR_GRAD1, "You paid $750 for %s!", (type == 1) ? ("a Sprunk") : ("some Candy"));
  51. GivePlayerCash(playerid, -750);
  52. }
  53. if((PlayerInfo[playerid][pConnectHours] < 5)) {
  54. SendClientMessageEx(playerid, COLOR_GRAD1, "You paid $150 for %s!", (type == 1) ? ("a Sprunk") : ("some Candy"));
  55. GivePlayerCash(playerid, -150);
  56. }
  57. return 1;
  58. }
  59. forward SprunkTimer(playerid);
  60. public SprunkTimer(playerid)
  61. {
  62. new Float:healtha;
  63. GetHealth(playerid, healtha);
  64. if((healtha + 35.0) > 100.0) SetHealth(playerid, 100);
  65. else SetHealth(playerid, healtha+35);
  66. return 1;
  67. }