courier.inc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #include <YSI_Coding\y_hooks>
  2. static bool:HoldingBox[MAX_PLAYERS];
  3. static CourierVan[MAX_PLAYERS];
  4. hook OnPlayerConnect(playerid)
  5. {
  6. HoldingBox[playerid] = false;
  7. CourierVan[playerid] = INVALID_VEHICLE_ID;
  8. }
  9. CourierStartJob(playerid)
  10. {
  11. if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 482) return SendErrorMessage(playerid, "You need to be driving a Burrito in order to start working.");
  12. if(Iter_Count(Business) <= 3 || Iter_Count(House) <= 3) return SendErrorMessage(playerid, "There must be more than three houses and businesses on the server in order to do this job.");
  13. new propertyid;
  14. switch(random(2))
  15. {
  16. case 0: propertyid = Iter_Random(House);
  17. case 1: propertyid = Iter_Random(Business);
  18. }
  19. new Float:x, Float:y, Float:z;
  20. Property_GetExtPos(propertyid, x, y, z);
  21. JobCheckpoint[playerid] = CreateDynamicCP(x, y, z, 4.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), playerid);
  22. CourierVan[playerid] = GetPlayerVehicleID(playerid);
  23. SetPlayerWorking(playerid, true);
  24. va_SendClientMessage(playerid, 0xffcc80ff, "(Job) You have to deliver some boxes to a %s at %s, hurry up!", (IsPropertyAHouse(propertyid)) ? ("house"): ("business"), Property_GetAddress(propertyid));
  25. return 1;
  26. }
  27. CourierEnterCheckpoint(playerid)
  28. {
  29. if(IsPlayerInAnyVehicle(playerid)) return 0;
  30. if(Iter_Count(Business) <= 3 || Iter_Count(House) <= 3)
  31. {
  32. Job_StopWorking(playerid);
  33. return SendErrorMessage(playerid, "There must be more than three houses and businesses on the server in order to do this job.");
  34. }
  35. if(!HoldingBox[playerid]) return SendErrorMessage(playerid, "You're not holding any boxes. Get them from the back of the vehicle. (/loadbox)");
  36. if(IsPlayerAttachedObjectSlotUsed(playerid, 9)) RemovePlayerAttachedObject(playerid, 9);
  37. if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_CARRY) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  38. ApplyAnimation(playerid, "CARRY", "putdwn", 4.1, 0, 1, 1, 0, 0, 1);
  39. DestroyDynamicCP(JobCheckpoint[playerid]);
  40. JobCheckpoint[playerid] = INVALID_STREAMER_ID;
  41. HoldingBox[playerid] = false;
  42. new propertyid;
  43. switch(random(2))
  44. {
  45. case 0: propertyid = Iter_Random(House);
  46. case 1: propertyid = Iter_Random(Business);
  47. }
  48. new Float:x, Float:y, Float:z;
  49. Property_GetExtPos(propertyid, x, y, z);
  50. JobCheckpoint[playerid] = CreateDynamicCP(x, y, z, 4.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), playerid);
  51. va_SendClientMessage(playerid, 0xffcc80ff, "(Job) You have to deliver some boxes to a %s at %s, hurry up!", (IsPropertyAHouse(propertyid)) ? ("house"): ("business"), Property_GetAddress(propertyid));
  52. return 1;
  53. }
  54. CourierStopsWorking(playerid)
  55. {
  56. HoldingBox[playerid] = false;
  57. CourierVan[playerid] = INVALID_VEHICLE_ID;
  58. if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_CARRY) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  59. if(IsPlayerAttachedObjectSlotUsed(playerid, 9)) RemovePlayerAttachedObject(playerid, 9);
  60. }
  61. timer CloseVanDoors[1000](playerid)
  62. {
  63. new driver, passenger, backleft, backright;
  64. GetVehicleParamsCarDoors(CourierVan[playerid], driver, passenger, backleft, backright);
  65. SetVehicleParamsCarDoors(CourierVan[playerid], driver, passenger, 0, 0);
  66. }
  67. timer ApplyBoxAnimation[2000](playerid)
  68. {
  69. if(IsPlayerWorking(playerid))
  70. {
  71. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
  72. SetPlayerAttachedObject(playerid, 9, 2694, 1, 0.170999, 0.363000, 0.000000, 0.000000, 93.700012, 0.000000, 0.713000, 0.650000, 1.000000, 0, 0);
  73. defer CloseVanDoors(playerid);
  74. }
  75. }
  76. CMD:loadbox(playerid, params[])
  77. {
  78. if(HoldingBox[playerid]) return SendErrorMessage(playerid, "You're already holding a box.");
  79. if(Player_GetJob(playerid) != JOB_COURIER) return SendErrorMessage(playerid, "You need the courier job in order to use this command.");
  80. if(!IsPlayerWorking(playerid)) return SendErrorMessage(playerid, "You need to be working in order to use this command.");
  81. if(!IsValidVehicle(CourierVan[playerid]))
  82. {
  83. Job_StopWorking(playerid);
  84. return SendErrorMessage(playerid, "Your vehicle has disappeared so you stopped working.");
  85. }
  86. if(!IsPlayerNearBoot(playerid, CourierVan[playerid])) return SendErrorMessage(playerid, "You need to be near the vehicle's trunk.");
  87. HoldingBox[playerid] = true;
  88. new Float:x, Float:y, Float:z;
  89. GetVehiclePos(CourierVan[playerid], x, y, z);
  90. SetPlayerToFacePoint(playerid, x, y);
  91. new driver, passenger, backleft, backright;
  92. GetVehicleParamsCarDoors(CourierVan[playerid], driver, passenger, backleft, backright);
  93. SetVehicleParamsCarDoors(CourierVan[playerid], driver, passenger, 1, 1);
  94. ApplyAnimation(playerid, "MISC", "Plunger_01", 4.1, 0, 1, 1, 0, 0, 1);
  95. defer ApplyBoxAnimation(playerid);
  96. SendInfoMessage(playerid, "You have loaded a box. Leave it at the property entrance.");
  97. return 1;
  98. }