Kwarde

Folder Delivery Sytem - 1.0 [BETA]

Nov 6th, 2010
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.98 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define COLOR_WHITE 0xFFFFFFAA
  4. #define COLOR_RED 0xFF0000AA
  5. #define COLOR_GREEN 0x00FF00AA
  6.  
  7. new LS_Ganton;
  8. new LS_Jefferson;
  9. new LS_PlayaDelSeville;
  10. new LS_VerdantBluffs;
  11.  
  12. new MoneyPerFolder = 150;
  13. new MinFolders = 10;
  14. new MaxFolders = 30;
  15.  
  16. enum pFJInfo__ENUM()
  17. {
  18.     bool:JobStarted,
  19.     CurrentStreetID,
  20.     CurrentStreetName[65],
  21.     MoneyThisRound,
  22.     CheckForAreaTimer,
  23.     FailTimer,
  24.     bool:TimerStarted,
  25.     SecondsInArea,
  26.     bool:StreetIsFlashing
  27. };
  28. new pFJInfo[MAX_PLAYERS][pFJInfo__ENUM];
  29.  
  30. forward CheckPlayerInArea(playerid);
  31. forward FailDelivery(playerid);
  32.  
  33. public OnFilterScriptInit()
  34. {
  35.     print(" ");
  36.     print("\n ** Folder Delivery Job v1.0 - By Kwarde :: LOADING...");
  37.    
  38.     LS_Ganton = GangZoneCreate(2220.01, -1741.078, 2531.842, -1634.489);
  39.     LS_Jefferson = GangZoneCreate(2071.699, -1381.833, 2261.841, -1223.924);
  40.     LS_PlayaDelSeville = GangZoneCreate(2706.773, -2068.74, 2790.435, -1906.883);
  41.     LS_VerdantBluffs = GangZoneCreate(2706.773, -2068.74, 2790.435, -1906.883);
  42.    
  43.     print("\n** Folder Delivery Job v1.0 - By Kwarde :: LOADED");
  44.     print("** Good luck with delivering the folders");
  45.     print(" ");
  46.     return 1;
  47. }
  48.  
  49. public OnFilterScriptExit()
  50. {
  51.     for(new i = 0; i < MAX_PLAYERS; i++)
  52.         if(IsPlayerConnected(i) && pFJInfo[i][JobStarted])
  53.             StopPlayerJob(i);
  54.     GangZoneDestroy(LS_Ganton);
  55.     GangZoneDestroy(LS_Jefferson);
  56.     GangZoneDestroy(LS_PlayaDelSeville);
  57.     GangZoneDestroy(LS_VerdantBluffs);
  58.     print(" ");
  59.     print("\n ** Folder Delivery Job v1.0 - By Kwarde :: UNLOADED");
  60.     print(" ");
  61.     return 1;
  62. }
  63.  
  64. public OnPlayerCommandText(playerid, cmdtext[])
  65. {
  66.     if(!strcmp(cmdtext, "/startfj", true)){
  67.         if(pFJInfo[playerid][JobStarted]) return SendClientMessage(playerid, COLOR_RED, "FolderChief: You can only do one job at once!");
  68.         StartPlayerJob(playerid);
  69.     }
  70.     if(!strcmp(cmdtext, "/stopfj", true)){
  71.         if(!pFJInfo[playerid][JobStarted]) return SendClientMessage(playerid, COLOR_RED, "FolderChief: You didn't start a job by us yet!");
  72.         StopPlayerJob(playerid);
  73.         SendClientMessage(playerid, COLOR_RED, "FolderChief: Ok. You've stopped your job. You can go back at any time");
  74.     }
  75.     return 0;
  76. }
  77.  
  78. public CheckPlayerInArea(playerid)
  79. {
  80.     new pTmpName[MAX_PLAYER_NAME], string[128];
  81.     GetPlayerName(playerid, pTmpName, MAX_PLAYER_NAME);
  82.     if(pFJInfo[playerid][JobStarted]){
  83.         if(pFJInfo[playerid][CurrentStreetID] == 1){
  84.             if(IsPlayerInArea(playerid, 2220.01, -1741.078, 2531.842, -1634.489)){
  85.                 if(!pFJInfo[playerid][StreetIsFlashing]){
  86.                     GangZoneFlashForPlayer(playerid, LS_Ganton, COLOR_RED);
  87.                     pFJInfo[playerid][StreetIsFlashing] = true;
  88.                 }
  89.                 if(pFJInfo[playerid][SecondsInArea] == 0)
  90.                     SendClientMessage(playerid, COLOR_GREEN, "FolderChief: Good. Now stay here 60 seconds");
  91.                 pFJInfo[playerid][SecondsInArea]++;
  92.                 if(pFJInfo[playerid][SecondsInArea] >= 60){
  93.                     SendClientMessage(playerid, COLOR_GREEN, "FolderChief: Nicely done! You've completed your job!");
  94.                     format(string, sizeof(string), "FolderChief: You've received $%d,- for delivering folders in %s", pFJInfo[playerid][MoneyThisRound], pFJInfo[playerid][CurrentStreetName]);
  95.                     SendClientMessage(playerid, COLOR_GREEN, string);
  96.                     format(string, sizeof(string), "FolderChief: Please come back any time %s, we want you!", pTmpName);
  97.                     SendClientMessage(playerid, COLOR_GREEN, string);
  98.                     StopPlayerJob(playerid);
  99.                 }
  100.             }
  101.             if(!IsPlayerInArea(playerid, 2220.01, -1741.078, 2531.842, -1634.48) && pFJInfo[playerid][SecondsInArea] > 0){
  102.                 format(string, sizeof(string), "FolderChief: %s, don't leave there! Go back to your street, NOW!", pTmpName);
  103.                 SendClientMessage(playerid, COLOR_RED, string);
  104.                 pFJInfo[playerid][SecondsInArea] = 0;
  105.             }
  106.             if(!IsPlayerInArea(playerid, 2220.01, -1741.078, 2531.842, -1634.48) && pFJInfo[playerid][StreetIsFlashing]){
  107.                 GangZoneStopFlashForPlayer(playerid, LS_Ganton);
  108.                 pFJInfo[playerid][StreetIsFlashing] = false;
  109.             }
  110.         }
  111.         else if(pFJInfo[playerid][CurrentStreetID] == 2){
  112.             if(IsPlayerInArea(playerid, 2071.699, -1381.833, 2261.841, -1223.924)){
  113.                 if(!pFJInfo[playerid][StreetIsFlashing]){
  114.                     GangZoneFlashForPlayer(playerid, LS_Jefferson, COLOR_RED);
  115.                     pFJInfo[playerid][StreetIsFlashing] = true;
  116.                 }
  117.                 if(pFJInfo[playerid][SecondsInArea] == 0)
  118.                     SendClientMessage(playerid, COLOR_GREEN, "FolderChief: Good. Now stay here 60 seconds");
  119.                 pFJInfo[playerid][SecondsInArea]++;
  120.                 if(pFJInfo[playerid][SecondsInArea] >= 120){
  121.                     SendClientMessage(playerid, COLOR_GREEN, "FolderChief: Nicely done! You've completed your job!");
  122.                     format(string, sizeof(string), "FolderChief: You've received $%d,- for delivering folders in %s", pFJInfo[playerid][MoneyThisRound], pFJInfo[playerid][CurrentStreetName]);
  123.                     SendClientMessage(playerid, COLOR_GREEN, string);
  124.                     format(string, sizeof(string), "FolderChief: Please come back any time %s, we want you!", pTmpName);
  125.                     SendClientMessage(playerid, COLOR_GREEN, string);
  126.                     StopPlayerJob(playerid);
  127.                 }
  128.             }
  129.             if(!IsPlayerInArea(playerid, 2071.699, -1381.833, 2261.841, -1223.924) && pFJInfo[playerid][SecondsInArea] > 0){
  130.                 format(string, sizeof(string), "FolderChief: %s, don't leave there! Go back to your street, NOW!", pTmpName);
  131.                 SendClientMessage(playerid, COLOR_RED, string);
  132.                 pFJInfo[playerid][SecondsInArea] = 0;
  133.             }
  134.             if(!IsPlayerInArea(playerid, 2071.699, -1381.833, 2261.841, -1223.924) && pFJInfo[playerid][StreetIsFlashing]){
  135.                 GangZoneStopFlashForPlayer(playerid, LS_Jefferson);
  136.                 pFJInfo[playerid][StreetIsFlashing] = false;
  137.             }
  138.         }
  139.         else if(pFJInfo[playerid][CurrentStreetID] == 3){
  140.             if(IsPlayerInArea(playerid, 2706.773, -2068.74, 2790.435, -1906.883)){
  141.                 if(!pFJInfo[playerid][StreetIsFlashing]){
  142.                     GangZoneFlashForPlayer(playerid, LS_PlayaDelSeville, COLOR_RED);
  143.                     pFJInfo[playerid][StreetIsFlashing] = true;
  144.                 }
  145.                 if(pFJInfo[playerid][SecondsInArea] == 0)
  146.                     SendClientMessage(playerid, COLOR_GREEN, "FolderChief: Good. Now stay here 60 seconds");
  147.                 pFJInfo[playerid][SecondsInArea]++;
  148.                 if(pFJInfo[playerid][SecondsInArea] >= 120){
  149.                     SendClientMessage(playerid, COLOR_GREEN, "FolderChief: Nicely done! You've completed your job!");
  150.                     format(string, sizeof(string), "FolderChief: You've received $%d,- for delivering folders in %s", pFJInfo[playerid][MoneyThisRound], pFJInfo[playerid][CurrentStreetName]);
  151.                     SendClientMessage(playerid, COLOR_GREEN, string);
  152.                     format(string, sizeof(string), "FolderChief: Please come back any time %s, we want you!", pTmpName);
  153.                     SendClientMessage(playerid, COLOR_GREEN, string);
  154.                     StopPlayerJob(playerid);
  155.                 }
  156.             }
  157.             if(!IsPlayerInArea(playerid, 2706.773, -2068.74, 2790.435, -1906.883) && pFJInfo[playerid][SecondsInArea] > 0){
  158.                 format(string, sizeof(string), "FolderChief: %s, don't leave there! Go back to your street, NOW!", pTmpName);
  159.                 SendClientMessage(playerid, COLOR_RED, string);
  160.                 pFJInfo[playerid][SecondsInArea] = 0;
  161.             }
  162.             if(!IsPlayerInArea(playerid,2706.773, -2068.74, 2790.435, -1906.8838) && pFJInfo[playerid][StreetIsFlashing]){
  163.                 GangZoneStopFlashForPlayer(playerid, LS_PlayaDelSeville);
  164.                 pFJInfo[playerid][StreetIsFlashing] = false;
  165.             }
  166.         }
  167.         else if(pFJInfo[playerid][CurrentStreetID] == 4){
  168.             if(IsPlayerInArea(playerid, 2706.773, -2068.74, 2790.435, -1906.883)){
  169.                 if(!pFJInfo[playerid][StreetIsFlashing]){
  170.                     GangZoneFlashForPlayer(playerid, LS_VerdantBluffs, COLOR_RED);
  171.                     pFJInfo[playerid][StreetIsFlashing] = true;
  172.                 }
  173.                 if(pFJInfo[playerid][SecondsInArea] == 0)
  174.                     SendClientMessage(playerid, COLOR_GREEN, "FolderChief: Good. Now stay here 60 seconds");
  175.                 pFJInfo[playerid][SecondsInArea]++;
  176.                 if(pFJInfo[playerid][SecondsInArea] >= 120){
  177.                     SendClientMessage(playerid, COLOR_GREEN, "FolderChief: Nicely done! You've completed your job!");
  178.                     format(string, sizeof(string), "FolderChief: You've received $%d,- for delivering folders in %s", pFJInfo[playerid][MoneyThisRound], pFJInfo[playerid][CurrentStreetName]);
  179.                     SendClientMessage(playerid, COLOR_GREEN, string);
  180.                     format(string, sizeof(string), "FolderChief: Please come back any time %s, we want you!", pTmpName);
  181.                     SendClientMessage(playerid, COLOR_GREEN, string);
  182.                     StopPlayerJob(playerid);
  183.                 }
  184.             }
  185.             if(!IsPlayerInArea(playerid, 2706.773, -2068.74, 2790.435, -1906.883) && pFJInfo[playerid][SecondsInArea] > 0){
  186.                 format(string, sizeof(string), "FolderChief: %s, don't leave there! Go back to your street, NOW!", pTmpName);
  187.                 SendClientMessage(playerid, COLOR_RED, string);
  188.                 pFJInfo[playerid][SecondsInArea] = 0;
  189.             }
  190.             if(!IsPlayerInArea(playerid, 2706.773, -2068.74, 2790.435, -1906.883) && pFJInfo[playerid][StreetIsFlashing]){
  191.                 GangZoneStopFlashForPlayer(playerid, LS_VerdantBluffs);
  192.                 pFJInfo[playerid][StreetIsFlashing] = false;
  193.             }
  194.         }
  195.     }
  196.     return 1;
  197. }
  198.  
  199. public FailDelivery(playerid)
  200. {
  201.     new pTmpName[MAX_PLAYER_NAME], string[128];
  202.     GetPlayerName(playerid, pTmpName, MAX_PLAYER_NAME);
  203.     format(string, sizeof(string), "FolderChief: %s! Shame you! I told you to deliver the folders within 10 minutes! They are over. You won't get your money!", pTmpName);
  204.     SendClientMessage(playerid, COLOR_RED, string);
  205.     StopPlayerJob(playerid);
  206.     return 1;
  207. }
  208.  
  209. stock StartPlayerJob(playerid)
  210. {
  211.     new pTmpName[MAX_PLAYER_NAME], RandomStreet, RandomFolders, string[128];
  212.     GetPlayerName(playerid, pTmpName, MAX_PLAYER_NAME);
  213.     RandomFolders = ( MinFolders + random( MaxFolders - MinFolders ) );
  214.     RandomStreet = random(4);
  215.     switch(RandomStreet){
  216.         case 0:{
  217.             pFJInfo[playerid][CurrentStreetID] = 1;
  218.             strset(pFJInfo[playerid][CurrentStreetName], "Ganton");
  219.             GangZoneShowForPlayer(playerid, LS_Ganton, COLOR_GREEN);
  220.         }
  221.         case 1:{
  222.             pFJInfo[playerid][CurrentStreetID] = 2;
  223.             strset(pFJInfo[playerid][CurrentStreetName], "Jefferson");
  224.             GangZoneShowForPlayer(playerid, LS_Jefferson, COLOR_GREEN);
  225.         }
  226.         case 2:{
  227.             pFJInfo[playerid][CurrentStreetID] = 3;
  228.             strset(pFJInfo[playerid][CurrentStreetName], "Playa Del Seville");
  229.             GangZoneShowForPlayer(playerid, LS_PlayaDelSeville, COLOR_GREEN);
  230.         }
  231.         case 3:{
  232.             pFJInfo[playerid][CurrentStreetID] = 4;
  233.             strset(pFJInfo[playerid][CurrentStreetName], "Verdant Bluffs");
  234.             GangZoneShowForPlayer(playerid, LS_VerdantBluffs, COLOR_GREEN);
  235.         }
  236.     }
  237.     pFJInfo[playerid][MoneyThisRound] = ( RandomFolders * MoneyPerFolder );
  238.     format(string, 128, "FolderChief: Hi %s. We've got some folders to deliver for you", pTmpName);
  239.     SendClientMessage(playerid, COLOR_WHITE, string);
  240.     format(string, 128, "FolderChief: Here are %d folders for you, you'll get $%d,- for it", RandomFolders, pFJInfo[playerid][MoneyThisRound]);
  241.     SendClientMessage(playerid, COLOR_WHITE, string);
  242.     format(string, 128, "FolderChief: Go to %s and stay there 60 seconds. Then you'll get your money", pFJInfo[playerid][CurrentStreetName]);
  243.     SendClientMessage(playerid, COLOR_WHITE, string);
  244.     SendClientMessage(playerid, COLOR_WHITE, "FolderChief: And now, go! You've got 10 minutes to deliver it. If you don't deliver it within 10 minutes, you won't get paid!");
  245.     SendClientMessage(playerid, COLOR_WHITE, "FolderChief: Good luck.");
  246.     pFJInfo[playerid][CheckForAreaTimer] = SetTimerEx("CheckPlayerInArea", 1000, true, "i", playerid);
  247.     pFJInfo[playerid][FailTimer] = SetTimerEx("FailDelivery", 600000, false, "i", playerid);
  248.     pFJInfo[playerid][TimerStarted] = true;
  249.     pFJInfo[playerid][JobStarted] = true;
  250.     return 1;
  251. }
  252.  
  253. stock StopPlayerJob(playerid)
  254. {
  255.     return ResetPlayerJobInfo(playerid);
  256. }
  257.  
  258. stock ResetPlayerJobInfo(playerid)
  259. {
  260.     if(pFJInfo[playerid][TimerStarted]){
  261.         KillTimer(pFJInfo[playerid][CheckForAreaTimer]);
  262.         KillTimer(pFJInfo[playerid][FailTimer]);
  263.     }
  264.     if(pFJInfo[playerid][CurrentStreetID] == 1)
  265.         GangZoneHideForPlayer(playerid, LS_Ganton);
  266.     else if(pFJInfo[playerid][CurrentStreetID] == 2)
  267.         GangZoneHideForPlayer(playerid, LS_Jefferson);
  268.     else if(pFJInfo[playerid][CurrentStreetID] == 3)
  269.         GangZoneHideForPlayer(playerid, LS_PlayaDelSeville);
  270.     else if(pFJInfo[playerid][CurrentStreetID] == 4)
  271.         GangZoneHideForPlayer(playerid, LS_VerdantBluffs);
  272.     pFJInfo[playerid][JobStarted] = false;
  273.     pFJInfo[playerid][CurrentStreetID] = (-1);
  274.     pFJInfo[playerid][CurrentStreetName] = 0;
  275.     pFJInfo[playerid][MoneyThisRound] = 0;
  276.     pFJInfo[playerid][CheckForAreaTimer] = (-1);
  277.     pFJInfo[playerid][FailTimer] = (-1);
  278.     pFJInfo[playerid][TimerStarted] = false;
  279.     pFJInfo[playerid][SecondsInArea] = 0;
  280.     pFJInfo[playerid][StreetIsFlashing] = false;
  281.     return 1;
  282. }
  283.  
  284. stock IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
  285. {
  286.     new Float:pX, Float:pY, Float:pZ;
  287.     GetPlayerPos(playerid, pX, pY, pZ);
  288.     if(pX >= MinX && pX <= MaxX && pY >= MinY && pY <= MaxY)
  289.         return true;
  290.     return false;
  291. }
  292.  
  293. stock strset(astr[], astrtoset[])
  294. {
  295.     strdel(astr, 0, strlen(astr));
  296.     strins(astr, astrtoset, 0, strlen(astrtoset));
  297. }
Add Comment
Please, Sign In to add comment