Advertisement
Knogle

Simple SA-MP gamemode based on Gun Game

May 25th, 2019
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 8.42 KB | None | 0 0
  1.  
  2. /*
  3.     Simple SA-MP gamemode based on Gun Game
  4.     Deathmatch Gamemode located in Caligula's Palace
  5.     Published under GNU GPL Public License.
  6.     Copyright (C) 2019  Fabian Druschke, Gareth Mössinger
  7.     Contact: webmaster@knogleinsi.de
  8.     Mail: Postfach 32 22 50147 Kerpen Germany
  9.  
  10.     This program is free software: you can redistribute it and/or modify
  11.     it under the terms of the GNU General Public License as published by
  12.     the Free Software Foundation, either version 3 of the License, or
  13.     (at your option) any later version.
  14.  
  15.     This program is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.     GNU General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU General Public License
  21.     along with this program.  If not, see http://www.gnu.org/licenses/
  22.  
  23. */
  24.  
  25.  
  26. #include <a_samp>
  27.  
  28.  
  29. forward PlayerHasWon(playerid);
  30.  
  31. new gamemodeDescriptor[512];
  32.  
  33.  
  34. //Gungame
  35. new gunGame_Weapon_Array[] = {
  36.     WEAPON_COLT45,
  37.     WEAPON_SILENCED,
  38.     WEAPON_DEAGLE,
  39.     WEAPON_SHOTGUN,
  40.     WEAPON_SAWEDOFF,
  41.     WEAPON_SHOTGSPA,
  42.     WEAPON_UZI,
  43.     WEAPON_MP5,
  44.     WEAPON_AK47,
  45.     WEAPON_M4,
  46.     WEAPON_TEC9,
  47.     WEAPON_RIFLE,
  48.     WEAPON_SNIPER,
  49.     WEAPON_KATANA
  50.     };
  51.  
  52. new const LEVELS_COUNT = sizeof(gunGame_Weapon_Array);
  53. new score[MAX_PLAYERS];
  54.  
  55. new const Float:gunGameSpawns_Caligulas[][]={
  56.     {2151.6001, 1601.7, 1002.0, 0.003}, // ped (4)
  57.     {2173.8, 1578.5, 1000.0, 174.003}, // ped (5)
  58.     {2171.7, 1607.3, 1000.0, 0.003}, // ped (6)
  59.     {2194.8, 1626.1, 1000.0, 0.003}, // ped (7)
  60.     {2207.0, 1608.8, 1000.0, 0.003}, // ped (9)
  61.     {2218.2, 1613.3, 1000.0, 356.003}, // ped (10)
  62.     {2194.6006, 1591.9004, 1000.0, 0.003}, // ped (11)
  63.     {2230.0, 1574.7998, 1000.0, 0.003}, // ped (12)
  64.     {2218.1006, 1553.0, 1004.7, 0.003} // ped (13)  
  65. };
  66.  
  67.  
  68.  
  69. main()
  70. {
  71.     print("\n----------------------------------");
  72.     print(gamemodeDescriptor);
  73.     print("----------------------------------\n");
  74.     print(" Simple SA-MP gamemode based on Gun Game");
  75.     print(" Deathmatch Gamemode located in Caligula's Palace");
  76.     print(" Published under GNU GPL Public License.");
  77.     print(" Copyright (C) 2019  Fabian Druschke, Gareth Mössinger");
  78.     print(" Contact: webmaster@knogleinsi.de");
  79.     print(" Mail: Postfach 32 22 50147 Kerpen Germany");
  80.     print("\nThis program is free software: you can redistribute it and/or modify");
  81.     print("it under the terms of the GNU General Public License as published by");
  82.     print("the Free Software Foundation, either version 3 of the License, or");
  83.     print("(at your option) any later version.");
  84.     print("\n This program is distributed in the hope that it will be useful,");
  85.     print("but WITHOUT ANY WARRANTY; without even the implied warranty of");
  86.     print("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the");
  87.     print("GNU General Public License for more details.");
  88.     print("\n You should have received a copy of the GNU General Public License");
  89.     print("along with this program.  If not, see http://www.gnu.org/licenses/");
  90.     printf("\n\nHeapspace: %i kilobytes", heapspace() / 1024);
  91.  
  92. }
  93.  
  94. public OnPlayerConnect(playerid)
  95. {
  96.     GameTextForPlayer(playerid,gamemodeDescriptor,5000,5);
  97.     new name[MAX_PLAYER_NAME + 1];
  98.     GetPlayerName(playerid, name, sizeof(name));
  99.     new string[MAX_PLAYER_NAME + 23 + 1];
  100.     format(string, sizeof(string), "%s (%d) has joined the server.", name,playerid);
  101.     SendClientMessageToAll(0xC4C4C4FF, string);    
  102.     RemoveBuildingForPlayer(playerid,3089,2168.6001,1619.42,1000.3,2.0); //Removing the disturbing door inside of Caligula's basement
  103.     return 1;
  104. }
  105.  
  106. public OnPlayerDisconnect(playerid, reason)
  107. {
  108.     new pname[MAX_PLAYER_NAME +1], string[128 + MAX_PLAYER_NAME];
  109.     GetPlayerName(playerid, pname, sizeof(pname));
  110.     switch(reason)
  111.     {
  112.     case 0: format(string, sizeof(string), "%s (%d) has left the server. (Lost Connection)", pname,playerid);
  113.     case 1: format(string, sizeof(string), "%s (%d) has left the server. (Leaving)", pname,playerid);
  114.     case 2: format(string, sizeof(string), "%s (%d) has left the server. (Kicked)", pname,playerid);
  115.     }
  116.     SendClientMessageToAll(0xC4C4C4FF, string);
  117.     score[playerid]=0;//Resetting player vars
  118. }
  119. stock GivePlayerMoneyText(playerid,value)
  120. {
  121.     new moneyplayerid[32];
  122.     if(value < 0)
  123.     format(moneyplayerid,sizeof(moneyplayerid), "~r~ %d~y~$",value);
  124.     if(value >= 0)
  125.     format(moneyplayerid,sizeof(moneyplayerid), "~g~ %d~y~$",value);
  126.     GameTextForPlayer(playerid,moneyplayerid,1000,1);
  127.     GivePlayerMoney(playerid,value);    
  128. }
  129. public OnPlayerSpawn(playerid)
  130. {
  131.     GivePlayerMoneyText(playerid,1000);
  132.     SetPlayerInterior(playerid,1);//Caligula's interior
  133.     TogglePlayerClock(playerid,0);
  134.  
  135.     new randSpawn = random(sizeof(gunGameSpawns_Caligulas));
  136.     SetPlayerPos(playerid,gunGameSpawns_Caligulas[randSpawn][0],gunGameSpawns_Caligulas[randSpawn][1],gunGameSpawns_Caligulas[randSpawn][2]);
  137.     SetPlayerFacingAngle(playerid,gunGameSpawns_Caligulas[randSpawn][3]);
  138.    
  139.     GivePlayerWeapon(playerid,gunGame_Weapon_Array[score[playerid]],99999);//Giving the current level weapon to the player
  140.  
  141.     return 1;
  142. }
  143. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
  144. {
  145.     if(issuerid != INVALID_PLAYER_ID && (weaponid == 34 || weaponid == 33) && bodypart == 9)//Headshot for rifle and sniper rifle
  146.     {
  147.         // One shot to the head to kill with sniper rifle
  148.         SetPlayerHealth(playerid, 0.0);
  149.     }
  150.     if(issuerid != INVALID_PLAYER_ID && weaponid == 8)//Increase damage issued by katana
  151.     {
  152.         new Float:health;
  153.         GetPlayerHealth(playerid,health);
  154.         health=health-30.0;
  155.         SetPlayerHealth(playerid, health);
  156.     }
  157.     return 1;
  158. }
  159. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
  160. {
  161.     PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0); // Ding Sound
  162.     return 1;
  163. }
  164.  
  165. public OnPlayerDeath(playerid, killerid, reason)
  166. {
  167.     SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed
  168.     GivePlayerMoneyText(playerid,-1000);
  169.     if(killerid != INVALID_PLAYER_ID)//We have to check if the player has been killed by another player.
  170.     {
  171.         score[killerid]+=1;
  172.         if(score[killerid] < LEVELS_COUNT)// Check if someone has reached the penultimate level
  173.         {
  174.             SetPlayerAmmo(killerid, gunGame_Weapon_Array[(score[killerid])-1],0);// Remove the weapon from last level.
  175.             GivePlayerWeapon(killerid,gunGame_Weapon_Array[score[killerid]],99999);
  176.             SendClientMessage(killerid,0xFFFFFF,"Weapon upgraded!");
  177.            
  178.         }
  179.         else
  180.         {
  181.             PlayerHasWon(killerid);
  182.         }
  183.     }
  184.     else//If the player has committed suicide (even though it might not be possible using the current weapon set)
  185.     {          
  186.         if(score[playerid] > 0)//The player level may not go below 0 to avoid bugs
  187.         {
  188.             score[playerid]-=1;//Player level will be degraded
  189.         }
  190.        
  191.     }
  192.     SetPlayerScore(playerid, score[playerid]);
  193.     SetPlayerScore(killerid, score[killerid]);
  194. }
  195.  
  196. SetupPlayerForClassSelection(playerid)
  197. {
  198.     SetPlayerInterior(playerid,14);
  199.     SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
  200.     SetPlayerFacingAngle(playerid, 270.0);
  201.     SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
  202.     SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
  203. }
  204.  
  205. public OnPlayerRequestClass(playerid, classid)
  206. {
  207.     SetupPlayerForClassSelection(playerid);
  208.     return 1;
  209. }
  210.  
  211. public OnGameModeInit()
  212. {
  213.     format(gamemodeDescriptor,sizeof(gamemodeDescriptor),"Gun Game");
  214.     SetGameModeText(gamemodeDescriptor);
  215.     //Misc conditions to deal with this mode
  216.     ShowPlayerMarkers(false);
  217.     ShowNameTags(true);
  218.     DisableInteriorEnterExits();
  219.    
  220.    
  221.     for(new i;i<311;i++)//All available skins for class selection
  222.     {
  223.         AddPlayerClass(i,1958.3783,1343.1572,15.3746,270.1425,0,0,0,0,-1,-1);
  224.  
  225.     }  
  226.     CreateObject(3089, 2150.0, 1602.1, 1002.2, 0.0, 0.0, 90.0, 100); // Door to prevent someone of leaving the area
  227.     return 1;
  228. }
  229.  
  230. public PlayerHasWon(playerid)
  231. {
  232.     new name[MAX_PLAYER_NAME + 1];
  233.     GetPlayerName(playerid, name, sizeof(name));
  234.     new string[MAX_PLAYER_NAME + 23 + 1];
  235.     format(string, sizeof(string), "%s reached the last level and has won the game!", name);
  236.     SendClientMessageToAll(0xFFFFFF, string);
  237.     SendRconCommand("gmx");//Restart the server after someone has won the game
  238. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement