pizzaboy.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #include <YSI_Coding\y_hooks>
  2. static bool:HoldingPizza[MAX_PLAYERS];
  3. static PizzaBike[MAX_PLAYERS];
  4. hook OnPlayerConnect(playerid)
  5. {
  6. HoldingPizza[playerid] = false;
  7. PizzaBike[playerid] = INVALID_VEHICLE_ID;
  8. }
  9. timer NewPizzaOrder[5000](playerid)
  10. {
  11. if(IsPlayerWorking(playerid))
  12. {
  13. if(Iter_Count(House) <= 3)
  14. return SendErrorMessage(playerid, "There must be more than three houses on the server in order to do this job.");
  15. new houseid = Iter_Random(House);
  16. new Float:x, Float:y, Float:z, Float:a;
  17. Property_GetExtPos(houseid, x, y, z, a);
  18. JobCheckpoint[playerid] = CreateDynamicCP(x, y, z, 2.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), playerid);
  19. va_SendClientMessage(playerid, 0xffcc80ff, "(Job) You've recieved a new order. Deliver the pizza to %s.", Property_GetAddress(houseid));
  20. }
  21. return 1;
  22. }
  23. timer ApplyPizzaAnimation[500](playerid)
  24. {
  25. if(IsPlayerWorking(playerid))
  26. {
  27. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
  28. SetPlayerAttachedObject(playerid, 9, 1582, 1, -0.026001, 0.363000, 0.000000, 0.000000, 93.700012, 0.000000, 0.712999, 0.649999, 1.000000, 0, 0);
  29. }
  30. }
  31. timer RemovePlayerPizza[1000](playerid)
  32. {
  33. if(IsPlayerAttachedObjectSlotUsed(playerid, 9)) RemovePlayerAttachedObject(playerid, 9);
  34. }
  35. PizzaboyStartJob(playerid)
  36. {
  37. if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 448) return SendErrorMessage(playerid, "You need to be driving a pizzaboy scooter in order to start working.");
  38. if(Iter_Count(House) <= 3) return SendErrorMessage(playerid, "There must be more than three houses on the server in order to do this job.");
  39. new houseid = Iter_Random(House);
  40. new Float:x, Float:y, Float:z, Float:a;
  41. Property_GetExtPos(houseid, x, y, z, a);
  42. PizzaBike[playerid] = GetPlayerVehicleID(playerid);
  43. JobCheckpoint[playerid] = CreateDynamicCP(x, y, z, 2.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), playerid);
  44. SetPlayerWorking(playerid, true);
  45. va_SendClientMessage(playerid, 0xffcc80ff, "(Job) You have to deliver the pizza to %s, hurry up!", Property_GetAddress(houseid));
  46. return 1;
  47. }
  48. PizzaboyEnterCheckpoint(playerid)
  49. {
  50. if(IsPlayerInAnyVehicle(playerid)) return 0;
  51. if(!HoldingPizza[playerid]) return SendErrorMessage(playerid, "You're not holding any pizzas. Get them from your scooter. (/loadpizza)");
  52. if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_CARRY) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  53. ApplyAnimation(playerid, "BAR", "BARSERVE_GIVE", 4.1, 0, 1, 1, 0, 0, 1);
  54. new money = random(6) + 4;
  55. GivePlayerMoney(playerid, money);
  56. va_SendClientMessage(playerid, 0xffcc80ff, "(Job) You've got a $%d tip, go back to your scooter.", money);
  57. defer RemovePlayerPizza(playerid);
  58. defer NewPizzaOrder(playerid);
  59. DestroyDynamicCP(JobCheckpoint[playerid]);
  60. JobCheckpoint[playerid] = INVALID_STREAMER_ID;
  61. HoldingPizza[playerid] = false;
  62. return 1;
  63. }
  64. PizzaboyStopsWorking(playerid)
  65. {
  66. HoldingPizza[playerid] = false;
  67. PizzaBike[playerid] = INVALID_VEHICLE_ID;
  68. if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_CARRY) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  69. if(IsPlayerAttachedObjectSlotUsed(playerid, 9)) RemovePlayerAttachedObject(playerid, 9);
  70. }
  71. CMD:loadpizza(playerid, params[])
  72. {
  73. if(HoldingPizza[playerid]) return SendErrorMessage(playerid, "You're already holding a pizza.");
  74. if(Player_GetJob(playerid) != JOB_PIZZABOY) return SendErrorMessage(playerid, "You need the pizza boy job in order to use this command.");
  75. if(!IsPlayerWorking(playerid)) return SendErrorMessage(playerid, "You need to be working in order to use this command.");
  76. if(!IsValidVehicle(PizzaBike[playerid]))
  77. {
  78. Job_StopWorking(playerid);
  79. return SendErrorMessage(playerid, "Your vehicle has disappeared so you stopped working.");
  80. }
  81. if(!IsPlayerNearBoot(playerid, PizzaBike[playerid])) return SendErrorMessage(playerid, "You need to be near the scooter's boot.");
  82. HoldingPizza[playerid] = true;
  83. new Float:x, Float:y, Float:z;
  84. GetVehiclePos(PizzaBike[playerid], x, y, z);
  85. SetPlayerToFacePoint(playerid, x, y);
  86. defer ApplyPizzaAnimation(playerid);
  87. ApplyAnimation(playerid, "CARRY", "liftup05", 4.1, 0, 1, 1, 0, 0, 1);
  88. SendInfoMessage(playerid, "You have loaded a pizza. Leave it at the property entrance.");
  89. return 1;
  90. }