Rei_Ayanami

Fallout Minigame by Flamehaze

Jul 29th, 2023
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //==============================================================================
  2. /* FALLOUT EVENT CODED BY Flamehaze, you can edit the entire code as your needs,
  3. if you use it in your Gamemode just give me the credits! If you could that would
  4. be awesome!
  5.  
  6.                          THANK YOU FOR DOWNLOADING IT
  7.  
  8. Changelog: Nothing atm :^)
  9.  
  10. */
  11. //================================ INCLUDES ====================================
  12. #include <a_samp>
  13. #include <zcmd>
  14. //==============================================================================
  15. new FalloutPlayer[MAX_PLAYERS], //Player Variable that let us know if the player is inside the event or not
  16. FalloutStarted = 0, //Global Variable to know if the Event has started or not
  17. FalloutPlayers = 0, //Global Variable to know how much players we have in the event, if < 1 the event will NOT start.
  18. FalloutWaiting = 0; //Global variable to know if we're waiting for the event to start or not
  19.  
  20. //Do not edit this
  21. #define PLATFORMS 63 //Number of platforms in the game (Don't change it)
  22.  
  23. //Editable settings
  24. #define EVENT_START 1 //Calculated in minutes you have to change it (1 = 1 minute)
  25. #define MONEY 10000 //The money that the player wins, change it from there if you want
  26.  
  27. //Forwards
  28. forward FalloutStarting(playerid);
  29. forward CheckPlayer();
  30. forward FallingPlat();
  31. forward RegenPlatforms();
  32.  
  33. //Platforms
  34. new PlatformObject[63];
  35.  
  36. //Some random colors needed
  37. #define Red 0xFF0000FF
  38. #define Grey 0xAFAFAFAA
  39. #define Green 0x33AA33AA
  40. #define Yellow 0xFFFF00AA
  41. #define White 0xFFFFFFAA
  42. #define Blue 0x0000BBAA
  43. #define Lightblue 0x33CCFFAA
  44. #define Orange 0xFF9900AA
  45. #define Lime 0x10F441AA
  46. #define Magenta 0xFF00FFFFT
  47. #define Navy 0x000080AA
  48. #define Aqua 0xF0F8FFAA
  49. #define Crimson 0xDC143CAA
  50. #define Black 0x000000AA
  51. #define Brown 0XA52A2AAA
  52. #define Gold 0xB8860BAA
  53. #define Limegreen 0x32CD32AA
  54.  
  55. //==============================================================================
  56. public OnPlayerConnect(playerid)
  57. {
  58.     FalloutPlayer[playerid] = 0; //Let's define that whenever a new player connects we set his Fallout variable to 0
  59.     return 1;
  60. }
  61.  
  62. public OnPlayerDisconnect(playerid, reason)
  63. {
  64.     //If a Fallout Player leaves
  65.     if(FalloutPlayer[playerid] == 1)
  66.     {
  67.        FalloutPlayers--;
  68.  
  69.        new string[100];
  70.        new name[22];
  71.  
  72.        GetPlayerName(playerid,name,22);
  73.  
  74.        format(string,sizeof(string),"%s has been eliminated from the Fallout Event (Disconnect)",name);
  75.        SendClientMessageToAll(Red,string);
  76.  
  77.     }
  78.     return 1;
  79. }
  80.  
  81. //========================== [ COMMANDS ] ======================================
  82.  
  83. COMMAND:startevent(playerid,params[])
  84. {
  85.     //Warnings
  86.     if(FalloutWaiting == 1) return SendClientMessage(playerid,Red,"You can't start another Fallout Event!"); //If the player tries to start again the event while FalloutWaiting is 1 so that means that the event is currently waiting for players
  87.     if(FalloutStarted == 1) return SendClientMessage(playerid,Red,"The Fallout Event has already started!"); //If the players tries to start the event while the event is active
  88.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Red,"You need to be Admin to use that command!"); //If the player that tries to do that command is not admin we send him a warning
  89.  
  90.     //If the requirements are met then let's do this:
  91.  
  92.     new string[100];
  93.     format(string,sizeof(string),"The Fallout event is about to start in %d minute(s), join it by typing '/joinfallout'",EVENT_START); //let's send everyone a string with the time until start and the join command
  94.     SendClientMessageToAll(Green,string); //If the event has triggered and it's about to be started (60 secs)
  95.     SetTimer("FalloutStarting",60000*EVENT_START,0); //Timer till the event starts
  96.     FalloutWaiting = 1; //Variable for the waiting time meanwhile searching for players
  97.     FalloutPlayer[playerid] = 1; //The player is now a Fallout Partecipant
  98.     FalloutPlayers++; //Increase the Fallout Players number by 1
  99.     return 1;
  100. }
  101.  
  102. COMMAND:joinfallout(playerid,params[])
  103. {
  104.     if(FalloutWaiting == 0) return SendClientMessage(playerid,Red,"There's no active Fallout Event!"); //If the player tries to join it while there's no active event
  105.     if(FalloutStarted == 1) return SendClientMessage(playerid,Red,"The Fallout event has already started, you can't join it now!"); //If the players tries to join it while the Event has already started
  106.     if(FalloutPlayer[playerid] == 1) return SendClientMessage(playerid,Red,"You can't join this, you're already in the event!"); //If the player tries to join the event but he's already inside it.
  107.  
  108.     //Join the event
  109.     FalloutPlayers++; //Increase the players in the event
  110.     FalloutPlayer[playerid] = 1; //The player is now a Fallout Partecipant
  111.     SendClientMessage(playerid,Green,"You joined the Fallout Event! Just wait until the event starts!");
  112.  
  113.     return 1;
  114. }
  115.  
  116.  
  117. //=============================== FALLOUT CORE FUNCTIONS =======================
  118.  
  119. public FalloutStarting(playerid) //The function from the timer: We do start the event or delete it if there are not enough players
  120. {
  121.     if(FalloutPlayers < 2) //If the players that joined the event are less than 2 then it triggers this
  122.     {
  123.         SendClientMessageToAll(Red,"Sadly there were not enough players to start the Fallout Event :("); //Send the player a message to let him know that the event isn't started cause of missing players
  124.         FalloutPlayers = 0; //Reset the fallout players to 0
  125.         FalloutWaiting = 0; //Reset the fallout Waiting to 0
  126.         FalloutPlayer[playerid] = 0; //Let's reset the player variable
  127.  
  128.     } else { //Otherwise the event begins
  129.  
  130.         FalloutWaiting = 0; //Let's avoid more players to join the event by putting this to 0
  131.         FalloutStarted = 1; //Put this to 1 to start the event
  132.         Platforms(); //Let's create the platforms
  133.  
  134.         SetTimer("FallingPlat",1000,1);
  135.         SetTimer("CheckPlayer",1000,1);
  136.  
  137.     //We're now cycling into all players to see if they are Players of the Fallout Event and teleport them if they are so.
  138.         for(new i; i < MAX_PLAYERS; i++)
  139.         {
  140.             if(FalloutPlayer[i] == 1)
  141.             {
  142.                 SetPlayerPos(i,-1737.18042, 845.63318, 435.79611);
  143.                 SetPlayerVirtualWorld(i,5000); //Set all the players in the Virtual World 5000
  144.             }
  145.         }
  146.  
  147.     } //Close
  148. }
  149.  
  150.  
  151. /* Here we do check the player and see if he's still in the platform or he has fallen
  152.    this gets checked every 1 second.
  153. */
  154.  
  155. public CheckPlayer()
  156. {
  157.     //If there is only 1 player remaining he's the winner
  158.     if(FalloutPlayers == 1) //Checking if there's 1 player remaining
  159.     {
  160.         for ( new z; z < MAX_PLAYERS; z++)
  161.         {
  162.             if(FalloutPlayer[z] == 1) //Checking if he's a fallout player
  163.             {
  164.                SendClientMessage(z,Green,"Congratz, you're the last man standing on the platform, you won! And you got some extra money for it!"); //Let's send him a message
  165.                GivePlayerMoney(z,MONEY); //Give him the money for the victory you can change it from the top of the Filterscript
  166.                SpawnPlayer(z); //Spawn him
  167.                SetPlayerVirtualWorld(z,0); //Reset his virtual world
  168.  
  169.                //Reset everything for a new run
  170.                FalloutPlayer[z] = 0;
  171.                FalloutStarted = 0;
  172.                FalloutPlayers = 0;
  173.  
  174.                SetTimer("RegenPlatforms",5000,0); //Let's recreate all the platforms in 20 seconds meanwhile they get destroyed and recreated
  175.  
  176.                //Now let's destroy all objects and reset them
  177.                for(new o=0;o<sizeof(PlatformObject);o++) //Cycle to get all the objects
  178.                {
  179.                     if(IsValidObject(PlatformObject[o])) //Then destroy it
  180.                     {
  181.                         DestroyObject(PlatformObject[o]);
  182.                     }
  183.                }
  184.  
  185.         }
  186.     }
  187.  
  188.     } else { //Otherwise do the following
  189.  
  190.     for(new i; i < MAX_PLAYERS; i++) //Cycle it to get all players id
  191.     {
  192.         new Float: px, Float: py, Float: pz; //Let's define px, py, pz
  193.         GetPlayerPos(i,px,py,pz); //Get everyone position
  194.  
  195.         if(IsPlayerConnected(i))
  196.         {
  197.             if(FalloutPlayer[i] == 1)
  198.             {
  199.                 if(pz < 400) //Let's check who has fallen from the platform
  200.                 {
  201.  
  202.                 new name[25];
  203.                 new string[100];
  204.  
  205.                 GetPlayerName(i,name,25);
  206.                 format(string,sizeof(string),"%s has been eliminated from the Fallout Event, Players Remaining: %d",name, FalloutPlayers);
  207.                 SendClientMessageToAll(Red,string);
  208.  
  209.                 FalloutPlayers--; //Decrease by 1 the Fallout Players count
  210.                 FalloutPlayer[i] = 0; //Reset his variables
  211.                 SpawnPlayer(i); //Spawn him
  212.                 SetPlayerVirtualWorld(i,0); //Reset his virtual world
  213.  
  214.                 }
  215.             }
  216.         }
  217.     }
  218.     }
  219. }
  220.  
  221. public FallingPlat() //Destroyer of the platforms :^) It destroys a random object from the platform
  222. {
  223.     if(IsValidObject(PlatformObject[random(PLATFORMS)]))
  224.     {
  225.         DestroyObject(PlatformObject[random(PLATFORMS)]);
  226.     }
  227. }
  228.  
  229.  
  230. public RegenPlatforms() //Regenerate all the platform for a second run
  231. {
  232.      Platforms();
  233. }
  234.  
  235. //================================= PLATFORMS ==================================
  236.  
  237. stock Platforms()
  238. {
  239.      //Platform objects
  240.      PlatformObject[0] = CreateObject(1649, -1740.44092, 845.66888, 428.79611, -90.00000, 0.00000, -90.60000);
  241.      PlatformObject[1] = CreateObject(1649, -1737.18042, 845.63318, 428.79611, -90.00000, 0.00000, -90.60000);
  242.      PlatformObject[2] = CreateObject(1649, -1740.48816, 841.32959, 428.79611, -90.00000, 0.00000, -90.60000);
  243.      PlatformObject[3] = CreateObject(1649, -1737.22803, 841.29327, 428.79611, -90.00000, 0.00000, -90.60000);
  244.      PlatformObject[4] = CreateObject(1649, -1743.76868, 841.38629, 428.79611, -90.00000, 0.00000, -90.60000);
  245.      PlatformObject[5] = CreateObject(1649, -1743.70081, 845.68628, 428.79611, -90.00000, 0.00000, -90.60000);
  246.      PlatformObject[6] = CreateObject(1649, -1743.67358, 850.00671, 428.79611, -90.00000, 0.00000, -90.60000);
  247.      PlatformObject[7] = CreateObject(1649, -1740.37341, 849.96948, 428.79611, -90.00000, 0.00000, -90.60000);
  248.      PlatformObject[8] = CreateObject(1649, -1737.11243, 849.93317, 428.79611, -90.00000, 0.00000, -90.60000);
  249.      PlatformObject[9] = CreateObject(1649, -1733.85181, 849.89679, 428.79611, -90.00000, 0.00000, -90.60000);
  250.      PlatformObject[10] = CreateObject(1649, -1733.93787, 845.51715, 428.79611, -90.00000, 0.00000, -90.60000);
  251.      PlatformObject[11] = CreateObject(1649, -1733.96399, 841.24866, 428.79611, -90.00000, 0.00000, -90.60000);
  252.      PlatformObject[12] = CreateObject(1649, -1730.74585, 841.14685, 428.79611, -90.00000, 0.00000, -90.60000);
  253.      PlatformObject[13] = CreateObject(1649, -1730.63953, 845.54553, 428.79611, -90.00000, 0.00000, -90.60000);
  254.      PlatformObject[14] = CreateObject(1649, -1730.59717, 849.84680, 428.79611, -90.00000, 0.00000, -90.60000);
  255.      PlatformObject[15] = CreateObject(1649, -1743.81250, 837.06433, 428.79611, -90.00000, 0.00000, -90.60000);
  256.      PlatformObject[16] = CreateObject(1649, -1740.53174, 837.00037, 428.79611, -90.00000, 0.00000, -90.60000);
  257.      PlatformObject[17] = CreateObject(1649, -1737.23096, 836.97479, 428.79611, -90.00000, 0.00000, -90.60000);
  258.      PlatformObject[18] = CreateObject(1649, -1734.09045, 836.91614, 428.79611, -90.00000, 0.00000, -90.60000);
  259.      PlatformObject[19] = CreateObject(1649, -1730.79199, 836.81165, 428.79611, -90.00000, 0.00000, -90.60000);
  260.      PlatformObject[20] = CreateObject(1649, -1747.12341, 837.09131, 428.79611, -90.00000, 0.00000, -90.60000);
  261.      PlatformObject[21] = CreateObject(1649, -1747.06689, 841.43445, 428.79611, -90.00000, 0.00000, -90.60000);
  262.      PlatformObject[22] = CreateObject(1649, -1747.01526, 845.75745, 428.79611, -90.00000, 0.00000, -90.60000);
  263.      PlatformObject[23] = CreateObject(1649, -1746.95740, 849.99884, 428.79611, -90.00000, 0.00000, -90.60000);
  264.      PlatformObject[24] = CreateObject(1649, -1730.82996, 832.48993, 428.79611, -90.00000, 0.00000, -90.60000);
  265.      PlatformObject[25] = CreateObject(1649, -1734.09753, 832.52924, 428.79611, -90.00000, 0.00000, -90.60000);
  266.      PlatformObject[26] = CreateObject(1649, -1737.34229, 832.58447, 428.79611, -90.00000, 0.00000, -90.60000);
  267.      PlatformObject[27] = CreateObject(1649, -1740.63342, 832.60742, 428.79611, -90.00000, 0.00000, -90.60000);
  268.      PlatformObject[28] = CreateObject(1649, -1743.83813, 832.65540, 428.79611, -90.00000, 0.00000, -90.60000);
  269.      PlatformObject[29] = CreateObject(1649, -1747.13342, 832.65881, 428.79611, -90.00000, 0.00000, -90.60000);
  270.      PlatformObject[30] = CreateObject(1649, -1750.43262, 832.73029, 428.79611, -90.00000, 0.00000, -90.60000);
  271.      PlatformObject[31] = CreateObject(1649, -1750.41174, 837.09027, 428.79611, -90.00000, 0.00000, -90.60000);
  272.      PlatformObject[32] = CreateObject(1649, -1750.32996, 841.42944, 428.79611, -90.00000, 0.00000, -90.60000);
  273.      PlatformObject[33] = CreateObject(1649, -1750.28845, 845.78906, 428.79611, -90.00000, 0.00000, -90.60000);
  274.      PlatformObject[34] = CreateObject(1649, -1750.24622, 850.10901, 428.79611, -90.00000, 0.00000, -90.60000);
  275.      PlatformObject[35] = CreateObject(1649, -1730.54651, 854.22644, 428.79611, -90.00000, 0.00000, -90.60000);
  276.      PlatformObject[36] = CreateObject(1649, -1733.78687, 854.29486, 428.79611, -90.00000, 0.00000, -90.60000);
  277.      PlatformObject[37] = CreateObject(1649, -1737.08728, 854.30304, 428.79611, -90.00000, 0.00000, -90.60000);
  278.      PlatformObject[38] = CreateObject(1649, -1740.26367, 854.29370, 428.79611, -90.00000, 0.00000, -90.60000);
  279.      PlatformObject[39] = CreateObject(1649, -1743.52954, 854.32788, 428.79611, -90.00000, 0.00000, -90.60000);
  280.      PlatformObject[40] = CreateObject(1649, -1746.84167, 854.36127, 428.79611, -90.00000, 0.00000, -90.60000);
  281.      PlatformObject[41] = CreateObject(1649, -1750.14624, 854.45685, 428.79611, -90.00000, 0.00000, -90.60000);
  282.      PlatformObject[42] = CreateObject(1649, -1753.71252, 832.77502, 428.79611, -90.00000, 0.00000, -90.60000);
  283.      PlatformObject[43] = CreateObject(1649, -1753.56506, 837.16809, 428.79611, -90.00000, 0.00000, -90.60000);
  284.      PlatformObject[44] = CreateObject(1649, -1753.59863, 841.46564, 428.79611, -90.00000, 0.00000, -90.60000);
  285.      PlatformObject[45] = CreateObject(1649, -1753.53516, 845.80377, 428.79611, -90.00000, 0.00000, -90.60000);
  286.      PlatformObject[46] = CreateObject(1649, -1753.46643, 850.09772, 428.79611, -90.00000, 0.00000, -90.60000);
  287.      PlatformObject[47] = CreateObject(1649, -1753.44092, 854.44940, 428.79611, -90.00000, 0.00000, -90.60000);
  288.      PlatformObject[48] = CreateObject(1649, -1730.49390, 858.64581, 428.79611, -90.00000, 0.00000, -90.60000);
  289.      PlatformObject[49] = CreateObject(1649, -1733.77344, 858.66431, 428.79611, -90.00000, 0.00000, -90.60000);
  290.      PlatformObject[50] = CreateObject(1649, -1737.05298, 858.68329, 428.79611, -90.00000, 0.00000, -90.60000);
  291.      PlatformObject[51] = CreateObject(1649, -1740.31287, 858.70197, 428.79611, -90.00000, 0.00000, -90.60000);
  292.      PlatformObject[52] = CreateObject(1649, -1743.45178, 858.75903, 428.79611, -90.00000, 0.00000, -90.60000);
  293.      PlatformObject[53] = CreateObject(1649, -1746.75024, 858.76831, 428.79611, -90.00000, 0.00000, -90.60000);
  294.      PlatformObject[54] = CreateObject(1649, -1750.05212, 858.79803, 428.79611, -90.00000, 0.00000, -90.60000);
  295.      PlatformObject[55] = CreateObject(1649, -1753.37537, 858.88470, 428.79611, -90.00000, 0.00000, -90.60000);
  296.      PlatformObject[56] = CreateObject(1649, -1756.61438, 858.90198, 428.79611, -90.00000, 0.00000, -90.60000);
  297.      PlatformObject[57] = CreateObject(1649, -1756.71008, 854.54590, 428.79611, -90.00000, 0.00000, -90.60000);
  298.      PlatformObject[58] = CreateObject(1649, -1756.71973, 850.21057, 428.79611, -90.00000, 0.00000, -90.60000);
  299.      PlatformObject[59] = CreateObject(1649, -1756.76819, 845.92291, 428.79611, -90.00000, 0.00000, -90.60000);
  300.      PlatformObject[60] = CreateObject(1649, -1756.84387, 841.63708, 428.79611, -90.00000, 0.00000, -90.60000);
  301.      PlatformObject[61] = CreateObject(1649, -1756.79749, 837.29614, 428.79611, -90.00000, 0.00000, -90.60000);
  302.      PlatformObject[62] = CreateObject(1649, -1756.81995, 832.97583, 428.79611, -90.00000, 0.00000, -90.60000);
  303. }
Add Comment
Please, Sign In to add comment