Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Crushers TDM.
- This is an TDM (Team deathmatch) GameMode.
- Made by Crusher.
- Version 1.0.
- First release
- */
- #include <a_samp>
- #define RoundTime 300000
- #define MAX_TEAM_KILLS 3
- #define COLOR_BASIC 0x0066FFAA
- new
- string[256],
- Team_1_Life_Players = 0,
- Team_2_Life_Players = 0,
- Team_1_Score = 0,
- Team_2_Score = 0,
- RoundTimer,
- EndRoundTimer,
- RifleRound = 0,
- GameStarted = 0,
- ALife[MAX_PLAYERS],
- TeamKill[MAX_PLAYERS],
- Text:Time,
- GameEnds = 0,
- GameStarts = 0,
- Text:textdraw,
- Time_0,
- Time_1,
- Time_2,
- Time_3,
- Time_4,
- Time_5;
- forward EndGame();
- forward NewGame();
- forward Time0();
- forward Time1();
- forward Time2();
- forward Time3();
- forward Time4();
- forward Time5();
- // '[:. Randoms .:]'
- new
- Float:Team_1_Random[][6] =
- {
- // Positions, (X, Y, Z and Facing Angle)
- {1764.796,-1924.766,13.228,58.0},
- {1797.719,-1894.259,13.063,58.0},
- {1716.036,-1932.410,13.229,58.0},
- {1708.088,-1883.313,13.229,181.0},
- {1694.660,-1892.206,13.229,181.0}
- },
- Float:Team_2_Random[][5] =
- {
- // Positions, (X, Y, Z and Facing Angle)
- {1802.684,-2072.868,13.225,0.0},
- {1786.163,-2072.864,13.225,0.0},
- {1751.390,-2060.402,13.225,0.0},
- {1690.142,-2072.064,13.254,0.0}
- };
- main() return 1;
- public OnGameModeInit()
- {
- // '[:. Some things .:]'
- SetGameModeText("Crushers TDM");
- UsePlayerPedAnims();
- DisableInteriorEnterExits();
- SetNameTagDrawDistance(0.1);
- // '[:. Classes .:]'
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); // class id 0
- AddPlayerClassEx(1, 1, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); // team1 swat
- AddPlayerClassEx(2, 95, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); // team1 army
- // '[:. Textdraws .:]'
- Time = TextDrawCreate(489.000000,120.000000,"~r~0 ~w~Minutes left");
- TextDrawAlignment(Time,0);
- TextDrawBackgroundColor(Time,0x000000ff);
- TextDrawFont(Time,1);
- TextDrawLetterSize(Time,0.399999,1.700000);
- TextDrawColor(Time,0xffffffff);
- TextDrawSetOutline(Time,1);
- TextDrawSetProportional(Time,1);
- TextDrawSetShadow(Time,1);
- textdraw = TextDrawCreate(1.000000,7.000000,"~b~ Scores: Team 1: 0, Team 2: 0");
- TextDrawAlignment(textdraw,0);
- TextDrawFont(textdraw,2);
- TextDrawLetterSize(textdraw,0.500000,1.200000);
- TextDrawColor(textdraw,COLOR_BASIC);
- TextDrawSetProportional(textdraw,1);
- TextDrawUseBox(textdraw,1);
- TextDrawSetShadow(textdraw,0);
- // '[:. Objects .:]'
- CreateObject(1655,1689.772,-2010.895,14.148,0.0,0.0,0.0); // object
- CreateObject(1655,1689.865,-2004.226,14.125,0.0,0.0,-179.622); // object (1)
- CreateObject(16302,1752.060,-1994.067,11.609,0.0,0.0,0.0); // object (3)
- CreateObject(16305,1712.518,-1991.709,15.937,0.0,0.0,0.0); // object (4)
- CreateObject(972,1687.852,-1881.955,12.529,0.0,0.0,-71.333); // object (5)
- CreateObject(972,1709.373,-1874.069,12.564,0.0,0.0,-90.241); // object (6)
- CreateObject(972,1725.864,-1876.929,12.556,0.0,0.0,-110.008); // object (7)
- CreateObject(972,1813.720,-1885.249,11.111,0.0,0.0,182.578); // object (8)
- CreateObject(972,1798.743,-1962.463,11.922,0.0,0.0,126.328); // object (9)
- CreateObject(972,1808.385,-1952.639,11.919,0.0,0.0,144.377); // object (10)
- CreateObject(972,1678.703,-1964.248,10.544,0.0,0.0,0.095); // object (11)
- CreateObject(972,1676.370,-2067.167,11.547,0.0,0.0,0.0); // object (12)
- CreateObject(972,1816.439,-2063.288,8.976,0.0,0.0,180.000); // object (13)
- CreateObject(969,1813.321,-2057.982,16.226,0.0,0.0,90.000); // object (15)
- CreateObject(969,1813.279,-2066.775,16.229,0.0,0.0,90.000); // object (16)
- CreateObject(3279,1796.848,-2039.000,12.330,0.0,0.0,22.500); // object (17)
- CreateObject(3279,1796.031,-1931.949,12.087,0.0,0.0,22.500); // object (18)
- NewGame();
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public EndGame()
- {
- GameEnds += 1;
- printf("Game ended!, total games ended: %d",GameEnds);
- TextDrawSetString(Time,"~w~Waiting for~n~ new game");
- for(new E=0; E<MAX_PLAYERS; E++)
- {
- TextDrawSetString(textdraw,"~b~ Waiting for new game!");
- TextDrawShowForPlayer(E,textdraw);
- TextDrawSetString(Time,"~w~Waiting for~n~ new game~n~~n~~n~~n~~n~~n~~n~To win kill~n~They all!!!");
- TogglePlayerControllable(E, 0);
- TextDrawShowForPlayer(E, Time);
- SetPlayerCameraPos(E,1678.4041,-2012.7576,21.9542);
- SetPlayerCameraLookAt(E,1759.4498,-1957.8380,13.5469);
- }
- GameStarted = 0;
- KillTimer(RoundTimer);
- KillTimer(Time_5);
- KillTimer(Time_4);
- KillTimer(Time_3);
- KillTimer(Time_2);
- KillTimer(Time_1);
- KillTimer(Time_0);
- if (Team_1_Life_Players < Team_2_Life_Players)
- {
- GameTextForAll("~y~]~w~Team ~r~2 ~b~win~y~]",40000,5);
- }
- if (Team_2_Life_Players < Team_1_Life_Players)
- {
- GameTextForAll("~y~]~w~Team ~r~1 ~b~win~y~]",40000,5);
- }
- if (Team_1_Life_Players == Team_2_Life_Players)
- {
- GameTextForAll("~y~]~w~Draw~y~]~n~~n~~n~~w~The round is draw.",10000,5);
- }
- RifleRound = 0;
- EndRoundTimer = SetTimer("NewGame",40000,0);
- return 1;
- }
- public NewGame()
- {
- Team_1_Life_Players = 0;
- Team_2_Life_Players = 0;
- KillTimer(EndRoundTimer);
- GameStarts += 1;
- printf("Game started!, total games started: %d",GameStarts);
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- TextDrawSetString(textdraw,"~b~ Scores: Team 1: 0, Team 2: 0");
- TextDrawShowForPlayer(i,textdraw);
- SetCameraBehindPlayer(i);
- ResetPlayerWeapons(i);
- TextDrawSetString(Time,"~w~Waiting for ~n~new game...");
- TextDrawShowForPlayer(i, Time);
- TogglePlayerControllable(i, 1);
- TogglePlayerSpectating(i, 0);
- ALife[i] = 1;
- if (RifleRound == 1)
- {
- SetPlayerHealth(i, 15); // health 15%
- GivePlayerWeapon(i, 33, 50);// rifle ammo 50
- }
- else
- {
- SetPlayerHealth(i, 40); // health 40%
- GivePlayerWeapon(i, 28, 100);
- GivePlayerWeapon(i, 31, 500);
- GivePlayerWeapon(i, 16, 1);
- }
- if (GetPlayerTeam(i) == 1)
- {
- new iRandom = random(sizeof(Team_1_Random));
- SetPlayerPos(i,Team_1_Random[iRandom][0],Team_1_Random[iRandom][1],Team_1_Random[iRandom][2]);
- SetPlayerFacingAngle(i, Team_1_Random[iRandom][3]);
- Team_1_Life_Players += 1;
- GameTextForPlayer(i,"~w~Kill the ~r~Army ~w~guys",3000,5);
- }
- if (GetPlayerTeam(i) == 2)
- {
- new aRandom = random(sizeof(Team_2_Random));
- SetPlayerPos(i,Team_2_Random[aRandom][0],Team_2_Random[aRandom][1],Team_2_Random[aRandom][2]);
- SetPlayerFacingAngle(i, Team_2_Random[aRandom][3]);
- Team_2_Life_Players += 1;
- GameTextForPlayer(i,"~w~Kill the ~r~S.W.A.T ~w~guys",3000,5);
- }
- }
- GameStarted = 1;
- RoundTimer = SetTimer("EndGame",RoundTime,0);
- Time_5 = SetTimer("Time5",60,0);
- Time_4 = SetTimer("Time4",60000,0);
- Time_3 = SetTimer("Time3",120000,0);
- Time_2 = SetTimer("Time2",180000,0);
- Time_1 = SetTimer("Time1",240000,0);
- Time_0 = SetTimer("Time0",290000,0);
- return 1;
- }
- public Time5() { TextDrawSetString(Time,"~r~5 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
- public Time4() { TextDrawSetString(Time,"~r~4 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
- public Time3() { TextDrawSetString(Time,"~r~3 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
- public Time2() { TextDrawSetString(Time,"~r~2 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
- public Time1() { TextDrawSetString(Time,"~r~1 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
- public Time0() { TextDrawSetString(Time,"~r~0 ~w~Minutes left"), TextDrawShowForAll(Time); return 1; }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1959.3783, 135.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- if (classid == 0)
- {
- GameTextForPlayer(playerid,"~w~Choise an team~n~~b~~<~~>~",3000,5);
- }
- if (classid == 1)
- {
- GameTextForPlayer(playerid,"~w~Team~n~~b~1",3000,5);
- }
- if (classid == 2)
- {
- GameTextForPlayer(playerid,"~w~Team~n~~b~2",3000,5);
- }
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- if (GetPlayerSkin(playerid) == 0)
- {
- ForceClassSelection(playerid);
- SetPlayerHealth(playerid,0);
- return 1;
- }
- TogglePlayerSpectating(playerid, 1);
- for(new C=0; C<MAX_PLAYERS; C++)
- {
- if (GameStarted == 1)
- {
- if (Team_1_Life_Players == 0 || Team_2_Life_Players == 0)
- {
- EndGame();
- }
- else if (IsPlayerConnected(C))
- {
- if (ALife[C] == 1)
- {
- PlayerSpectatePlayer(playerid, C);
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- GameTextForPlayer(playerid,"~w~Crushers ~r~TDM~n~~b~Have Fun",5000,5);
- ALife[playerid] = 0;
- new Name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- new Connects[256];
- format(Connects, sizeof(Connects), ".:. %s (ID:%d) has joined the server .:.", Name, playerid);
- SendClientMessageToAll(COLOR_BASIC,Connects);
- }
- }
- SendClientMessage(playerid,COLOR_BASIC,"============");
- SendClientMessage(playerid,COLOR_BASIC,"This server uses Crushers Team DeathMatch script.");
- SendClientMessage(playerid,COLOR_BASIC,"Cmds: /Help, /Info, /rAdmins, /Kill");
- SendClientMessage(playerid,COLOR_BASIC,"============");
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if (GetPlayerTeam(playerid) == 1)
- {
- Team_1_Life_Players -= 1;
- }
- if (GetPlayerTeam(playerid) == 2)
- {
- Team_2_Life_Players -= 1;
- }
- new Name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- new Disconnects[256];
- format(Disconnects, sizeof(Disconnects), ".:. %s (ID:%d) has leaved the server .:.", Name, playerid);
- SendClientMessageToAll(COLOR_BASIC,Disconnects);
- }
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if (GetPlayerTeam(killerid) == GetPlayerTeam(playerid))
- {
- SetPlayerScore(killerid, GetPlayerScore(killerid)-10);
- if (GetPlayerTeam(killerid) == 1)
- {
- Team_1_Score -= 10;
- }
- if (GetPlayerTeam(killerid) == 2)
- {
- Team_2_Score -= 10;
- }
- TeamKill[killerid] += 1;
- if (TeamKill[killerid] == MAX_TEAM_KILLS)
- {
- new Name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
- new Reason[256] = "Teamkilling";
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- new Connects[256];
- format(Connects, sizeof(Connects), ".:. %s (ID:%d) has kicked from the server. the server, reason: %s .:.", Name, playerid, Reason);
- SendClientMessageToAll(COLOR_BASIC,Connects);
- }
- }
- SendClientMessage(killerid,COLOR_BASIC,"You are kicked from the server!");
- SendClientMessage(killerid,COLOR_BASIC,"Because you have killed team mates!");
- TogglePlayerControllable(killerid, 0);
- Kick(killerid);
- return 1;
- }
- }
- if (GetPlayerTeam(killerid) != GetPlayerTeam(playerid))
- {
- SetPlayerScore(killerid, GetPlayerScore(killerid)+5);
- if (GetPlayerTeam(killerid) == 1)
- {
- Team_1_Score += 5;
- }
- if (GetPlayerTeam(killerid) == 2)
- {
- Team_2_Score += 5;
- }
- }
- if (GetPlayerTeam(playerid) == 1)
- {
- Team_1_Life_Players -= 1;
- }
- if (GetPlayerTeam(playerid) == 2)
- {
- Team_2_Life_Players -= 1;
- }
- if (Team_1_Life_Players == 0)return EndGame();
- if (Team_2_Life_Players == 0)return EndGame();
- TogglePlayerSpectating(playerid, 1);
- PlayerSpectatePlayer(playerid, killerid);
- ALife[playerid] = 0;
- new SCOREs[256];
- format(SCOREs, sizeof(SCOREs), "~b~ Scores: Team 1: %d, Team 2: %d", Team_1_Score, Team_2_Score);
- TextDrawSetString(textdraw,SCOREs);
- TextDrawShowForAll(textdraw);
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerPrivmsg(playerid, recieverid, text[])
- {
- for(new MSG=0; MSG<MAX_PLAYERS; MSG++)
- {
- if (IsPlayerConnected(MSG))
- {
- if (IsPlayerAdmin(MSG))
- {
- new MSGs[256];
- format(MSGs, sizeof(MSGs),"Player:%d PM Player: %d, Text: %s",playerid,recieverid,text);
- SendClientMessage(MSG,COLOR_BASIC,MSGs);
- }
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/kill", cmdtext, true, 10) == 0)
- {
- SetPlayerHealth(playerid, 0);
- SAT(playerid,"Kill");
- SendClientMessage(playerid,COLOR_BASIC,"You are now DEAD!, lolz");
- return 1;
- }
- if(strcmp(cmdtext,"/radmins",true) == 0)
- {
- //rcon admins
- SendClientMessage(playerid, COLOR_BASIC, "Online Rcon Admins:");
- new RconAdmins = 0;
- for(new r = 0; r < MAX_PLAYERS; r++)
- {
- if(IsPlayerConnected(r) == 1)
- {
- if(IsPlayerAdmin(r))
- {
- RconAdmins++;
- new Rconpname[MAX_PLAYER_NAME];
- GetPlayerName(r, Rconpname, sizeof(Rconpname));
- format(string, sizeof(string), "%d) Name: %s, ID: %d", RconAdmins, Rconpname, r,(r));
- SendClientMessage(playerid, COLOR_BASIC, string);
- }
- }
- }
- if(RconAdmins == 0)
- {
- SendClientMessage(playerid,COLOR_BASIC, "There are no rcon admins currently online");
- }
- return 1;
- }
- if (strcmp("/help", cmdtext, true, 10) == 0)
- {
- SendClientMessage(playerid,COLOR_BASIC,"============");
- SendClientMessage(playerid,COLOR_BASIC,"CTDM - Help.");
- SendClientMessage(playerid,COLOR_BASIC,"Cmds: /Help, /Kill, /rAdmins, /Info.");
- SendClientMessage(playerid,COLOR_BASIC,"============");
- SAT(playerid,"Help");
- return 1;
- }
- if (strcmp("/info", cmdtext, true, 10) == 0)
- {
- SendClientMessage(playerid,COLOR_BASIC,"============");
- SendClientMessage(playerid,COLOR_BASIC,"CTDM - Info.");
- SendClientMessage(playerid,COLOR_BASIC,"What must i do:");
- SendClientMessage(playerid,COLOR_BASIC,"You must be kill the enemy team to WIN!");
- SendClientMessage(playerid,COLOR_BASIC,"Dont kill team mates or you get an KICK!");
- SendClientMessage(playerid,COLOR_BASIC,"Credits:");
- SendClientMessage(playerid,COLOR_BASIC,"Maker: Crusher!!");
- SendClientMessage(playerid,COLOR_BASIC,"Testing: Crusher!!, Remi-X");
- SendClientMessage(playerid,COLOR_BASIC,"============");
- SAT(playerid,"Help");
- return 1;
- }
- if (strcmp("/Rifle", cmdtext, true, 10) == 0)
- {
- if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_BASIC,"You are not an admin");
- if (GameStarted == 1) return SendClientMessage(playerid,COLOR_BASIC,"You must be at the game end to use this cmd.");
- RifleRound = 1;
- SAT(playerid,"Rifle");
- SendClientMessageToAll(COLOR_BASIC,"Next round wil be an Rifle Round");
- return 1;
- }
- if (strcmp("/nextgame", cmdtext, true, 10) == 0)
- {
- if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_BASIC,"You are not an admin");
- NewGame();
- SAT(playerid,"newgame");
- SendClientMessage(playerid,COLOR_BASIC,"Newgame started!");
- return 1;
- }
- return FailCmd(playerid);
- }
- stock SAT(playerid,text[]) //SendAdminText SAT
- {
- for(new MSG=0; MSG<MAX_PLAYERS; MSG++)
- {
- if (IsPlayerConnected(MSG))
- {
- if (IsPlayerAdmin(MSG))
- {
- new MSGs[256];
- format(MSGs, sizeof(MSGs),"Player:%d has used /%s",playerid,text);
- SendClientMessage(MSG,COLOR_BASIC,MSGs);
- }
- }
- }
- return 1;
- }
- stock FailCmd(playerid)
- {
- SendClientMessage(playerid,COLOR_BASIC,"UNKNOWN COMMAND USE /HELP");
- for(new MSG=0; MSG<MAX_PLAYERS; MSG++)
- {
- if (IsPlayerConnected(MSG))
- {
- if (IsPlayerAdmin(MSG))
- {
- new MSGs[256];
- format(MSGs, sizeof(MSGs),"Player:%d Typed an wrong command",playerid);
- SendClientMessage(MSG,COLOR_BASIC,MSGs);
- }
- }
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if (newstate == PLAYER_STATE_DRIVER)
- {
- GameTextForPlayer(playerid,"~W~you must shoot~N~~R~not drive~n~~w~!!!!!!!!!!!!",5000,5);
- RemovePlayerFromVehicle(playerid);
- for(new MSG=0; MSG<MAX_PLAYERS; MSG++)
- {
- if (IsPlayerConnected(MSG))
- {
- if (IsPlayerAdmin(MSG))
- {
- new MSGs[256];
- format(MSGs, sizeof(MSGs),"Player:%d is kicked from an vehicle",playerid);
- SendClientMessage(MSG,COLOR_BASIC,MSGs);
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment