#include #include #include #define COLOR_GREY 0xAFAFAFAA #define COLOR_GREEN 0x33AA33AA #define COLOR_RED 0xAA3333AA #define COLOR_YELLOW 0xFFFF00AA #define COLOR_WHITE 0xFFFFFFAA #define COLOR_BLUE 0x0000BBAA #define COLOR_LIGHTBLUE 0x33CCFFAA #define COLOR_ORANGE 0xFF9900AA #define COLOR_SHINERED 0xFF0000AA #define COLOR_SHINEGREEN 0x00FF00AA #define COLOR_LIGHTRED 0xFF9999AA #define COLOR_LIGHTGREEN 0x66FFCCAA #define VCOLOR_WHITE 1 #define VCOLOR_BLACK 0 #define VCOLOR_PINK 126 #define VCOLOR_GREEN 86 #define VCOLOR_RED 3 #define VCOLOR_BLUE 79 #define VCOLOR_ORANGE 6 #define VCOLOR_LIGHTBLUE 7 #define ASS_TEAM 1 #define DEF_TEAM 2 #define DRAW 0 #define ASS_ELIM 1 #define DEF_ELIM 2 #define ASS_OBJ 3 #define DEF_OBJ 4 #define START_LIMIT 1 //players needed to start round #define SECURE_SECONDS 15 //secure van seconds #define FOREPLAY 10 //time before round begins (Seconds) #define ROUND_TIME 360 //round time (Seconds) forward AlmostEndRound(reason); forward EndRound(reason); forward StartRound(); forward CounterRound(); forward UpdateSpectator(); forward SpecPlayer(playerid, sr); forward mSpawnPlayer(playerid); forward GetTeamSize(&ass, &def); new round_timer; new round_counter = ROUND_TIME; new Teami[MAX_PLAYERS]; new gamestarted; //0 - waiting for players to spawn 1 - game in prograss new Spec[MAX_PLAYERS]; // 0 - player is playing, 1 - player is dead and spectating new PlayerSecure[2] = {INVALID_PLAYER_ID , SECURE_SECONDS}; //the player who's securing the van new wins[3]; new vehicles; //number of vehicles new modeint = 1; #define SPAWNS 6 new Float:TeamSpawn[2][SPAWNS][4] = { { // assault {-1342.701293, 38.243682, 7.420363, 125.0}, // 1 {-1340.428100, 37.821029, 7.420362, 125.0}, // 2 {-1345.163452, 41.631584, 7.442305, 125.0}, // 3 {-1338.756347, 42.017547, 7.442304, 125.0}, // 4 {-1334.628295, 33.347896, 7.442304, 125.0}, // 5 {-1338.359375, 32.330387, 7.420361, 125.0} // 6 //{-1347.062377, 38.692985, 7.420361}, // 7 }, { // defense {-1416.242309, -315.753997, 7.099882, 340.0}, // 1 {-1414.046752, -314.942993, 7.099884, 340.0}, // 2 {-1415.452636, -311.143432, 7.099884, 340.0}, // 3 {-1407.177612, -314.950805, 7.099882, 340.0}, // 4 {-1407.210937, -321.185729, 7.099879, 340.0}, // 5 {-1405.987304, -318.525573, 7.099879, 340.0} // 6 } }; #define SKINS 4 new TeamSkins[2][SKINS] = { {124, 120, 113, 112}, {163, 164, 165, 166} }; //gg //{-1459.521728, -105.610702, 6.790548}, // 7? //{-1462.035888, -104.870208, 6.768606}, // 8? //{-1463.539306, -101.593833, 6.768606}, // 9? #define SPEC_NUM 5 #define SPEC_HIGHT 200 new Float:SpecSpawns[SPEC_NUM][2][3] = { { {-1475.081176, -118.927009, 10.007267}, // Camera 1a {-1457.487426, -108.798439, 6.789279} // Camera 1b },{ {-1467.455200, 35.397129, 6.000000}, // 2a {-1466.501953, -213.556167, 6.000000} // 2b },{ {-1428.425537, -322.532531, 10.940030}, // 3a {-1417.312377, -292.465881, 6.000000} // 3b },{ {-1336.512939, 40.696838, 9.743233}, // 4a {-1356.759521, 13.635001, 6.000000} // 4b },{ {-1423.224853, -145.871856, 10.175897}, // 5a {-1474.123046, -102.267585, 7.432641} // 5b } }; main() { print("\n----------------------------------"); print(" Van Assault "); print(" By Yellowblood"); print("----------------------------------\n"); } #define SPEC_SECONDS 20 //new spec_timer; new vanid; public OnGameModeInit() { print("GameModeInit( Van Assault )"); SetGameModeText("Van Assault"); AddPlayerClass(TeamSkins[0][0], -1364.424072, -249.121627, 16.406250, 269.1425, 0, 0, 0, 0, 0, 0); AddPlayerClass(TeamSkins[1][0], -1364.424072, -249.121627, 16.406250, 269.1425, 0, 0, 0, 0, 0, 0); AddPlayerClass(0, -1364.424072, -249.121627, 16.406250, 269.1425, 0, 0, 0, 0, 0, 0); //vehicles vanid = AddStaticVehicle(413,-1459.0176,-111.8537,6.0844,87.0118,VCOLOR_BLACK,VCOLOR_BLACK); // van? AddStaticVehicle(404,-1442.5953,-200.3978,5.7338,81.4238,123,92); // AddStaticVehicle(404,-1397.2808,-131.0975,5.7321,306.3851,123,92); // AddStaticVehicle(426,-1474.4688,-81.5275,5.7431,283.7412,62,62); // AddStaticVehicle(426,-1338.1917,-37.2883,5.7430,101.3431,62,62); // AddStaticVehicle(426,-1387.2928,-233.9768,5.7424,100.6595,62,62); // AddStaticVehicle(431,-1392.1422,-31.3672,6.0994,315.8300,55,83); // bus AddStaticVehicle(479,-1385.7233,-20.9471,5.7934,259.3298,55,41); // AddStaticVehicle(490,-1416.1698,-328.2638,6.2680,270.6664,0,0); //1 AddStaticVehicle(490,-1427.8296,-315.3505,6.1454,79.0003,0,0); //2 AddStaticVehicle(490,-1428.9440,-298.9905,6.1273,246.3253,0,0); //3 AddStaticVehicle(490,-1440.9354,-302.3441,6.1290,356.8027,0,0); // black van 4 AddStaticVehicle(507,-1401.7369,-299.0592,5.9133,19.7786,62,62); // AddStaticVehicle(507,-1458.8735,-200.3237,5.8255,288.5834,62,62); // AddStaticVehicle(514,-1412.5598,-259.0888,6.5857,337.4743,36,1); // truck AddStaticVehicle(543,-1442.5507,-9.0936,5.8160,260.9279,43,8); // AddStaticVehicle(589,-1352.3855,-108.4896,5.6581,91.8413,23,23); // AddStaticVehicle(420,-1441.7850,-108.8201,5.7789,76.6086,6,1); // AddStaticVehicle(420,-1337.3711,-205.4834,5.7795,279.6441,6,1); // AddStaticVehicle(456,-1339.0012,19.4241,6.1734,170.1838,12,95); // enemy spawn AddStaticVehicle(462,-1452.9492,-88.5416,5.9329,154.9849,1,3); // bike AddStaticVehicle(499,-1448.7606,42.0297,5.9917,6.7231,84,66); // pickup truck1 AddStaticVehicle(499,-1425.7772,-171.0195,5.9917,281.9906,84,66); // pickup 2 AddStaticVehicle(533,-1370.1367,-200.5490,5.7091,279.1694,83,1); // showoff car AddStaticVehicle(552,-1414.0909,-132.4787,5.6786,56.6505,49,49); // crashed roads constructing vehicle vehicles = AddStaticVehicle(578,-1473.4608,-63.2072,6.6223,89.6307,1,1); // truck printf("Van: %d vehicles: %d",vanid, vehicles); ShowNameTags(0); ShowPlayerMarkers(0); return 1; } public OnPlayerRequestClass(playerid, classid) { if(modeint == 1) { SetTimer("UpdateSpectator", SPEC_SECONDS * 1000, 1); SetTimer("StartRound", 30000, 0); modeint = 0; } printf("OnPlayerRequestClass"); // printf("OnPlayerRequestClass(%d, %d)", playerid, classid); SetPlayerPos(playerid, -1364.424072, -249.121627, 16.406250); SetPlayerFacingAngle(playerid, 315); SetPlayerCameraPos(playerid, -1355.627197, -240.417694, 21.987598); SetPlayerCameraLookAt(playerid, -1364.424072, -249.121627, 16.406250); printf("OnPlayerRequestClass Camera done"); SetPlayerColor(playerid, COLOR_BLUE); printf("Colors"); Spec[playerid] = 0; if(classid == 0) { Teami[playerid] = - ASS_TEAM; GameTextForPlayer(playerid, "~r~ASSAULT", 10000, 6); printf("classid == 0"); } else if(classid == 1) { Teami[playerid] = - DEF_TEAM; GameTextForPlayer(playerid, "~b~defense", 10000, 6); printf("classid == 1"); } else { Teami[playerid] = 0; GameTextForPlayer(playerid, "~w~SPECTATORS", 10000, 6); printf("classid == else"); } printf("return"); return 1; } public OnGameModeExit() { print("GameModeExit()"); return 1; } public OnPlayerConnect(playerid) { Spec[playerid] = 0; Teami[playerid] = 0; SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Yellowblood's Van Assault mode!"); SendClientMessage(playerid, COLOR_YELLOW, "There are two teamns: Defense and Assault. If you die, you will have to wait until next round."); SendClientMessage(playerid, COLOR_LIGHTBLUE, "Type /help for more info."); // printf("OnPlayerConnect(%d)", playerid); return 1; } public OnPlayerDisconnect(playerid) { Teami[playerid] = 0; if(gamestarted == 1) { new ass,def; GetTeamSize(ass,def); if(ass == 0 || def == 0) { if(def > 0) AlmostEndRound(ASS_ELIM); else if(ass > 0) AlmostEndRound(DEF_ELIM); else AlmostEndRound(DRAW); } } // printf("OnPlayerDisconnect(%d)", playerid); return 1; } public OnPlayerSpawn(playerid) { GameTextForPlayer(playerid, " ", 100, 6); new ass,def; GetTeamSize(ass, def); if(gamestarted == 1 || Teami[playerid] == 0) Spec[playerid] = 1; if(Spec[playerid] != 0) { new sr = random(SPEC_NUM); SetPlayerColor(playerid, COLOR_WHITE); SpecPlayer(playerid, sr); if(Teami[playerid] == 0) SendClientMessage(playerid, COLOR_YELLOW, "You are now on spectator mode. Hit F4 and type /getout to start playing."); return 1; } else { if(Teami[playerid] > 0) Teami[playerid] = - Teami[playerid]; printf("ass: %d def: %d", ass,def); for(new i=1; i <= vehicles; i++) SetVehicleParamsForPlayer(i, playerid, 0, 1); // TogglePlayerControllable(playerid,1); if((Teami[playerid] == - DEF_TEAM && ass+1 >= def) || ass > def + 1) {//defense if(Teami[playerid] != - DEF_TEAM) SendClientMessage(playerid, COLOR_WHITE, "You were forced to change teams to Defense."); Teami[playerid] = DEF_TEAM; DisablePlayerCheckpoint(playerid); SetVehicleParamsForPlayer(1, playerid, 1, 1); SetPlayerColor(playerid, COLOR_SHINEGREEN); SendClientMessage(playerid, COLOR_YELLOW, "You are on defense team. Your objective is to protect the black van."); } else {//assault if(Teami[playerid] != - ASS_TEAM) SendClientMessage(playerid, COLOR_WHITE, "You were forced to change teams to Assault."); Teami[playerid] = ASS_TEAM; SetPlayerColor(playerid, COLOR_SHINERED); SetPlayerCheckpoint(playerid, -1462.83, -112.57, 6.0,2); SendClientMessage(playerid, COLOR_YELLOW, "You are on assault team. Your objective is to secure the black van."); } mSpawnPlayer(playerid); // new string[256]; // format(string, sizeof(string), "Game starts in a few seconds"); SendClientMessage(playerid, COLOR_RED, "Game starts in a few seconds."); if(gamestarted == 0) TogglePlayerControllable(playerid,0); return 1; } return 0; } public OnPlayerDeath(playerid, killerid, reason) { SendDeathMessage(killerid, playerid, reason); if(IsPlayerConnected(killerid) && Teami[killerid] == Teami[playerid]) { SetPlayerScore(killerid, GetPlayerScore(playerid) - 1); GameTextForPlayer(killerid, "~r~do not ~w~teamkill", 6000, 3); new Float:health; //hurt tk noob GetPlayerHealth(killerid, health); SetPlayerHealth(killerid, health - 40.0); } else { SetPlayerScore(killerid, GetPlayerScore(playerid) + 1); if(Teami[playerid] > 0) Teami[playerid] = - Teami[playerid]; } DisablePlayerCheckpoint(playerid); SetVehicleParamsForPlayer(1, playerid, 0, 1); if(gamestarted == 1) { new ass,def; GetTeamSize(ass,def); if(ass == 0 || def == 0) { for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) TogglePlayerControllable(i, 0); if(def > 0) AlmostEndRound(ASS_ELIM); else if(ass > 0) AlmostEndRound(DEF_ELIM); else AlmostEndRound(DRAW); } else Spec[playerid] = 1; } return 1; } public OnVehicleSpawn(vehicleid) { // printf("OnVehicleSpawn(%d)", vehicleid); return 1; } public OnVehicleDeath(vehicleid, killerid) { // printf("OnVehicleDeath(%d, %d)", vehicleid, killerid); return 1; } public OnPlayerText(playerid,text[]) { if (text[0] == '@') return 0; new pteam = Teami[playerid]; new pname[256]; GetPlayerName(playerid,pname,sizeof pname); if (text[0]=='!' && pteam != 0) { for (new i=0 ; i z-1) // { new sr = Spec[i]; if(sr == SPEC_NUM) { sr = 0; Spec[i] = 1; } else Spec[i]++ ; SpecPlayer(i, sr); // } } return 1; } public CounterRound() { // printf("CounterRound(%d)", round_counter); if(round_counter > 0) { new minutes, seconds; minutes = round_counter / 60; seconds = round_counter - minutes * 60; new string[256]; if(seconds > 9) format(string, sizeof(string), "~b~%d:%d",minutes, seconds); else format(string, sizeof(string), "~b~%d:0%d",minutes, seconds); GameTextForAll(string ,1500, 6); round_counter --; } else { AlmostEndRound(DEF_OBJ); return 1; } if(PlayerSecure[0] != INVALID_PLAYER_ID) { if(PlayerSecure[1] > 0) { new string[256] = "~r~"; for(new i=PlayerSecure[1]; i < SECURE_SECONDS;i++) { format(string, sizeof(string),"%s|",string); } format(string, sizeof(string),"%s~w~",string); for(new i=1; i <= PlayerSecure[1];i++) { format(string, sizeof(string),"%s|",string); } GameTextForPlayer(PlayerSecure[0], string, 1500, 3); PlayerSecure[1] = PlayerSecure[1] - 1; } else { new string[256]; GetPlayerName(PlayerSecure[0], string, sizeof(string)); format(string, sizeof(string),"%s secured the van!",string); SendClientMessageToAll(COLOR_LIGHTRED, string); AlmostEndRound(ASS_OBJ); } } return 1; } public AlmostEndRound(reason) { round_counter = ROUND_TIME; KillTimer(round_timer); for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) { Spec[i] = 0; TogglePlayerControllable(i, 0); } if(reason == DEF_ELIM || reason == ASS_OBJ) { wins[ASS_TEAM]++; SendClientMessageToAll(COLOR_LIGHTRED, "Assault team has won!"); } else if(reason == ASS_ELIM || reason == DEF_OBJ) { wins[DEF_TEAM]++; SendClientMessageToAll(COLOR_LIGHTGREEN, "Defense team has won!"); } new string[256]; switch(reason) { case DRAW: format(string, sizeof(string), "~w~WTF? DRAW!"); case ASS_ELIM: format(string, sizeof(string), "~w~Assault team eliminated"); case DEF_ELIM: format(string, sizeof(string), "~w~Defense team eliminated"); case ASS_OBJ: format(string, sizeof(string), "~w~Van secured"); case DEF_OBJ: format(string, sizeof(string), "~w~Time is over"); } GameTextForAll(string, 10000, 3); new temp[256]; format(temp, sizeof(temp), "Scores: Assault %d : %d Defense", wins[ASS_TEAM], wins[DEF_TEAM]); SendClientMessageToAll(COLOR_GREEN, temp); PlayerSecure[0] = INVALID_PLAYER_ID; PlayerSecure[1] = SECURE_SECONDS; SetTimer("EndRound", 10000, 0); return 1; } public EndRound(reason) { //publish scores //publish team wins gamestarted = 0; for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && Teami[i] != 0) { Spec[i] = 0; SpawnPlayer(i); TogglePlayerControllable(i, 0); SetPlayerHealth(i, 100.0); } SetTimer("StartRound", FOREPLAY * 1000, 0); return 1; } public StartRound() { new ass,def; GetTeamSize(ass,def); if(ass+def >= START_LIMIT) { printf("Round Started!"); gamestarted = 1; for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && Teami[i] > 0) { TogglePlayerControllable(i, 1); } round_timer = SetTimer("CounterRound", 1000, 1); return 1; } else { printf("Needs stuff"); new string[256]; format(string, sizeof(string), "Needs %d more players to start", (START_LIMIT - ass - def)); SendClientMessageToAll(COLOR_YELLOW,string); SetTimer("StartRound", FOREPLAY * 1000, 0); return 1; } return 0; }