Advertisement
Guest User

Escape from area 51

a guest
Nov 10th, 2010
1,745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.77 KB | None | 0 0
  1. //  All credits go to Wups!
  2.  
  3. // Includes
  4. #include <a_samp>
  5.  
  6. // End
  7.  
  8. // Defines
  9. #define ForEachPlayer(%0) for(new index_%0=0, %0=ConnectedPlayerList[0]; index_%0<ConnectedPlayers; index_%0++, %0=ConnectedPlayerList[index_%0])
  10.  
  11. #define GREY            0xB4B5B7FF
  12. #define ORANGE          0xFF8C00AA
  13. #define Orange          0xFF8C00AA
  14. #define GREEN           0x33AA33AA
  15. #define YELLOW          0xFFFF00AA
  16. #define HOMER           0xFF0000AA
  17. #define BLUE            0x33CCFFAA
  18. #define ABLUE           0x2641FEAA
  19. #define SYNTAX          0xAA3333AA
  20. #define OTHER           0xFF6347AA
  21. #define WHITE           0xFFFFFFAA
  22. #define PURPLE          0xC2A2DAAA
  23.  
  24. // Costumization
  25. #define LAUNCH_TIME 90 // Rocket Lauch time in seconds. For me it is best 90.
  26.  
  27. #define ROUND_RESTART // Comment if you don't want the game mode auto restarting.
  28. #define RESTART_TIME 3600 // If GM is auto restarting - time to auto restart. Time is in seconds.
  29.  
  30.  
  31.  
  32. // End
  33.  
  34. // Forwards
  35. forward Check();
  36. forward Restart();
  37. forward Restart1();
  38. forward Launched();
  39. forward IsOnRocket();
  40. forward CountDown();
  41. // values
  42. new rocket,timeleft = LAUNCH_TIME,timer;
  43. new
  44.     item1,
  45.     item2,
  46.     item3,
  47.     item4;
  48. new
  49.     place1,
  50.     place2,
  51.     place3,
  52.     place4;
  53.  
  54. enum Items
  55. {
  56.     Money,
  57.     XP,
  58.     LVL,
  59.     holding
  60. }
  61.  
  62. new DB[MAX_PLAYERS][Items];
  63.  
  64. enum Pos
  65. {
  66.     Float:IntX,
  67.     Float:IntY,
  68.     Float:IntZ
  69. }
  70. #define MUCH 19
  71. new const
  72.     Pickups[MUCH][ Pos ] =
  73. {
  74.  
  75. {240.6358,1859.8672,17.8985}, // place
  76. {153.1655,1845.0262,17.6406}, // place
  77. {277.4870,1836.9594,11.5239}, // place
  78. {237.9041,1801.4854,7.4141}, // place
  79. {246.8211,1860.9368,14.0840}, // place
  80. {281.5044,1820.5909,4.7114}, // place
  81. {266.4630,1895.4285,25.4985}, // place
  82. {245.1866,1869.4648,8.7650}, // place
  83. {142.1472,1875.2747,17.8434}, // place
  84. {293.4821,1820.6752,4.7109}, // place
  85. {246.0950,1831.4540,12.3509}, // place
  86. {210.8548,1820.6373,7.4141}, // place
  87. {257.7172,1818.7261,1.0078}, // place
  88. {255.4552,1810.5033,4.7109}, // place
  89. {277.5846,1874.0669,8.7578}, // place
  90. {256.3776,1802.4285,7.5214}, // place
  91. {158.7069,1929.8846,27.8438}, // place
  92. {211.5485,1811.4919,21.8594}, // place
  93. {249.8331,1816.3413,12.2463} // place
  94.  
  95. };
  96.  
  97. new
  98.     ConnectedPlayers,
  99.     ConnectedPlayerList[MAX_PLAYERS+1];
  100.  
  101. main()
  102. {
  103.     print("\n----------------------------------");
  104.     print(" Escape from AREA 51");
  105.     print("----------------------------------\n");
  106. }
  107.  
  108.  
  109. public OnGameModeInit()
  110. {
  111.     SetGameModeText("Escape from");
  112.     SendRconCommand("mapname Area 51");
  113.    
  114.     rocket = CreateObject(17050,268.78613281,1883.78320312,-31.09375000,0.00000000,0.00000000,0.00000000); //foguete
  115.    
  116.     Create3DTextLabel( "1st Battery Cell", WHITE, 268.6331,1891.3718,5.9139, 20.0, 0, 1 );
  117.     Create3DTextLabel( "2nd Battery Cell", WHITE, 268.7466,1876.6882,-3.4694, 20.0, 0, 1 );
  118.     Create3DTextLabel( "3rd Battery Cell", WHITE, 268.6223,1891.2946,-12.8596, 20.0, 0, 1 );
  119.     Create3DTextLabel( "4th Battery Cell", WHITE, 269.0400,1876.5714,-22.2449, 20.0, 0, 1 );
  120.  
  121.     new id = random(15);
  122.     id++;
  123.     item1 = AddCell(Pickups[id][IntX],Pickups[id][IntY],Pickups[id][IntZ]);
  124.     id++;
  125.     item2 = AddCell(Pickups[id][IntX],Pickups[id][IntY],Pickups[id][IntZ]);
  126.     id++;
  127.     item3 = AddCell(Pickups[id][IntX],Pickups[id][IntY],Pickups[id][IntZ]);
  128.     id++;
  129.     item4 = AddCell(Pickups[id][IntX],Pickups[id][IntY],Pickups[id][IntZ]);
  130.    
  131.     SetTimer("Check",2000,true);
  132.  
  133.     AddPlayerClass(165,117.0963,1813.4122,33.4975,10.1864,24,20,25,100,34,10); // Spawn
  134.     AddPlayerClass(166,107.6730,1900.1848,33.4982,356.5878,24,20,25,100,34,10); // Spawn
  135.     AddPlayerClass(284,265.6358,1806.5851,33.4972,2.2907,24,20,25,100,34,10); // Spawn6
  136.     AddPlayerClass(285,165.7563,1931.8768,33.4964,176.2942,24,20,25,100,34,10); // Spawn
  137.     AddPlayerClass(286,236.9397,1934.3514,33.5008,182.8743,24,20,25,100,34,10); // Spawn
  138.     AddPlayerClass(287,270.9631,1894.2793,33.4976,96.8948,24,20,25,100,34,10); // Spawn5
  139.    
  140.     #if defined ROUND_RESTART
  141.     SetTimer("Restart",RESTART_TIME*1000,false);
  142.     #endif
  143.    
  144.     return 1;
  145. }
  146.  
  147.  
  148. public OnPlayerRequestClass(playerid, classid)
  149. {
  150.  
  151.     SetPlayerPos(playerid, 180.3154,1919.8483,17.9419);
  152.     SetPlayerFacingAngle(playerid,47.1800);
  153.    
  154.     SetPlayerCameraPos(playerid, 174.3843,1925.4944,20.1752);
  155.     SetPlayerCameraLookAt(playerid, 180.3154,1919.8483,17.9419);
  156.     return 1;
  157. }
  158.  
  159. public OnPlayerConnect(playerid)
  160. {
  161.     if(IsPlayerNPC(playerid)) return 1;
  162.     DB[playerid][holding]=0;
  163.     ConnectedPlayerList[ConnectedPlayers++]=playerid;
  164.     return 1;
  165. }
  166.  
  167. public OnPlayerDisconnect(playerid, reason)
  168. {
  169.     for(new i=0;i<ConnectedPlayers;i++)
  170.     {
  171.         if(ConnectedPlayerList[i]==playerid)
  172.         {
  173.             ConnectedPlayers--;
  174.             ConnectedPlayerList[i]=ConnectedPlayerList[ConnectedPlayers];
  175.         }
  176.     }
  177.     return 1;
  178. }
  179.  
  180. public OnPlayerDeath(playerid, killerid, reason)
  181. {
  182.     if(killerid != INVALID_PLAYER_ID)
  183.     {
  184.         SendClientMessage(killerid,ORANGE," Oh noes! You killed a player! Bad kitty..");
  185.         SetPlayerScore(killerid,GetPlayerScore(killerid)-10);
  186.     }
  187.     if(DB[playerid][holding]!=0)
  188.     {
  189.         new Float:Coo[3];
  190.         GetPlayerPos(playerid,Coo[0],Coo[1],Coo[2]);
  191.         StopPlayerHoldingObject(playerid);
  192.         new i = DB[playerid][holding];
  193.         switch(i)
  194.         {
  195.             case 1: item1 = CreatePickup(1252,2,Coo[0],Coo[1],Coo[2]);
  196.             case 2: item2 = CreatePickup(1252,2,Coo[0],Coo[1],Coo[2]);
  197.             case 3: item3 = CreatePickup(1252,2,Coo[0],Coo[1],Coo[2]);
  198.             case 4: item4 = CreatePickup(1252,2,Coo[0],Coo[1],Coo[2]);
  199.         }
  200.         DB[playerid][holding]=0;
  201.     }
  202.     return 1;
  203. }
  204.  
  205. public OnPlayerCommandText(playerid, cmdtext[])
  206. {
  207.     if(strcmp(cmdtext, "/help", true)==0)
  208.     {
  209.         SendClientMessage(playerid,BLUE,".:' Escape from AREA 51 ':.");
  210.         SendClientMessage(playerid,ORANGE,".:'       Objective:    ':.");
  211.         SendClientMessage(playerid,YELLOW," Your objective is to get all cells, and place them.");
  212.         SendClientMessage(playerid,WHITE,"Bonus: Put the last cell, Jump on a rocket when it is launching.");
  213.         SendClientMessage(playerid,BLUE,"If another player has taken a cell - kill him, and take the cell.");
  214.         SendClientMessage(playerid,BLUE,"The cells are placed all around AREA 51.");
  215.         SendClientMessage(playerid,GREEN,"GameMode Credits: Wups!");
  216.         return 1;
  217.     }
  218.     return SendClientMessage(playerid,BLUE," There is no such command. Write /help !");
  219. }
  220.  
  221. public OnPlayerUpdate(playerid)
  222. {
  223.     if(DB[playerid][holding]!=0)
  224.     {
  225.         if(GetPlayerWeapon(playerid)) SetPlayerArmedWeapon(playerid,0);
  226.     }
  227.     return 1;
  228. }
  229.  
  230. stock AddCell(Float:X,Float:Y,Float:Z)
  231. {
  232.     new id = CreatePickup(1252,2,X,Y,Z);
  233.     return id;
  234. }
  235.  
  236. public OnPlayerPickUpPickup(playerid, pickupid)
  237. {
  238.     if(DB[playerid][holding]!=0) return SendClientMessage(playerid,PURPLE," * You are already holding a cell!");
  239.     if(pickupid == item1)
  240.     {
  241.         DestroyPickup(pickupid);
  242.         item1 = -1;
  243.         SendClientMessageToAll(YELLOW," The first cell was taken!");
  244.         SetPlayerHoldingObject(playerid,1252,5);
  245.         DB[playerid][holding]=1;
  246.         return 1;
  247.     }
  248.     if(pickupid == item2)
  249.     {
  250.         DestroyPickup(pickupid);
  251.         item2 = -1;
  252.         SendClientMessageToAll(YELLOW," The second cell was taken!");
  253.         SetPlayerHoldingObject(playerid,1252,5);
  254.         DB[playerid][holding]=2;
  255.         return 1;
  256.     }
  257.     if(pickupid == item3)
  258.     {
  259.         DestroyPickup(pickupid);
  260.         item3 = -1;
  261.         SendClientMessageToAll(YELLOW," The third cell was taken!");
  262.         SetPlayerHoldingObject(playerid,1252,5);
  263.         DB[playerid][holding]=3;
  264.         return 1;
  265.     }
  266.     if(pickupid == item4)
  267.     {
  268.         DestroyPickup(pickupid);
  269.         item4 = -1;
  270.         SendClientMessageToAll(YELLOW," The fourth cell was taken!");
  271.         SetPlayerHoldingObject(playerid,1252,5);
  272.         DB[playerid][holding]=4;
  273.         return 1;
  274.     }
  275.     return 1;
  276. }
  277. public Check()
  278. {
  279.     ForEachPlayer(playerid)
  280.     {
  281.    
  282.         if(DB[playerid][holding]!=0)
  283.         {
  284.        
  285.        
  286.             if(PlayerToPoint(2,playerid,268.6331,1891.3718,5.9139)) // first place
  287.             {
  288.                 if(place1==1)
  289.                 {
  290.                 SendClientMessage(playerid,GREEN," * A cell is already placed here.");
  291.                 }
  292.                 else
  293.                 {
  294.                     place1=1;
  295.                     DB[playerid][holding]=0;
  296.                     StopPlayerHoldingObject(playerid);
  297.                     SendClientMessage(playerid,GREEN," * You placed a cell.");
  298.                     SetPlayerScore(playerid,GetPlayerScore(playerid)+50+random(10));
  299.                     if(place1==1 && place2==1 && place3==1 && place4==1) return LastItem(playerid);
  300.                    
  301.                 }
  302.             }
  303.             if(PlayerToPoint(2,playerid,268.7466,1876.6882,-3.4694)) // second place
  304.             {
  305.                 if(place2==1)
  306.                 {
  307.                 SendClientMessage(playerid,GREEN," * A cell is already placed here.");
  308.                 }
  309.                 else
  310.                 {
  311.                     place2=1;
  312.                     DB[playerid][holding]=0;
  313.                     StopPlayerHoldingObject(playerid);
  314.                     SendClientMessage(playerid,GREEN," * You placed a cell.");
  315.                     SetPlayerScore(playerid,GetPlayerScore(playerid)+50+random(10));
  316.                     if(place1==1 && place2==1 && place3==1 && place4==1) return LastItem(playerid);
  317.                 }
  318.             }
  319.             if(PlayerToPoint(2,playerid,268.6223,1891.2946,-12.8596)) // third place
  320.             {
  321.                 if(place3==1)
  322.                 {
  323.                 SendClientMessage(playerid,GREEN," * A cell is already placed here.");
  324.                 }
  325.                 else
  326.                 {
  327.                     place3=1;
  328.                     DB[playerid][holding]=0;
  329.                     StopPlayerHoldingObject(playerid);
  330.                     SendClientMessage(playerid,GREEN," * You placed a cell.");
  331.                     SetPlayerScore(playerid,GetPlayerScore(playerid)+50+random(10));
  332.                     if(place1==1 && place2==1 && place3==1 && place4==1) return LastItem(playerid);
  333.                 }
  334.             }
  335.             if(PlayerToPoint(2,playerid,269.0400,1876.5714,-22.2449)) // fourth place
  336.             {
  337.                 if(place4==1)
  338.                 {
  339.                 SendClientMessage(playerid,GREEN," * A cell is already placed here.");
  340.                 }
  341.                 else
  342.                 {
  343.                     place4=1;
  344.                     DB[playerid][holding]=0;
  345.                     StopPlayerHoldingObject(playerid);
  346.                     SendClientMessage(playerid,GREEN," * You placed a cell.");
  347.                     SetPlayerScore(playerid,GetPlayerScore(playerid)+50+random(10));
  348.                     if(place1==1 && place2==1 && place3==1 && place4==1) return LastItem(playerid);
  349.                 }
  350.             }
  351.            
  352.            
  353.            
  354.         }
  355.        
  356.     }
  357.  
  358.     return 1;
  359. }
  360. stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  361. {
  362.     if(IsPlayerConnected(playerid))
  363.     {
  364.         new Float:oldposx, Float:oldposy, Float:oldposz;
  365.         new Float:tempposx, Float:tempposy, Float:tempposz;
  366.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  367.         tempposx = (oldposx -x);
  368.         tempposy = (oldposy -y);
  369.         tempposz = (oldposz -z);
  370.         if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  371.         {
  372.             return 1;
  373.         }
  374.     }
  375.     return 0;
  376. }
  377. stock LastItem(playerid)
  378. {
  379.     new msg[128],name[24];
  380.     GetPlayerName(playerid,name,24);
  381.     SetPlayerScore(playerid,GetPlayerScore(playerid)+100+random(10));
  382.     format(msg,128," *** %s Placed the last cell! Count Down started!! ***",name);
  383.     SendClientMessageToAll(ORANGE,msg);
  384.     SendClientMessageToAll(GREEN," * Objective : Jump on the rocked, and fly to the air!");
  385.     timer = SetTimer("CountDown",1000,true);
  386.     return 1;
  387. }
  388. public Restart()
  389. {
  390.     SendClientMessageToAll(PURPLE," * Server is restarting in 5 seconds.");
  391.     SendClientMessageToAll(PURPLE," * Server is restarting in 5 seconds.");
  392.     SendClientMessageToAll(PURPLE," * Server is restarting in 5 seconds.");
  393.     SetTimer("Restart1",5000,false);
  394. }
  395. public Restart1()
  396. {
  397.     SendRconCommand("gmx");
  398.     return 1;
  399. }
  400. public Launched()
  401. {
  402.         MoveObject(rocket,268.78613281,1883.78320312,864.84967041,40.0);
  403.         SetObjectRot(rocket,0.00000000,0.00000000,0.00000000);
  404.         SendClientMessageToAll(GREEN," ***   The rocked has launched!!   *** ");
  405.         SetTimer("IsOnRocket",5000,false);
  406.         return 1;
  407. }
  408. public IsOnRocket()
  409. {
  410.     ForEachPlayer(playerid)
  411.     {
  412.         new Float:Coo[3];
  413.         GetPlayerPos(playerid,Coo[0],Coo[1],Coo[2]);
  414.         if(Coo[2] > 100)
  415.         {
  416.             SendClientMessage(playerid,GREEN," * You made it on time! Congratz!");
  417.             SetPlayerScore(playerid,GetPlayerScore(playerid)+30+random(10));
  418.         }
  419.         else
  420.         {
  421.             SendClientMessage(playerid,PURPLE," * You didn't make it on time!!");
  422.         }
  423.    
  424.    
  425.     }
  426.     SendClientMessageToAll(YELLOW," * Check your score and get ready for a restart!");
  427.     SetTimer("Restart",1000,false);
  428. }
  429. public CountDown()
  430. {
  431.         if(!timeleft)
  432.         {
  433.             KillTimer(timer);
  434.             Launched();
  435.         }
  436.         timeleft --;
  437.         new msg[128];
  438.         new minutess = timeleft / 60;
  439.         new atsakimas = minutess * 60;
  440.         new sekunde = timeleft - atsakimas;
  441.         new valanda = minutess / 60;
  442.         new atsakimas2 = valanda * 60;
  443.         if (minutess > 60){ minutess =  minutess - atsakimas2; }
  444.  
  445.         if(sekunde <= 9)
  446.         {
  447.             format(msg,sizeof(msg),"        ~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~Rocket launches after~y~ %i:%i:0%i",valanda,minutess,sekunde);
  448.             GameTextForAll(msg, 5000, 3);
  449.         }else{
  450.             format(msg,sizeof(msg),"        ~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~Rocket launches after~y~ %i:%i:%i",valanda,minutess,sekunde);
  451.             GameTextForAll(msg, 5000, 3);
  452.         }
  453.  
  454. }
  455. // Do NOT remove the credits.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement