Advertisement
Guest User

.....

a guest
Mar 15th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.24 KB | None | 0 0
  1.  
  2. #include <a_samp>
  3.  
  4. #define COLOR_ORANGE        0xFFA500FF
  5. #define COLOR_LIMEGREEN     0x32CD32FF
  6. #define COLOR_ROYALBLUE     0x4169E1FF
  7. #define COLOR_PINK          0xFA8072FF
  8. #define COLOR_GREY          0xAFAFAFAA
  9. #define COLOR_GREEN         0x33AA33AA
  10. #define COLOR_RED           0xFF0000C8
  11. #define COLOR_YELLOW        0xFFFF00AA
  12. #define COLOR_WHITE         0xFFFFFFAA
  13. #define COLOR_BLUE          0x0000BBAA
  14. #define COLOR_LIGHTBLUE     0x33CCFFAA
  15. #define COLOR_INDIGO 0x1E90FFAA
  16.  
  17. enum {
  18.     STAGE_IDLE,
  19.     STAGE_LOAD,
  20.     STAGE_UNLOAD
  21. }
  22.  
  23. enum {
  24.     STAGE_IDL,
  25.     STAGE_LOA,
  26.     STAGE_UNLOA
  27. }
  28.  
  29. new MissionStge[MAX_PLAYERS];
  30.  
  31. new Float: qPickupCPs[][] = {
  32.     { 2520.4902,1299.3765,10.8125},//
  33.     { 2078.8430,1618.3031,10.8203 },//
  34.     { 1726.2607,1529.2054,10.8203 },//
  35.     { 2079.0376,1009.1650,10.8203 },//
  36.     { 1772.3185,-1859.1658,13.4141},//
  37.     { 1455.9867,-1739.3135,13.5469},//
  38.     { 1107.7612,-1718.7412,13.5469},//
  39.    { -292.6930,-2168.5618,28.5569},//
  40.    { -226.7563,-264.2542,1.4219},//
  41.    {  72.6294,98.2194,2.2922}
  42. };
  43.  
  44. new Float: qDeliverCPs[][] = {
  45.     { 2121.8547,1431.1693,10.8203},//
  46.     { 1844.1877,2264.9973,11.2288 },//
  47.     { 1996.1808,824.2429,6.8624 },//
  48.     { 1716.4343,1373.8458,10.6406 },//
  49.     { 2158.5112,1871.4792,10.8203 },//
  50.     { 1638.2766,-2323.8223,13.3828 },//
  51.     { 1560.9440,-1808.5863,13.5469 },//
  52.     { 826.4546,-1635.2385,13.5469 },//
  53.     { 375.6268,-1908.5886,7.8359 },//
  54.     { -378.5306,-1405.5066,25.1902 },//
  55.     { -157.0472,-351.0927,1.4297   }
  56. };
  57.  
  58. new MissionStage[MAX_PLAYERS];
  59.  
  60.  
  61. new Float: gPickupCPs[][] = {
  62.     { 1708.1753,1447.5897,10.8183},//
  63.     { 2020.1150,1281.8982,10.8203 },//
  64.     { 1605.1226,1845.6368,10.8203 },//
  65.     { 1624.7622,2591.9053,10.6719 },//
  66.     { 2572.1851,1379.5211,10.8203},//
  67.     { 1945.4916,168.0763,37.2813},//
  68.     { -139.8199,214.4663,7.7478},//
  69.    { -2172.1980,-90.0761,35.1719},//
  70.    { -1412.2441,-304.1318,14.1411},//
  71.    {  341.2981,-1803.4674,4.6585},
  72.    {  774.9841,-1792.0835,13.0311},
  73.    {  1663.0458,-2250.7988,13.3554},
  74.    {  1934.3203,-1928.5203,13.3860},
  75.    {  2607.8840,-1450.5083,32.9954}
  76. };
  77.  
  78. new Float: gDeliverCPs[][] = {
  79.     { 2715.4163,-1121.9978,69.5781},//
  80.     { 2168.6951,-1629.7954,14.4724 },//
  81.     { 1996.5559,-1713.5670,13.5469},//
  82.     { 119.0267,-1560.5231,8.4564 },//
  83.     { -2019.3076,164.8913,28.2674 },//
  84.     { -1541.7216,495.1849,7.1797 },//
  85.     { 1239.2821,350.3404,19.4063 },//
  86.     { 2352.4280,154.6426,26.4692 },//
  87.     { 2296.4382,665.6402,10.8203 },//
  88.     { 1044.0485,1043.5970,10.1577 },//
  89.     { 1863.2518,1097.7646,10.7056  }
  90. };
  91.  
  92.  
  93. public OnPlayerConnect(playerid) {
  94.     MissionStage[playerid] = STAGE_IDLE;
  95.     MissionStge[playerid] = STAGE_IDL;
  96.     return true;
  97. }
  98.  
  99. DeliveryMissionn(playerid) {
  100.     if(MissionStage[playerid] == STAGE_IDLE) {
  101.         if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 420) {
  102.             new
  103.                 idx,
  104.                 Float: tmp,
  105.                 Float: dist = GetPlayerDistanceFromPoint(playerid, gPickupCPs[0][0], gPickupCPs[0][1], gPickupCPs[0][2])
  106.             ;
  107.             for(new i = 1; i < sizeof gPickupCPs; ++i) {
  108.                 tmp = GetPlayerDistanceFromPoint(playerid, gPickupCPs[i][0], gPickupCPs[i][1], gPickupCPs[i][2]);
  109.  
  110.                 if(tmp < dist) {
  111.                     dist = tmp;
  112.                     idx = i;
  113.                 }
  114.             }
  115.             MissionStage[playerid] = STAGE_LOAD;
  116.             return SetPlayerCheckpoint(playerid, gPickupCPs[idx][0], gPickupCPs[idx][1], gPickupCPs[idx][2], 20.0);
  117.         }
  118.     } else {
  119.         MissionStage[playerid] = STAGE_IDLE;
  120.         return DisablePlayerCheckpoint(playerid);
  121.     }
  122.     return false;
  123. }
  124.  
  125. DeliveryMissio(playerid) {
  126.     if(MissionStge[playerid] == STAGE_IDL) {
  127.         if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 437) {
  128.             new
  129.                 idx,
  130.                 Float: tmp,
  131.                 Float: dist = GetPlayerDistanceFromPoint(playerid, qPickupCPs[0][0], qPickupCPs[0][1], qPickupCPs[0][2])
  132.             ;
  133.             for(new i = 1; i < sizeof qPickupCPs; ++i) {
  134.                 tmp = GetPlayerDistanceFromPoint(playerid, qPickupCPs[i][0], qPickupCPs[i][1], qPickupCPs[i][2]);
  135.  
  136.                 if(tmp < dist) {
  137.                     dist = tmp;
  138.                     idx = i;
  139.                 }
  140.             }
  141.             MissionStge[playerid] = STAGE_LOA;
  142.             return SetPlayerCheckpoint(playerid, qPickupCPs[idx][0], qPickupCPs[idx][1], qPickupCPs[idx][2], 20.0);
  143.         }
  144.     } else {
  145.         MissionStge[playerid] = STAGE_IDL;
  146.         return DisablePlayerCheckpoint(playerid);
  147.     }
  148.     return false;
  149. }
  150.  
  151. public OnPlayerCommandText(playerid, cmdtext[]) {
  152.     if (strcmp("/Bus", cmdtext, true) == 0) {
  153.         if(MissionStge[playerid] != STAGE_IDL) {
  154.             return SendClientMessage(playerid, COLOR_RED, "You are already in a work!");
  155.         }
  156.         if(DeliveryMissio(playerid)) {
  157.             return 1;
  158.         }
  159.     }
  160.     if (strcmp("/Stopbus", cmdtext, true) == 0) {
  161.         if(MissionStge[playerid] == STAGE_IDL) {
  162.            return SendClientMessage(playerid, COLOR_RED, "You aren't doing any work!");
  163.         }
  164.         if(DeliveryMissio(playerid)) {
  165.             GivePlayerMoney(playerid,-10000);
  166.             return SendClientMessage(playerid, COLOR_RED, "You had Paid $10,000 for stopping your Work!");
  167.         }
  168.         if (strcmp("/Taxi", cmdtext, true) == 0) {
  169.         if(MissionStage[playerid] != STAGE_IDLE) {
  170.             return SendClientMessage(playerid, COLOR_RED, "You are already in a work!");
  171.         }
  172.         if(DeliveryMissionn(playerid)) {
  173.             SendClientMessage(playerid, COLOR_INDIGO, "You have Started your Work !");
  174.             return 1;
  175.         }
  176.         }
  177.         if (strcmp("/StopTaxi", cmdtext, true) == 0) {
  178.         if(MissionStage[playerid] == STAGE_IDLE) {
  179.            return SendClientMessage(playerid, COLOR_RED, "You aren't doing any work!");
  180.         }
  181.         if(DeliveryMissionn(playerid)) {
  182.             GivePlayerMoney(playerid,-10000);
  183.             return SendClientMessage(playerid, COLOR_RED, "You had Paid $10,000 for stopping your Work!");
  184.         }
  185.         return 1;
  186.         }
  187.     }
  188.     return 0;
  189. }
  190.  
  191. public OnPlayerEnterCheckpoint(playerid) {
  192.     switch(MissionStage[playerid]) {
  193.         case STAGE_LOAD: {
  194.             new
  195.                 rand = random(sizeof gDeliverCPs)
  196.             ;
  197.             DisablePlayerCheckpoint(playerid);
  198.             GameTextForPlayer(playerid, "~g~Passengers Boarding !", 2000, 4);
  199.             TogglePlayerControllable(playerid, false); // Freeze the player
  200.             SetTimerEx("Unfreeze", 3000, false, "i", playerid); // Make a 3 second timer for that player to get unfroze
  201.             SetPlayerCheckpoint(playerid, gDeliverCPs[rand][0], gDeliverCPs[rand][1], gDeliverCPs[rand][2], 10.0);
  202.  
  203.             MissionStage[playerid] = STAGE_UNLOAD;
  204.         }
  205.         case STAGE_UNLOAD: {
  206.             DisablePlayerCheckpoint(playerid);
  207.  
  208.             GameTextForPlayer(playerid, "~g~Passengers UnLoading !", 2000, 4);
  209.             TogglePlayerControllable(playerid, false); // Freeze the player
  210.             SetTimerEx("Unfreeze", 3000, false, "i", playerid); // Make a 3 second timer for that player to get unfroze
  211.             SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
  212.             new cash = random(8000);
  213.             GivePlayerMoney(playerid, cash);
  214.             new
  215.                 string[64]
  216.             ;
  217.             GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  218.             strcat(string, " Completed a Taxi Mission!");
  219.             SendClientMessageToAll(COLOR_ORANGE, string);
  220.  
  221.             MissionStage[playerid] = STAGE_IDLE;
  222.         }
  223.     }
  224.     switch(MissionStge[playerid]) {
  225.         case STAGE_LOA: {
  226.             new
  227.                 rand = random(sizeof qDeliverCPs)
  228.             ;
  229.             DisablePlayerCheckpoint(playerid);
  230.             GameTextForPlayer(playerid, "~g~Passengers Boarding !", 2000, 4);
  231.             TogglePlayerControllable(playerid, false); // Freeze the player
  232.             SetTimerEx("Unfreeze", 3000, false, "i", playerid); // Make a 3 second timer for that player to get unfroze
  233.             SetPlayerCheckpoint(playerid, qDeliverCPs[rand][0], qDeliverCPs[rand][1], qDeliverCPs[rand][2], 10.0);
  234.  
  235.             MissionStge[playerid] = STAGE_UNLOA;
  236.         }
  237.         case STAGE_UNLOA: {
  238.             DisablePlayerCheckpoint(playerid);
  239.  
  240.             GameTextForPlayer(playerid, "~g~Passengers UnLoading !", 2000, 4);
  241.             TogglePlayerControllable(playerid, false); // Freeze the player
  242.             SetTimerEx("Unfreeze", 3000, false, "i", playerid); // Make a 3 second timer for that player to get unfroze
  243.             SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
  244.             new cash = random(8000);
  245.             GivePlayerMoney(playerid, cash);
  246.             new
  247.                 string[64]
  248.             ;
  249.             GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  250.             strcat(string, " Completed a Bus Haul!");
  251.             SendClientMessageToAll(COLOR_ORANGE, string);
  252.  
  253.             MissionStge[playerid] = STAGE_IDL;
  254.         }
  255.     }
  256.     return false;
  257. }
  258.  
  259. public OnPlayerDeath(playerid, killerid, reason){
  260.     MissionStge[playerid] = STAGE_IDL;
  261.     DisablePlayerCheckpoint(playerid);
  262.     MissionStage[playerid] = STAGE_IDLE;
  263.     DisablePlayerCheckpoint(playerid);
  264.     return true;
  265. }
  266.  
  267. forward Unfreeze(playerid);
  268. public Unfreeze(playerid)
  269. {
  270.     TogglePlayerControllable(playerid, true); // Unfreeze the player after 5 seconds
  271.     return 1;
  272. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement