Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Script by: Bullet
- Map by: Bullet
- Mission Base: Capture The Flag
- Mission Type: Capture The Flag
- Mission Type ID: 6
- */
- //==============================================================================
- // Includes
- //==============================================================================
- #include <a_samp>
- #include <crashdetect>
- #include <float>
- #include <fixes2>
- #include "..\filterscripts\MM\stuff\defines"
- #include "..\filterscripts\MM\stuff\serverkeymsg"
- //==============================================================================
- // Defines
- //==============================================================================
- #define MISSION_NAME "Mine Wars"
- #define Health 99.0
- #define VEHICLE_HEALTH 999.0
- #define TEAM_ATTACK_NAME "Cowboys"
- #define TEAM_DEFEND_NAME "Workers"
- #define CP_POS 393.4844,4033.3633,9.4901
- #define CP_SIZE 3.0
- #define TEAM_DEFEND_CAPTURE 329.9418,3971.8276,14.0544
- #define TEAM_ATTACK_CAPTURE 421.6885,4089.8411,5.2357
- #define MAX_MAP_OBJECTS 63
- #define CLASS_POSTION 1566.2374,-3066.1609,5.2656
- #define CLASS_CAMERA 1575.1250,-3066.3704,5.2656
- #define CLASS_FACING_AGNLE 266.8701
- #define OBJ_NAME "Diamond"
- #define OBJ_ID 1559
- #define SPAWN_PROTECTION true
- //==============================================================================
- // Per mission functions
- //==============================================================================
- enum ped_enum
- {
- TeamID,
- Skin,
- Float:SpawnX,
- Float:SpawnY,
- Float:SpawnZ,
- Float:SpawnAngle,
- SpawnInterior,
- VirtualWorld,
- Weapon1,
- Ammo1,
- Weapon2,
- Ammo2,
- Weapon3,
- Ammo3,
- };
- new PedInfo[][ped_enum] = {
- {TEAM_ATTACK, 30, 421.6885,4089.8411,5.2357,245.4168,0,0,WEAPON_DEAGLE,210,WEAPON_AK47,500,WEAPON_GRENADE,5},
- {TEAM_DEFEND, 287,329.9418,3971.8276,14.0544,71.8283,0,0,WEAPON_DEAGLE,210,WEAPON_M4,500,WEAPON_GRENADE,5}
- };
- #if MAX_MAP_OBJECTS != 0
- new Object[MAX_MAP_OBJECTS];
- CreateMap()
- {
- Object[0] = CreateObject(11696,389.7102100,4055.4184600,5.0000000,0.0000000,0.0000000,0.0000000); //
- Object[1] = CreateObject(744,416.2350800,4088.9177200,3.6876600,0.0000000,0.0000000,50.0000000); //
- Object[2] = CreateObject(744,418.1844800,4092.5312500,3.3391800,0.0000000,0.0000000,58.0000000); //
- Object[3] = CreateObject(744,334.6243600,3968.6020500,13.0915900,0.0000000,0.0000000,-33.0000000); //
- Object[4] = CreateObject(744,335.2477100,3972.0681200,12.8975000,0.0000000,0.0000000,-33.0000000); //
- Object[5] = CreateObject(2936,409.3111300,4030.9980500,27.7112600,0.0000000,0.0000000,0.0000000); //
- Object[6] = CreateObject(2936,414.3909300,4031.0017100,27.7112600,0.0000000,0.0000000,0.0000000); //
- Object[7] = CreateObject(2936,421.4023700,4027.6796900,27.1719200,0.0000000,0.0000000,0.0000000); //
- Object[8] = CreateObject(2936,421.0508700,4035.2319300,27.1719200,0.0000000,0.0000000,0.0000000); //
- Object[9] = CreateObject(2936,404.9755200,4031.6892100,28.3711200,0.0000000,0.0000000,0.0000000); //
- Object[10] = CreateObject(2936,398.3390200,4036.0874000,28.4310100,0.0000000,0.0000000,0.0000000); //
- Object[11] = CreateObject(2936,405.7936400,4035.7717300,28.4909200,0.0000000,0.0000000,0.0000000); //
- Object[12] = CreateObject(2936,394.6105700,4032.4885300,27.7578300,0.0000000,0.0000000,0.0000000); //
- Object[13] = CreateObject(2936,387.3726200,4037.0744600,28.0806300,0.0000000,0.0000000,0.0000000); //
- Object[14] = CreateObject(2936,384.8745100,4031.6486800,27.6379900,0.0000000,0.0000000,0.0000000); //
- Object[15] = CreateObject(2936,374.4191000,4031.7106900,27.1788700,0.0000000,0.0000000,0.0000000); //
- Object[16] = CreateObject(2936,375.5055200,4038.7756300,27.1788700,0.0000000,0.0000000,0.0000000); //
- Object[17] = CreateObject(2936,385.6531100,4025.2939500,26.3162400,0.0000000,0.0000000,0.0000000); //
- Object[18] = CreateObject(2936,378.1670800,4025.0485800,25.8150600,0.0000000,0.0000000,0.0000000); //
- Object[19] = CreateObject(2936,388.2245800,4017.8886700,21.9005700,0.0000000,0.0000000,0.0000000); //
- Object[20] = CreateObject(2936,382.8870800,4017.6086400,21.9005700,0.0000000,0.0000000,0.0000000); //
- Object[21] = CreateObject(2936,396.6984600,4025.4943800,26.9160100,0.0000000,0.0000000,0.0000000); //
- Object[22] = CreateObject(2936,398.0264000,4022.4123500,25.4084500,0.0000000,0.0000000,0.0000000); //
- Object[23] = CreateObject(2936,391.7637900,4028.3559600,27.6371100,0.0000000,0.0000000,0.0000000); //
- Object[24] = CreateObject(2936,371.6201500,4028.2412100,27.1788700,0.0000000,0.0000000,0.0000000); //
- Object[25] = CreateObject(2936,370.8545200,4022.1367200,24.6416400,0.0000000,0.0000000,0.0000000); //
- Object[26] = CreateObject(2936,364.9714400,4025.9677700,25.9469700,0.0000000,0.0000000,0.0000000); //
- Object[27] = CreateObject(2936,370.9244100,4015.0666500,18.2966300,0.0000000,0.0000000,0.0000000); //
- Object[28] = CreateObject(2936,379.3250700,4014.5268600,16.9324600,0.0000000,0.0000000,0.0000000); //
- Object[29] = CreateObject(2936,442.8230000,4030.3327600,19.9380900,0.0000000,0.0000000,0.0000000); //
- Object[30] = CreateObject(2936,421.5344200,4017.1218300,19.9380900,0.0000000,0.0000000,0.0000000); //
- Object[31] = CreateObject(2936,414.4274900,4023.0278300,25.5998000,0.0000000,0.0000000,0.0000000); //
- Object[32] = CreateObject(2936,421.4812000,4022.5737300,25.3660800,0.0000000,0.0000000,0.0000000); //
- Object[33] = CreateObject(2936,436.8805800,4007.6936000,34.4646600,0.0000000,0.0000000,0.0000000); //
- Object[34] = CreateObject(2936,417.6314100,4017.9480000,21.3593700,0.0000000,0.0000000,0.0000000); //
- Object[35] = CreateObject(2936,386.2952000,4046.3584000,20.9764500,0.0000000,0.0000000,0.0000000); //
- Object[36] = CreateObject(2936,404.3441800,4046.7661100,21.2013500,0.0000000,0.0000000,0.0000000); //
- Object[37] = CreateObject(2936,415.2910500,4043.7507300,19.0575200,0.0000000,0.0000000,0.0000000); //
- Object[38] = CreateObject(2936,414.3179900,4041.5219700,23.2484600,0.0000000,0.0000000,0.0000000); //
- Object[39] = CreateObject(2936,428.5527000,4036.8481400,23.2484600,0.0000000,0.0000000,0.0000000); //
- Object[40] = CreateObject(899,436.1568900,4025.3403300,3.0000000,0.0000000,0.0000000,0.0000000); //
- Object[41] = CreateObject(899,422.3172300,4026.0483400,3.0000000,0.0000000,0.0000000,-30.0000000); //
- Object[42] = CreateObject(899,423.3393900,4037.9108900,3.0000000,0.0000000,0.0000000,-30.0000000); //
- Object[43] = CreateObject(899,402.5417200,4040.8576700,3.0000000,0.0000000,0.0000000,-30.0000000); //
- Object[44] = CreateObject(899,406.1453600,4023.2724600,3.0199200,0.0000000,0.0000000,-30.0000000); //
- Object[45] = CreateObject(899,388.9830000,4025.8439900,3.0000000,0.0000000,0.0000000,-30.0000000); //
- Object[46] = CreateObject(899,388.1668700,4037.2131300,3.0000000,0.0000000,0.0000000,-30.0000000); //
- Object[47] = CreateObject(899,374.4233400,4022.0502900,3.0000000,0.0000000,0.0000000,120.0000000); //
- Object[48] = CreateObject(899,370.8603800,4039.9008800,3.0000000,0.0000000,0.0000000,120.0000000); //
- Object[49] = CreateObject(899,352.3211400,4035.7771000,3.0000000,0.0000000,0.0000000,120.0000000); //
- Object[50] = CreateObject(899,354.3014800,4017.4646000,3.0000000,0.0000000,0.0000000,120.0000000); //
- Object[51] = CreateObject(899,337.0445300,4019.9873000,3.0000000,0.0000000,0.0000000,120.0000000); //
- Object[52] = CreateObject(899,336.9896200,4037.8071300,3.0000000,0.0000000,0.0000000,120.0000000); //
- Object[53] = CreateObject(899,435.3073700,4009.3430200,3.0000000,0.0000000,0.0000000,-30.0000000); //
- Object[54] = CreateObject(899,392.9835500,4014.7258300,3.0199200,0.0000000,0.0000000,-30.0000000); //
- Object[55] = CreateObject(3865,372.6852700,4023.5202600,9.9230100,0.0000000,0.0000000,0.0000000); //
- Object[56] = CreateObject(3865,353.8850400,4033.0817900,9.9230100,0.0000000,0.0000000,0.0000000); //
- Object[57] = CreateObject(3865,394.6105000,4033.2678200,9.9230000,0.0000000,0.0000000,-66.0000000); //
- Object[58] = CreateObject(3865,429.8086900,4032.0449200,8.6218000,-10.0000000,0.0000000,-33.0000000); //
- Object[59] = CreateObject(3865,405.7546100,4021.6103500,9.9230000,0.0000000,0.0000000,40.0000000); //
- Object[60] = CreateObject(899,439.9010300,4021.5190400,3.0000000,0.0000000,0.0000000,0.0000000); //
- Object[61] = CreateObject(899,423.2704200,4013.1130400,3.0000000,0.0000000,0.0000000,-30.0000000); //
- Object[62] = CreateObject(3865,366.7371200,4036.0654300,8.7915600,13.2600000,-34.2599900,-87.7200200); //
- }
- #endif
- //==============================================================================
- // Basic vars
- //==============================================================================
- new bool:MissionStarted;
- new bool:ObjectiveStarted;
- new bool:MissionCancelled;
- native IsValidVehicle(vehicleid);
- enum teamdata
- {
- Kills,
- Name[32],
- Members,
- Points
- };
- enum playerdata
- {
- UserName[MAX_PLAYER_NAME],
- bool:TeamChosen,
- TeamSelection,
- PlayerClassID,
- PlayerPointsTaken,
- Counted
- };
- new Team[2][teamdata];
- new PlayerMissionInfo[MAX_PLAYERS][playerdata];
- new Collecting= INVALID_PLAYER_ID;
- new ObjectiveObj;
- //==============================================================================
- // Basic script
- //==============================================================================
- main()
- {
- print("----------------------------------");
- print(" Mission: "MISSION_NAME" started.");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- MissionStarted= true;
- format(Team[TEAM_DEFEND][Name],32,"%s",TEAM_DEFEND_NAME);
- format(Team[TEAM_ATTACK][Name],32,"%s",TEAM_ATTACK_NAME);
- if(CallRemoteFunction("GetCurrentMissionCJWalk","")) UsePlayerPedAnims();
- #if MAX_MAP_OBJECTS != 0
- CreateMap();
- #endif
- for(new i=0; i<sizeof(PedInfo); i++)AddPlayerClassEx(PedInfo[i][TeamID],PedInfo[i][Skin],PedInfo[i][SpawnX],PedInfo[i][SpawnY],PedInfo[i][SpawnZ],PedInfo[i][SpawnAngle],0,0,0,0,0,0);
- for(new i=0; i<MAX_VEHICLES; i++) if(IsValidVehicle(i)) SetVehicleHealth(i,VEHICLE_HEALTH);
- for(new i=0; i<MAX_PLAYERS; i++) PlayerMissionInfo[i][TeamSelection]= NO_TEAM;
- ObjectiveObj=CreateObject(19306,CP_POS+2.0,0.0,0.0,0.0);
- Collecting=INVALID_PLAYER_ID;
- SetTimer("StartMissionFunc",3000,false);
- return 1;
- }
- FUNCTION StartMissionFunc()
- {
- CallRemoteFunction("StartMission","");
- ObjectiveStarted= true;
- return 1;
- }
- public OnGameModeExit()
- {
- #if MAX_MAP_OBJECTS != 0
- for(new i=0;i<MAX_MAP_OBJECTS;i++) DestroyObject(Object[i]);
- #endif
- DestroyObject(ObjectiveObj);
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- if(PlayerMissionInfo[playerid][TeamSelection] != NO_TEAM && PlayerMissionInfo[playerid][TeamChosen])
- {
- Team[PlayerMissionInfo[playerid][TeamSelection]][Members] --;
- PlayerMissionInfo[playerid][TeamChosen] = false;
- }
- new string[70];
- if(Collecting == playerid)
- {
- if(!MissionStarted) return 1;
- format(string,sizeof(string),"%s has dropped the "OBJ_NAME"",PlayerMissionInfo[Collecting][UserName]);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, Collecting,string,0);
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(!CallRemoteFunction("GetAliveState","i",i)) continue;
- SetPlayerCheckpoint(i,x,y,z,3.0);
- }
- RemovePlayerAttachedObject(playerid,0);
- ObjectiveObj=CreateObject(OBJ_ID,x,y,z+2.0,0.0,0.0,0.0);
- Collecting=INVALID_PLAYER_ID;
- }
- return 1;
- }
- public OnPlayerRequestClass(playerid,classid)
- {
- SetPlayerPos(playerid,CLASS_POSTION);
- SetPlayerCameraPos(playerid,CLASS_CAMERA);
- SetPlayerCameraLookAt(playerid,CLASS_POSTION);
- SetPlayerFacingAngle(playerid,CLASS_FACING_AGNLE);
- CallRemoteFunction("TdmHide","i",playerid);
- CallRemoteFunction("ShowClassSelection","ddsddd",playerid, PedInfo[classid][TeamID],Team[PedInfo[classid][TeamID]][Name], PedInfo[classid][Weapon1], PedInfo[classid][Weapon2], PedInfo[classid][Weapon3]);
- if(PlayerMissionInfo[playerid][Counted] && PlayerMissionInfo[playerid][TeamSelection] != NO_TEAM)
- {
- Team[PlayerMissionInfo[playerid][TeamSelection]][Members]--;
- PlayerMissionInfo[playerid][Counted] = false;
- }
- PlayerMissionInfo[playerid][TeamSelection] = PedInfo[classid][TeamID];
- PlayerMissionInfo[playerid][PlayerClassID]=classid;
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- new opp_team = (PlayerMissionInfo[playerid][TeamSelection] == 1)? 0:1;
- if(Team[PlayerMissionInfo[playerid][TeamSelection]][Members] > Team[opp_team][Members])
- {
- CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,"This Team is full, choose another!",100);
- return 0;
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SetPlayerHealth(playerid,Health);
- CallRemoteFunction("UpdateAliveState","ii",playerid,1);
- CallRemoteFunction("TdmShow","i",playerid);
- CallRemoteFunction("TdmUpdate","sssdd",OBJ_NAME,Team[TEAM_DEFEND][Name],Team[TEAM_ATTACK][Name],Team[TEAM_DEFEND][Points],Team[TEAM_ATTACK][Points]);
- new string[124];
- if(CallRemoteFunction("GetSpectateStatus","d",playerid)) return CallRemoteFunction("SpecOffAdmin","d",playerid);
- if(CallRemoteFunction("GetJailedStatus","d",playerid)) CallRemoteFunction("SetJailed","d",playerid);
- else
- {
- SetPlayerPos(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnX],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnY],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnZ]);
- SetPlayerFacingAngle(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnAngle]);
- SetPlayerInterior(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnInterior]);
- SetPlayerVirtualWorld(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][VirtualWorld]);
- CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon1],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo1]);
- CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon2],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo2]);
- CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon3],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo3]);
- if(!PlayerMissionInfo[playerid][Counted])
- {
- PlayerMissionInfo[playerid][Counted] = true;
- Team[PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][TeamID]][Members]++;
- format(string,sizeof(string),"You have chosen team %s, Your mission is to capture &s.",Team[PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][TeamID]][Name],OBJ_NAME);
- CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,string,100);
- if(PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][TeamID] == TEAM_ATTACK) format(string,sizeof(string),"~r~~h~Stop ~w~%s.",Team[TEAM_DEFEND][Name]);
- else format(string,sizeof(string),"~r~~h~Stop ~w~%s.",Team[TEAM_ATTACK][Name]);
- CallRemoteFunction("ShowInfoText", "iisi", playerid, -1,string,100);
- }
- if(Collecting == INVALID_PLAYER_ID) SetPlayerCheckpoint(playerid,CP_POS,3.0);
- else
- {
- if(PlayerMissionInfo[Collecting][TeamSelection] == TEAM_ATTACK) SetPlayerCheckpoint(playerid,TEAM_ATTACK_CAPTURE,3.0);
- else SetPlayerCheckpoint(playerid,TEAM_DEFEND_CAPTURE,3.0);
- }
- }
- SetPlayerTeam(playerid,PlayerMissionInfo[playerid][TeamSelection]);
- if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK) SetPlayerColor(playerid,COLOR_TEAM_ATTACK);
- else SetPlayerColor(playerid,COLOR_TEAM_DEFEND);
- TogglePlayerControllable(playerid,true);
- #if SPAWN_PROTECTION == true
- CallRemoteFunction("SetSpawnProtection","df",playerid,Health);
- #endif
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(killerid != INVALID_PLAYER_ID && PlayerMissionInfo[playerid][TeamSelection] != NO_TEAM && MissionStarted)
- {
- Team[PlayerMissionInfo[killerid][TeamSelection]][Kills]++;
- }
- new string[70];
- if(Collecting == playerid)
- {
- if(!MissionStarted) return 1;
- format(string,sizeof(string),"%s has dropped the "OBJ_NAME"",PlayerMissionInfo[Collecting][UserName]);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, Collecting,string,0);
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(!CallRemoteFunction("GetAliveState","i",i)) continue;
- DisablePlayerCheckpoint(i);
- SetPlayerCheckpoint(i,x,y,z,3.0);
- }
- RemovePlayerAttachedObject(playerid,0);
- ObjectiveObj=CreateObject(OBJ_ID,x,y,z+2.0,0.0,0.0,0.0);
- Collecting=INVALID_PLAYER_ID;
- }
- CallRemoteFunction("UpdateAliveState","ii",playerid,0);
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- new string[128];
- if(!MissionStarted || MissionCancelled) return 1;
- if(IsPlayerInAnyVehicle(playerid)) return 1;
- if(Collecting == INVALID_PLAYER_ID)
- {
- DisablePlayerCheckpoint(Collecting);
- Collecting= playerid;
- CallRemoteFunction("ShowInfoBox", "iisi", Collecting, -1,"Deliver this "OBJ_NAME" to your base",0);
- format(string,sizeof(string),"%s is capturing "OBJ_NAME" for %s",PlayerMissionInfo[Collecting][UserName],Team[PlayerMissionInfo[Collecting][TeamSelection]][Name]);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, Collecting,string,0);
- SetPlayerColor(playerid,COLOR_SERVER);
- DisablePlayerCheckpoint(Collecting);
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(!CallRemoteFunction("GetAliveState","i",i)) continue;
- DisablePlayerCheckpoint(i);
- if(PlayerMissionInfo[Collecting][TeamSelection] == TEAM_ATTACK) SetPlayerCheckpoint(i,TEAM_ATTACK_CAPTURE,3.0);
- else SetPlayerCheckpoint(i,TEAM_DEFEND_CAPTURE,3.0);
- }
- DestroyObject(ObjectiveObj);
- SetPlayerAttachedObject(playerid, 0, OBJ_ID, 6, -0.006000,0.010000,0.918000,0.000000,0.000000,0.000000,1.000000,1.000000,1.000000);
- }
- else if(Collecting == playerid)
- {
- format(string,sizeof(string),"%s has captured the "OBJ_NAME" for %s",PlayerMissionInfo[Collecting][UserName],Team[PlayerMissionInfo[Collecting][TeamSelection]][Name]);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, Collecting,string,0);
- PlayerMissionInfo[playerid][PlayerPointsTaken]++;
- CallRemoteFunction("PlayerMissionStats","dd",playerid,7);
- Team[PlayerMissionInfo[playerid][TeamSelection]][Points]++;
- SetPlayerScore(playerid,PlayerMissionInfo[playerid][PlayerPointsTaken]);
- CallRemoteFunction("TdmUpdate","sssdd",OBJ_NAME,Team[TEAM_DEFEND][Name],Team[TEAM_ATTACK][Name],Team[TEAM_DEFEND][Points],Team[TEAM_ATTACK][Points]);
- if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK) SetPlayerColor(playerid,COLOR_TEAM_ATTACK);
- else SetPlayerColor(playerid,COLOR_TEAM_DEFEND);
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(!CallRemoteFunction("GetAliveState","i",i)) continue;
- DisablePlayerCheckpoint(i);
- SetPlayerCheckpoint(i,CP_POS,3.0);
- }
- RemovePlayerAttachedObject(playerid,0);
- ObjectiveObj=CreateObject(OBJ_ID,CP_POS+2.0,0.0,0.0,0.0);
- Collecting=INVALID_PLAYER_ID;
- }
- return 1;
- }
- FUNCTION EndTheMission()
- {
- if(!MissionStarted) return 1;
- MissionStarted= false;
- if(!MissionCancelled)
- {
- new string[256];
- new amount= 10000;
- new winning_team;
- if(Team[TEAM_DEFEND][Points] == Team[TEAM_ATTACK][Points]) { winning_team = 2; }
- else if(Team[TEAM_DEFEND][Points] > Team[TEAM_ATTACK][Points]) { winning_team = 0; }
- else { winning_team = 1; }
- if(winning_team != 2)
- {
- amount =amount+(Team[winning_team][Points]*60);
- format(string,sizeof(string),""SERVER_KEY_MSG" %s has won the capture the "OBJ_NAME"! Reward: $%d",Team[winning_team][Name],amount);
- CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
- SendClientMessageToAll(COLOR_SERVER,string);
- format(string,sizeof(string),""SERVER_KEY_MSG" You have received $%i because your team has won capture the "OBJ_NAME"!",amount);
- for(new i=0,j=GetPlayerPoolSize(); i <= j; i++)
- {
- if(PlayerMissionInfo[i][TeamSelection] == winning_team && PlayerMissionInfo[i][Counted])
- {
- PlayerPlaySound(i,3200,0,0,0);
- SendClientMessage(i,COLOR_SERVER,string);
- CallRemoteFunction("GivePlayerCash","ii",i,amount);
- CallRemoteFunction("PlayerMissionStats","dd",i,0);
- CallRemoteFunction("PlayerMissionStats","dd",i,6);
- }
- if(PlayerMissionInfo[i][TeamSelection] != winning_team && PlayerMissionInfo[i][Counted])
- {
- PlayerPlaySound(i,17004,0,0,0);
- GameTextForPlayer(i,"~R~MISSION FAILED~w~!",3000,3);
- CallRemoteFunction("PlayerMissionStats","dd",i,1);
- }
- }
- }
- else
- {
- PlaySoundForAll(1058);
- format(string,sizeof(string),""SERVER_KEY_MSG" IT'S A DRAW! No team has won capture the "OBJ_NAME".");
- SendClientMessageToAll(COLOR_SERVER,string);
- CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
- for(new i=0,j=GetPlayerPoolSize(); i <= j; i++) if(IsPlayerConnected(i) && PlayerMissionInfo[i][Counted]) CallRemoteFunction("PlayerMissionStats","dd",i,2);
- }
- }
- else
- {
- PlaySoundForAll(1058);
- SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" The mission has been cancelled.");
- CallRemoteFunction("IRC_SendMessage","ss",""SERVER_KEY_MSG" The mission has been cancelled.",IRC_SERVER_COLOR);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"The mission has been cancelled.",0);
- GameTextForAll("~R~MISSION CANCELLED~w~!",3000,3);
- }
- return 1;
- }
- //==============================================================================
- // Mission functions
- //==============================================================================
- PlaySoundForAll(sound)
- {
- for (new i=0,j=GetPlayerPoolSize(); i <=j ; i++)
- {
- if(IsPlayerConnected(i)) PlayerPlaySound(i,sound,0,0,0);
- }
- }
- //==============================================================================
- // Important functions required
- //==============================================================================
- FUNCTION OnPlayerNameRecieve(playerid,name[])
- {
- format(PlayerMissionInfo[playerid][UserName],MAX_PLAYER_NAME,"%s",name);
- return 1;
- }
- FUNCTION CancelTheMission()
- {
- MissionCancelled= true;
- return 1;
- }
- FUNCTION MissionObjectiveStarted() return ObjectiveStarted;
- FUNCTION OnPlayerSpectateObjective(playerid)
- {
- SetPlayerCameraPos(playerid, CP_POS + 2.5);
- SetPlayerCameraLookAt(playerid, CP_POS);
- SetPlayerPos(playerid, CP_POS - 5);
- SetPlayerColor(playerid, (PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK) ? COLOR_TEAM_ATTACK_INV : COLOR_TEAM_DEFEND_INV);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment