/*
Simple SA-MP gamemode based on Gun Game
Deathmatch Gamemode located in Caligula's Palace
Published under GNU GPL Public License.
Copyright (C) 2019 Fabian Druschke, Gareth Mössinger
Contact: [email protected]
Mail: Postfach 32 22 50147 Kerpen Germany
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
*/
#include <a_samp>
forward PlayerHasWon(playerid);
new gamemodeDescriptor[512];
//Gungame
new gunGame_Weapon_Array[] = {
WEAPON_COLT45,
WEAPON_SILENCED,
WEAPON_DEAGLE,
WEAPON_SHOTGUN,
WEAPON_SAWEDOFF,
WEAPON_SHOTGSPA,
WEAPON_UZI,
WEAPON_MP5,
WEAPON_AK47,
WEAPON_M4,
WEAPON_TEC9,
WEAPON_RIFLE,
WEAPON_SNIPER,
WEAPON_KATANA
};
new const LEVELS_COUNT = sizeof(gunGame_Weapon_Array);
new score[MAX_PLAYERS];
new const Float:gunGameSpawns_Caligulas[][]={
{2151.6001, 1601.7, 1002.0, 0.003}, // ped (4)
{2173.8, 1578.5, 1000.0, 174.003}, // ped (5)
{2171.7, 1607.3, 1000.0, 0.003}, // ped (6)
{2194.8, 1626.1, 1000.0, 0.003}, // ped (7)
{2207.0, 1608.8, 1000.0, 0.003}, // ped (9)
{2218.2, 1613.3, 1000.0, 356.003}, // ped (10)
{2194.6006, 1591.9004, 1000.0, 0.003}, // ped (11)
{2230.0, 1574.7998, 1000.0, 0.003}, // ped (12)
{2218.1006, 1553.0, 1004.7, 0.003} // ped (13)
};
main()
{
print("\n----------------------------------");
print(gamemodeDescriptor);
print("----------------------------------\n");
print(" Simple SA-MP gamemode based on Gun Game");
print(" Deathmatch Gamemode located in Caligula's Palace");
print(" Published under GNU GPL Public License.");
print(" Copyright (C) 2019 Fabian Druschke, Gareth Mössinger");
print(" Contact: [email protected]");
print(" Mail: Postfach 32 22 50147 Kerpen Germany");
print("\nThis program is free software: you can redistribute it and/or modify");
print("it under the terms of the GNU General Public License as published by");
print("the Free Software Foundation, either version 3 of the License, or");
print("(at your option) any later version.");
print("\n This program is distributed in the hope that it will be useful,");
print("but WITHOUT ANY WARRANTY; without even the implied warranty of");
print("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the");
print("GNU General Public License for more details.");
print("\n You should have received a copy of the GNU General Public License");
print("along with this program. If not, see http://www.gnu.org/licenses/");
printf("\n\nHeapspace: %i kilobytes", heapspace() / 1024);
}
public OnPlayerConnect(playerid)
{
GameTextForPlayer(playerid,gamemodeDescriptor,5000,5);
new name[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, name, sizeof(name));
new string[MAX_PLAYER_NAME + 23 + 1];
format(string, sizeof(string), "%s (%d) has joined the server.", name,playerid);
SendClientMessageToAll(0xC4C4C4FF, string);
RemoveBuildingForPlayer(playerid,3089,2168.6001,1619.42,1000.3,2.0); //Removing the disturbing door inside of Caligula's basement
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new pname[MAX_PLAYER_NAME +1], string[128 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
switch(reason)
{
case 0: format(string, sizeof(string), "%s (%d) has left the server. (Lost Connection)", pname,playerid);
case 1: format(string, sizeof(string), "%s (%d) has left the server. (Leaving)", pname,playerid);
case 2: format(string, sizeof(string), "%s (%d) has left the server. (Kicked)", pname,playerid);
}
SendClientMessageToAll(0xC4C4C4FF, string);
score[playerid]=0;//Resetting player vars
}
stock GivePlayerMoneyText(playerid,value)
{
new moneyplayerid[32];
if(value < 0)
format(moneyplayerid,sizeof(moneyplayerid), "~r~ %d~y~$",value);
if(value >= 0)
format(moneyplayerid,sizeof(moneyplayerid), "~g~ %d~y~$",value);
GameTextForPlayer(playerid,moneyplayerid,1000,1);
GivePlayerMoney(playerid,value);
}
public OnPlayerSpawn(playerid)
{
GivePlayerMoneyText(playerid,1000);
SetPlayerInterior(playerid,1);//Caligula's interior
TogglePlayerClock(playerid,0);
new randSpawn = random(sizeof(gunGameSpawns_Caligulas));
SetPlayerPos(playerid,gunGameSpawns_Caligulas[randSpawn][0],gunGameSpawns_Caligulas[randSpawn][1],gunGameSpawns_Caligulas[randSpawn][2]);
SetPlayerFacingAngle(playerid,gunGameSpawns_Caligulas[randSpawn][3]);
GivePlayerWeapon(playerid,gunGame_Weapon_Array[score[playerid]],99999);//Giving the current level weapon to the player
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID && (weaponid == 34 || weaponid == 33) && bodypart == 9)//Headshot for rifle and sniper rifle
{
// One shot to the head to kill with sniper rifle
SetPlayerHealth(playerid, 0.0);
}
if(issuerid != INVALID_PLAYER_ID && weaponid == 8)//Increase damage issued by katana
{
new Float:health;
GetPlayerHealth(playerid,health);
health=health-30.0;
SetPlayerHealth(playerid, health);
}
return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
PlayerPlaySound(playerid, 17802, 0.0, 0.0, 0.0); // Ding Sound
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed
GivePlayerMoneyText(playerid,-1000);
if(killerid != INVALID_PLAYER_ID)//We have to check if the player has been killed by another player.
{
score[killerid]+=1;
if(score[killerid] < LEVELS_COUNT)// Check if someone has reached the penultimate level
{
SetPlayerAmmo(killerid, gunGame_Weapon_Array[(score[killerid])-1],0);// Remove the weapon from last level.
GivePlayerWeapon(killerid,gunGame_Weapon_Array[score[killerid]],99999);
SendClientMessage(killerid,0xFFFFFF,"Weapon upgraded!");
}
else
{
PlayerHasWon(killerid);
}
}
else//If the player has committed suicide (even though it might not be possible using the current weapon set)
{
if(score[playerid] > 0)//The player level may not go below 0 to avoid bugs
{
score[playerid]-=1;//Player level will be degraded
}
}
SetPlayerScore(playerid, score[playerid]);
SetPlayerScore(killerid, score[killerid]);
}
SetupPlayerForClassSelection(playerid)
{
SetPlayerInterior(playerid,14);
SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
SetPlayerFacingAngle(playerid, 270.0);
SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
}
public OnPlayerRequestClass(playerid, classid)
{
SetupPlayerForClassSelection(playerid);
return 1;
}
public OnGameModeInit()
{
format(gamemodeDescriptor,sizeof(gamemodeDescriptor),"Gun Game");
SetGameModeText(gamemodeDescriptor);
//Misc conditions to deal with this mode
ShowPlayerMarkers(false);
ShowNameTags(true);
DisableInteriorEnterExits();
for(new i;i<311;i++)//All available skins for class selection
{
AddPlayerClass(i,1958.3783,1343.1572,15.3746,270.1425,0,0,0,0,-1,-1);
}
CreateObject(3089, 2150.0, 1602.1, 1002.2, 0.0, 0.0, 90.0, 100); // Door to prevent someone of leaving the area
return 1;
}
public PlayerHasWon(playerid)
{
new name[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, name, sizeof(name));
new string[MAX_PLAYER_NAME + 23 + 1];
format(string, sizeof(string), "%s reached the last level and has won the game!", name);
SendClientMessageToAll(0xFFFFFF, string);
SendRconCommand("gmx");//Restart the server after someone has won the game
}
Comments