Guest User

Gifts Distribuitor - by Edison NZ

a guest
Dec 23rd, 2015
2,894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 20.55 KB | None | 0 0
  1. /*
  2.     Created by: Edison NZ
  3.     Credits: Edison NZ(for script) and Valentino NZ(for maps)
  4.     My channel: www.youtube.com/c/EdisonNZ
  5. */
  6.  
  7. // Colors
  8. #define COLOR_WHITE 0xFFFFFFFF
  9. #define COLOR_LIGHTGREEN 0xAFFFA1FF
  10.  
  11. // Dialogs
  12. #define DIALOG_STATUS (333)
  13. #define DIALOG_JOB (334)
  14.  
  15. // Variables
  16. new Float:HousePos[16][3] = {
  17.     {2013.6630, -1656.3639, 14.0733},
  18.     {2018.2024, -1629.8944, 14.0733},
  19.     {1980.9697, -1719.0088, 17.0321},
  20.     {2066.9150, -1731.6338, 14.0879},
  21.     {2067.4844, -1643.7155, 14.0866},
  22.     {1853.9839, -1914.2035, 15.2474},
  23.     {1938.5319, -1911.3409, 15.1402},
  24.     {1928.5387, -1916.0127, 15.2403},
  25.     {2238.3540, -1906.7906, 14.9349},
  26.     {2307.0564, -1679.1633, 14.2915},
  27.     {2326.7124, -1716.8486, 13.8206},
  28.     {2385.3164, -1711.6276, 14.1911},
  29.     {2696.3904, -1990.4764, 14.1993},
  30.     {2787.2646, -1926.0974, 13.5604},
  31.     {1872.4790, -2132.6597, 15.5008},
  32.     {1667.4546, -2106.8040, 14.0209}
  33. };
  34.  
  35.  
  36. new
  37.     Timer[MAX_PLAYERS],
  38.     Working[MAX_PLAYERS],
  39.     Gifts[MAX_PLAYERS],
  40.     TotalGifts[MAX_PLAYERS],
  41.     GiftHand[MAX_PLAYERS],
  42.     Vehicle[MAX_PLAYERS],
  43.     Checkpoint[MAX_PLAYERS],
  44.     PlayerText: InfoTD,
  45.     jobVehicles[6],
  46.     jobActor,
  47.     jobPickup;
  48.  
  49. public OnGameModeInit() {
  50.     jobActor = CreateActor(112, 2244.5381, -2193.9580, 13.5469, 78.8678);
  51.     SetActorInvulnerable(jobActor, true);
  52.     ApplyActorAnimation(jobActor, "COP_AMBIENT", "Coplook_loop", 4.0, 0, 1, 1, 1, -1);
  53.     jobPickup = CreatePickup(1239, 23, 2243.8152,-2193.8157,13.5469);
  54.     Create3DTextLabel("/startwork", 0x0062FF99, 2243.8152,-2193.8157,13.5469, 10.0, 0);
  55.  
  56.     jobVehicles[0] = CreateVehicle(482, 2251.4128, -2186.0459, 13.6538, 134.9000, 3, 1, -1);
  57.     jobVehicles[1] = CreateVehicle(482, 2224.4158, -2159.3484, 13.6538, 135.0000, 3, 1, -1);
  58.     jobVehicles[2] = CreateVehicle(482, 2229.6980, -2164.4678, 13.6538, 135.0000, 3, 1, -1);
  59.     jobVehicles[3] = CreateVehicle(482, 2235.2888, -2169.8135, 13.6538, 135.0000, 3, 1, -1);
  60.     jobVehicles[4] = CreateVehicle(482, 2240.5559, -2175.1892, 13.6538, 135.0000, 3, 1, -1);
  61.     jobVehicles[5] = CreateVehicle(482, 2245.7339, -2180.4153, 13.6538, 135.0000, 3, 1, -1);
  62.  
  63.     CreateObject(19059, 2253.40039, -2183.45166, 17.46260,   0.00000, 90.00000, 45.00000);
  64.     CreateObject(19059, 2226.90356, -2156.94824, 17.46259,   0.00000, 90.00000, 45.00000);
  65.     CreateObject(19060, 2232.17334, -2162.20068, 17.46260,   0.00000, 90.00000, 45.00000);
  66.     CreateObject(19061, 2237.51318, -2167.51025, 17.46260,   0.00000, 90.00000, 45.00000);
  67.     CreateObject(19062, 2242.76733, -2172.80518, 17.46260,   0.00000, 90.00000, 45.00000);
  68.     CreateObject(19063, 2248.10010, -2178.14355, 17.46260,   0.00000, 90.00000, 45.00000);
  69.     CreateObject(2510, 2244.32959, -2186.91162, 20.80740,   0.00000, 0.00000, 90.00000);
  70.     CreateObject(2510, 2225.16260, -2166.36548, 20.80740,   0.00000, 0.00000, 0.00000);
  71.     CreateObject(2510, 2233.41479, -2181.15625, 20.80740,   0.00000, 0.00000, 45.00000);
  72.     CreateObject(1568, 2213.29590, -2165.32520, 13.34210,   0.00000, 0.00000, 0.00000);
  73.     CreateObject(1568, 2244.87207, -2196.93555, 13.34215,   0.00000, 0.00000, 0.00000);
  74.     CreateObject(1568, 2243.37622, -2177.72583, 12.54010,   0.00000, 0.00000, 0.00000);
  75.     CreateObject(1568, 2237.82471, -2172.34839, 12.54010,   0.00000, 0.00000, 0.00000);
  76.     CreateObject(1568, 2232.51343, -2167.08398, 12.54010,   0.00000, 0.00000, 0.00000);
  77.     CreateObject(1568, 2248.67065, -2182.95654, 12.54014,   0.00000, 0.00000, 0.00000);
  78.     CreateObject(1568, 2226.98999, -2161.66821, 12.54010,   0.00000, 0.00000, 0.00000);
  79.  
  80.     CreateObject(19057, 2786.34985, -2446.70923, 13.13820,   0.00000, 0.00000, 0.00000);
  81.     CreateObject(19054, 2789.31738, -2446.70923, 13.13820,   0.00000, 0.00000, 0.00000);
  82.     CreateObject(19056, 2787.84570, -2446.70923, 13.13820,   0.00000, 0.00000, 0.00000);
  83.     CreateObject(19054, 2789.31738, -2449.86206, 13.13820,   0.00000, 0.00000, 0.00000);
  84.     CreateObject(19057, 2789.31738, -2448.29248, 13.13820,   0.00000, 0.00000, 0.00000);
  85.     CreateObject(19056, 2777.63428, -2462.71924, 13.13820,   0.00000, 0.00000, 359.89999);
  86.     CreateObject(19055, 2786.34985, -2448.29248, 13.13820,   0.00000, 0.00000, 0.00000);
  87.     CreateObject(19055, 2787.84570, -2449.86206, 13.13820,   0.00000, 0.00000, 0.00000);
  88.     CreateObject(19058, 2787.84570, -2448.29248, 13.13820,   0.00000, 0.00000, 0.00000);
  89.     CreateObject(19057, 2789.31738, -2464.06738, 13.13820,   0.00000, 0.00000, 0.00000);
  90.     CreateObject(19054, 2789.31738, -2465.52002, 13.13816,   0.00000, 0.00000, 0.00000);
  91.     CreateObject(19054, 2789.31738, -2462.62280, 13.13820,   0.00000, 0.00000, 0.00000);
  92.     CreateObject(19056, 2787.84570, -2462.62280, 13.13820,   0.00000, 0.00000, 0.00000);
  93.     CreateObject(19058, 2787.84570, -2464.06738, 13.13820,   0.00000, 0.00000, 0.00000);
  94.     CreateObject(19055, 2787.84570, -2465.52002, 13.13820,   0.00000, 0.00000, 0.00000);
  95.     CreateObject(19056, 2786.34985, -2465.52002, 13.13820,   0.00000, 0.00000, 0.00000);
  96.     CreateObject(19055, 2786.34985, -2464.06738, 13.13820,   0.00000, 0.00000, 0.00000);
  97.     CreateObject(19057, 2786.34985, -2462.62280, 13.13820,   0.00000, 0.00000, 0.00000);
  98.     CreateObject(2510, 2773.17163, -2456.02759, 17.16240,   0.00000, -10.00000, -90.00000);
  99.     CreateObject(1568, 2773.80566, -2461.31982, 12.63910,   0.00000, 0.00000, 0.00000);
  100.     CreateObject(1568, 2773.80566, -2450.53760, 12.63907,   0.00000, 0.00000, 0.00000);
  101.     CreateObject(19056, 2786.34985, -2449.86206, 13.13820,   0.00000, 0.00000, 0.00000);
  102.     CreateObject(19055, 2778.33594, -2447.31152, 13.13820,   0.00000, 0.00000, 0.00000);
  103.     CreateObject(19056, 2780.14063, -2446.76660, 13.13820,   0.00000, 0.00000, 0.00000);
  104.     CreateObject(19057, 2779.72119, -2448.80005, 13.13820,   0.00000, 0.00000, 0.00000);
  105.     CreateObject(19057, 2780.64990, -2464.70923, 13.13820,   0.00000, 0.00000, 0.00000);
  106.     CreateObject(19058, 2778.50708, -2464.92896, 13.13820,   0.00000, 0.00000, 359.89999);
  107.     CreateObject(19055, 2779.95483, -2462.62939, 13.13820,   0.00000, 0.00000, 359.89999);
  108.     CreateObject(2469, 2791.98853, -2461.35938, 14.27980,   0.00000, 0.00000, 180.00000);
  109.     CreateObject(2464, 2783.76294, -2461.34741, 14.45417,   0.00000, 0.00000, 0.00000);
  110.     CreateObject(2469, 2783.71924, -2450.59106, 14.32223,   0.00000, 0.00000, 0.00000);
  111.     CreateObject(2464, 2783.71167, -2450.90771, 12.84029,   0.00000, 0.00000, 0.00000);
  112.     CreateObject(2480, 2783.78296, -2450.94409, 15.75139,   0.00000, 0.00000, 0.00000);
  113.     CreateObject(2474, 2791.78979, -2450.48413, 12.74016,   0.00000, 0.00000, 0.00000);
  114.     CreateObject(2464, 2791.92749, -2450.95142, 15.24909,   0.00000, 0.00000, 0.00000);
  115.     CreateObject(2485, 2792.01172, -2451.08716, 14.32813,   0.00000, 0.00000, 0.00000);
  116.     CreateObject(2466, 2783.76294, -2461.34741, 13.65120,   0.00000, 0.00000, 180.00000);
  117.     CreateObject(2468, 2791.80713, -2461.36426, 13.43120,   0.00000, 0.00000, 180.00000);
  118.     CreateObject(2484, 2794.80347, -2448.80249, 13.52007,   0.00000, 0.00000, 45.00000);
  119.     CreateObject(2492, 2794.05786, -2466.00391, 13.73340,   0.00000, 0.00000, -135.00000);
  120.     CreateObject(2493, 2793.82397, -2465.78564, 13.73340,   0.00000, 0.00000, 45.00000);
  121.     CreateObject(2494, 2794.05420, -2465.77173, 13.73340,   0.00000, 0.00000, -45.00000);
  122.     CreateObject(2491, 2793.93652, -2465.53589, 12.73470,   0.00000, 0.00000, 45.00000);
  123.  
  124.     SetTimer("jobCheck", 1000, true);
  125.     print("\nJob Christmass loaded...");
  126.     print("Credits: Edison, Valentino.");
  127.     return 1;
  128. }
  129.  
  130. public OnPlayerConnect(playerid) {
  131.     Working[playerid] = -1;
  132.     Gifts[playerid] = 0;
  133.     Checkpoint[playerid] = -1;
  134.     TotalGifts[playerid] = 0;
  135.  
  136.     InfoTD = CreatePlayerTextDraw(playerid, 173.821395, 374.500091, "");
  137.     PlayerTextDrawLetterSize(playerid, InfoTD, 0.256500, 1.279167);
  138.     PlayerTextDrawAlignment(playerid, InfoTD, 1);
  139.     PlayerTextDrawColor(playerid, InfoTD, -1);
  140.     PlayerTextDrawSetShadow(playerid, InfoTD, 0);
  141.     PlayerTextDrawSetOutline(playerid, InfoTD, 1);
  142.     PlayerTextDrawBackgroundColor(playerid, InfoTD, 51);
  143.     PlayerTextDrawFont(playerid, InfoTD, 1);
  144.     PlayerTextDrawSetProportional(playerid, InfoTD, 1);
  145.  
  146.     RemoveBuildingForPlayer(playerid, 3744, 2241.2969, -2183.9766, 15.1016, 0.25);
  147.     RemoveBuildingForPlayer(playerid, 3744, 2226.3203, -2168.9922, 15.1016, 0.25);
  148.     RemoveBuildingForPlayer(playerid, 1226, 2224.7813, -2185.7422, 16.3516, 0.25);
  149.     RemoveBuildingForPlayer(playerid, 3574, 2226.3203, -2168.9922, 15.1016, 0.25);
  150.     RemoveBuildingForPlayer(playerid, 3574, 2241.2969, -2183.9766, 15.1016, 0.25);
  151.     return 1;
  152. }
  153.  
  154. public OnPlayerDeath(playerid, killerid, reason) {
  155.     JobFailed(playerid);
  156.     return 1;
  157. }
  158.  
  159. public OnPlayerCommandText(playerid, cmdtext[]) {
  160.     if(strcmp("/stopwork", cmdtext, true, 10) == 0)
  161.     {
  162.         if(Working[playerid] == -1) return 1;
  163.         DisablePlayerCheckpoint(playerid);
  164.         Working[playerid] = -1;
  165.         Gifts[playerid] = 0;
  166.         Checkpoint[playerid] = -1;
  167.         TotalGifts[playerid] = 0;
  168.         if(Vehicle[playerid] != -1) SetVehicleToRespawn(Vehicle[playerid]);
  169.         Vehicle[playerid] = -1;
  170.         SendClientMessage(playerid, COLOR_WHITE, "Stop working...");
  171.         if(Timer[playerid] >= 1) { Timer[playerid] = -1; PlayerTextDrawHide(playerid, InfoTD); }
  172.         return 1;
  173.     }
  174.     return 0;
  175. }
  176.  
  177. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) {
  178.     if(vehicleid == jobVehicles[0] || vehicleid == jobVehicles[1] || vehicleid == jobVehicles[2] || vehicleid == jobVehicles[3] || vehicleid == jobVehicles[4] || vehicleid == jobVehicles[5]) {
  179.         if(Working[playerid] == -1) {
  180.             new Float: Position[3];
  181.             GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
  182.             SetPlayerPos(playerid, Position[0], Position[1], Position[2]+1);
  183.             SendClientMessage(playerid, COLOR_WHITE, "You do not work!");
  184.         }
  185.         else {
  186.             if(Timer[playerid] >= 1) { Timer[playerid] = -1; PlayerTextDrawHide(playerid, InfoTD); }
  187.         }      
  188.     }
  189.     return 1;
  190. }
  191.  
  192. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  193.     new string[256];
  194.     if(newkeys == KEY_NO) {
  195.         if(Working[playerid] == -1) return 1;
  196.         if(IsPlayerInAnyVehicle(playerid)) return 1;
  197.         if(Vehicle[playerid] == -1 && Working[playerid] == 1) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "* You must to climb in a vehicle and after upload gifts.");
  198.         if(CheckPlayerDistanceToVehicle(5.0, playerid, Vehicle[playerid])) {
  199.             RemovePlayerAttachedObject(playerid, 5);
  200.             if(TotalGifts[playerid] == 0) return 1;
  201.             if(GiftHand[playerid] == -1) {
  202.                 GiftHand[playerid] = 1;
  203.                 SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
  204.                 new rand = random(4), gift;
  205.                 if(rand == 0) gift = 19054;
  206.                 else if(rand == 1) gift = 19055;
  207.                 else if(rand == 2) gift = 19056;
  208.                 else if(rand == 3) gift = 19057;                               
  209.                 else if(rand == 4) gift = 19058;   
  210.                 SetPlayerAttachedObject( playerid, 5, gift, 1, 0.179536, 0.436568, -0.047055, 0.000000, 84.821968, 77.998138, 0.405070, 1.000000, 0.225547 );
  211.                 SendClientMessage(playerid, COLOR_WHITE, "* You have took one gift from your vehicle!");
  212.             }        
  213.             else if(GiftHand[playerid] == 1) {
  214.                 GiftHand[playerid] = -1;
  215.                 RemovePlayerAttachedObject(playerid, 5);
  216.                 SetPlayerSpecialAction(playerid, 0);
  217.                 SendClientMessage(playerid, COLOR_WHITE, "* You have put the gift in your vehicle!");
  218.                 if(TotalGifts[playerid] < 9 && Checkpoint[playerid] == -1) {
  219.                     format(string, sizeof(string), "{FFBC63}Want to get gifts?\nCurrently, you have only {94FF63}%d gifts{FFFFFF}.", TotalGifts[playerid]);
  220.                     ShowPlayerDialog(playerid, DIALOG_STATUS, DIALOG_STYLE_MSGBOX, " ", string, "Yes", "No");
  221.                 }
  222.                 if(Gifts[playerid] == 10) {
  223.                     format(string, sizeof(string), "{FFBC63}Congratulations, {638DFF}%s{FFBC63}!\nYou have {94FF63}finished{FFBC63} the step one. Next step consist to distrbuite gifts on different houses. Success!", GetName(playerid));
  224.                     ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, " ", string, "Okay", "");
  225.                     new rand = random(sizeof(HousePos));
  226.                     SetPlayerCheckpoint(playerid, HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2], 2.0);
  227.                     format(string, sizeof(string), "You have still %d gifts distributed! Distance: %0.2fm", Gifts[playerid], GetPlayerDistanceFromPoint(playerid,  HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2]));
  228.                     SendClientMessage(playerid, 0xFFFF00FF, string);       
  229.                     Checkpoint[playerid] = 1;
  230.                 }
  231.             }
  232.         }
  233.         else if(IsPlayerInRangeOfPoint(playerid, 5.0,2779.7212, -2448.8000, 13.1382) || IsPlayerInRangeOfPoint(playerid, 5.0,2787.8457, -2449.8621, 13.1382)
  234.         || IsPlayerInRangeOfPoint(playerid, 5.0,2787.8457, -2462.6228, 13.1382) || IsPlayerInRangeOfPoint(playerid, 5.0,2779.9548, -2462.6294, 13.1382)) {
  235.             if(Gifts[playerid] == 10) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "* You have a maximum gifts (10).");
  236.             if(GiftHand[playerid] == 1) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "* You already have a gift in your hands!");
  237.             Gifts[playerid] ++;
  238.             TotalGifts[playerid] ++;
  239.             new rand = random(4), gift;
  240.             if(rand == 0) gift = 19054;
  241.             else if(rand == 1) gift = 19055;
  242.             else if(rand == 2) gift = 19056;
  243.             else if(rand == 3) gift = 19057;                               
  244.             else if(rand == 4) gift = 19058;   
  245.             SetPlayerAttachedObject( playerid, 5, gift, 1, 0.179536, 0.436568, -0.047055, 0.000000, 84.821968, 77.998138, 0.405070, 1.000000, 0.225547 );
  246.             SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
  247.             GiftHand[playerid] = 1;
  248.         }
  249.     }
  250.     return 1;
  251. }
  252.  
  253. public OnPlayerExitVehicle(playerid, vehicleid) {
  254.     if(Working[playerid] == 1 && TotalGifts[playerid] >= 1 && vehicleid == jobVehicles[0] || vehicleid == jobVehicles[1] || vehicleid == jobVehicles[2] || vehicleid == jobVehicles[3] || vehicleid == jobVehicles[4] || vehicleid == jobVehicles[5] && Gifts[playerid] != 0) {
  255.         SendClientMessage(playerid, COLOR_WHITE, "You have one minute to distribute gift on the checkpoint!");
  256.         Timer[playerid] = 60;
  257.         PlayerTextDrawSetString(playerid, InfoTD, "~y~Gift Distributor~w~~h~~n~You have 60 seconds until you enter in the vehicle.");
  258.         PlayerTextDrawShow(playerid, InfoTD);
  259.     }
  260.     return 1;
  261. }
  262.  
  263. public OnPlayerStateChange(playerid, newstate, oldstate) {
  264.     if(newstate == PLAYER_STATE_DRIVER) {
  265.         new vehicleid = GetPlayerVehicleID(playerid);
  266.         if(vehicleid == jobVehicles[0] || vehicleid == jobVehicles[1] || vehicleid == jobVehicles[2] || vehicleid == jobVehicles[3] || vehicleid == jobVehicles[4] || vehicleid == jobVehicles[5] && Gifts[playerid] == 0) {
  267.             if(TotalGifts[playerid] != 0) return 1;
  268.             Vehicle[playerid] = vehicleid;
  269.             SendClientMessage(playerid, COLOR_WHITE, "Go to red checkpoint to load gifts!");
  270.             SetPlayerCheckpoint(playerid, 2774.2368, -2455.7124, 12.6391, 8.0);
  271.             Checkpoint[playerid] = 3;
  272.         }  
  273.     }
  274.     return 1;
  275. }
  276.  
  277. public OnPlayerEnterCheckpoint(playerid) {
  278.     new string[256];
  279.     if(Checkpoint[playerid] == 1) {
  280.         if(GiftHand[playerid] == -1) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "* You not have a gift in your hands!");
  281.         DisablePlayerCheckpoint(playerid);
  282.         SetPlayerSpecialAction(playerid, 0);
  283.         Gifts[playerid] --;
  284.         GiftHand[playerid] = -1;
  285.         RemovePlayerAttachedObject(playerid, 5);
  286.         new rand = random(sizeof(HousePos));
  287.         SetPlayerCheckpoint(playerid, HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2], 2.0);
  288.         if(Gifts[playerid] != 0) {
  289.             Checkpoint[playerid] = 1;
  290.             format(string, sizeof(string), "You have still %d gifts distributed! Distance: %0.2fm", Gifts[playerid], GetPlayerDistanceFromPoint(playerid,  HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2]));
  291.             SendClientMessage(playerid, 0xFFFF00FF, string);
  292.         }
  293.         // de terminat
  294.         if(Gifts[playerid] == 0) {
  295.             Gifts[playerid] = -1;
  296.             DisablePlayerCheckpoint(playerid);
  297.             SetPlayerCheckpoint(playerid, 2251.8628, -2206.0054, 13.4719, 9.0);
  298.             Checkpoint[playerid] = 2;
  299.             format(string, sizeof(string), "{FFBC63}Congratulations, {638DFF}%s{FFBC63}!\nYou have {94FF63}finished{FFBC63} the step two. The last step is to go to the checkpoint to take the money!", GetName(playerid));
  300.             ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, " ", string, "Okay", "");
  301.         }
  302.         return 1;
  303.     }
  304.     if(Checkpoint[playerid] == 2) {
  305.         if(IsPlayerInVehicle(playerid, Vehicle[playerid])) SetVehicleToRespawn(Vehicle[playerid]);
  306.         DisablePlayerCheckpoint(playerid);
  307.         new money = 1000 + random(500) * TotalGifts[playerid];
  308.         format(string, sizeof(string), "You delivered %d gifts.", TotalGifts[playerid]);
  309.         SendClientMessage(playerid, 0x25B336FF, string);
  310.         format(string, sizeof(string), "Congratulations, you have earned $%d.", money);
  311.         SendClientMessage(playerid, 0x25B336FF, string);
  312.         GivePlayerMoney(playerid, money);
  313.         TotalGifts[playerid] = 0;
  314.         Checkpoint[playerid] = -1;
  315.         Working[playerid] = -1;
  316.         return 1;
  317.     }
  318.     if(Checkpoint[playerid] == 3) {
  319.         DisablePlayerCheckpoint(playerid);
  320.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Go to gifts and use key N to load a gift!");
  321.         Checkpoint[playerid] = -1;
  322.         return 1;
  323.     }
  324.     return 1;
  325. }
  326.  
  327. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  328.     new string[256];
  329.     switch(dialogid) {
  330.         case DIALOG_STATUS: {
  331.             if(response) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Continue to take gifts!");
  332.             format(string, sizeof(string), "{FFBC63}Congratulations, {638DFF}%s{FFBC63}!\nYou have {94FF63}finished{FFBC63} the step one. Next step consist to distrbuite gifts on different houses. Success!", GetName(playerid));
  333.             ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, " ", string, "Okay", "");
  334.             new rand = random(sizeof(HousePos));
  335.             SetPlayerCheckpoint(playerid, HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2], 2.0);
  336.             format(string, sizeof(string), "You have still %d gifts distributed! Distance: %0.2fm", Gifts[playerid], GetPlayerDistanceFromPoint(playerid,  HousePos[rand][0] ,HousePos[rand][1], HousePos[rand][2]));
  337.             SendClientMessage(playerid, 0xFFFF00FF, string);       
  338.             Checkpoint[playerid] = 1;
  339.         }
  340.         case DIALOG_JOB: {
  341.             if(!response) return 1;
  342.             if(Working[playerid] == 1) return 1;
  343.             Working[playerid] = 1;
  344.             TotalGifts[playerid] = 0;
  345.             Gifts[playerid] = 0;
  346.             SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Congratulations! Now you can working on job.");
  347.         }
  348.     }
  349.     return 1;
  350. }
  351.  
  352. public OnPlayerSpawn(playerid)
  353. {
  354.     SetPlayerPos(playerid, 2224.7813, -2185.7422, 16.3516);
  355.     return 1;
  356. }
  357.  
  358. public OnPlayerPickUpPickup(playerid, pickupid)
  359. {
  360.     if(pickupid == jobPickup) {
  361.         if(Working[playerid] == 1) return 1;
  362.         new string[1024];
  363.         strcat(string, "{FFBC63}Welcome to job {638DFF}Gift Distribuitor{FFBC63}!\n\nInformations:\n{638DFF}•{FFBC63} There are two steps to this job.\n{638DFF}•{FFBC63} The first step is that you must go to the warehouse to load");
  364.         strcat(string, "gifts in the vehicle from job.\n{638DFF}•{FFBC63} The second and final step at the same time have to go to some houses (depending on how many");
  365.         strcat(string, "gifts you get from the warehouse).\n{638DFF}•{FFBC63} Finally, you get a checkpoint and have to go to him. Once you get into it, get some money");
  366.         strcat(string, "(depending on how many gifts you had).\n{638DFF}•{FFBC63} If you want to not work, use the command {638DFF}/stopwork{FFBC63}!\n\nDo you start work? If so, click the button {94FF63}Start!{FFBC63}");
  367.         ShowPlayerDialog(playerid, DIALOG_JOB, DIALOG_STYLE_MSGBOX, " ", string, "Start", "Close");
  368.     }
  369.     return 1;
  370. }
  371.  
  372. forward jobCheck();
  373. public jobCheck() {
  374.  
  375.     new string[256];
  376.     for(new i = 0; i < MAX_PLAYERS; i++) {
  377.         if(IsPlayerConnected(i)) {
  378.             if(Timer[i] >= 1) {
  379.                 Timer[i] --;
  380.                 format(string, sizeof(string), "~y~Gift Distributor~w~~h~~n~You have %d seconds until you enter the vehicle.", Timer);
  381.                 PlayerTextDrawSetString(i, InfoTD, string);
  382.                 PlayerTextDrawShow(i, InfoTD);
  383.                 if(Timer[i] == 0) {
  384.                     Timer[i] = -1;
  385.                     JobFailed(i);
  386.                     PlayerTextDrawHide(i, InfoTD);
  387.                 }
  388.             }
  389.         }
  390.     }
  391.     return 1;
  392. }
  393.  
  394. stock JobFailed(playerid) {
  395.     if(Working[playerid] == 1) {
  396.         DisablePlayerCheckpoint(playerid);
  397.         Working[playerid] = -1;
  398.         Gifts[playerid] = 0;
  399.         Checkpoint[playerid] = -1;
  400.         TotalGifts[playerid] = 0;
  401.         SetVehicleToRespawn(Vehicle[playerid]);
  402.         Vehicle[playerid] = -1;
  403.         SendClientMessage(playerid, COLOR_LIGHTGREEN, "* Job failed!");
  404.         SendClientMessage(playerid, COLOR_WHITE, "You lose the car and gifts.");
  405.     }
  406.     return 1;
  407. }
  408.  
  409. stock GetName(playerid) {
  410.     new
  411.         pName[MAX_PLAYER_NAME];
  412.  
  413.     GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  414.     return pName;
  415. }
  416.  
  417. stock CheckPlayerDistanceToVehicle(Float:radi, playerid, vehicleid) {
  418.     if(IsPlayerConnected(playerid)) {
  419.         new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z;
  420.         GetPlayerPos(playerid,PX,PY,PZ);
  421.         GetVehiclePos(vehicleid, X,Y,Z);
  422.         new Float:Distance = (X-PX)*(X-PX)+(Y-PY)*(Y-PY)+(Z-PZ)*(Z-PZ);
  423.         if(Distance <= radi*radi) return 1;
  424.     }
  425.     return 0;
  426. }
Advertisement
Add Comment
Please, Sign In to add comment