Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Script by: Bullet
- Map by: Bullet
- Mission Base: Stealing
- Mission Type: Vehicle stealing
- Mission Type ID: 3
- */
- //==============================================================================
- // Includes
- //==============================================================================
- #include <a_samp>
- #include <crashdetect>
- #include <float>
- #include "..\filterscripts\MM\stuff\defines"
- #include "..\filterscripts\MM\stuff\serverkeymsg"
- //==============================================================================
- // Defines
- //==============================================================================
- #define MISSION_NAME "Grand Theft Bike"
- #define Health 99.0
- #define TEAM_DEFEND_NAME "Mafia"
- #define TEAM_ATTACK_NAME "Russian"
- #define MAX_MAP_OBJECTS 10
- #define VEHICLE_HEALTH 999.0
- #define CLASS_POSTION 2594.0273,2393.2974,17.5443
- #define CLASS_CAMERA 2598.1211,2395.4849,17.8203
- #define CLASS_FACING_AGNLE 299.3985
- #define OBJ_POS -2291.9819,1746.8385,6.4788,59.6400
- #define OBJ_ID 522
- #define OBJ_NAME "Bike"
- #define CP_POS -2399.8987,1952.3320,20.3731
- #define SPAWN_PROTECTION true
- //==============================================================================
- // Per mission functions
- //==============================================================================
- enum skindata
- {
- TeamID,
- SkinID,
- Float:SpawnX,
- Float:SpawnY,
- Float:SpawnZ,
- Float:SpawnAngle,
- SpawnInterior,
- VirtualWorld,
- Weapon1,
- Ammo1,
- Weapon2,
- Ammo2,
- Weapon3,
- Ammo3,
- };
- new const SkinData[][skindata] = {
- {TEAM_ATTACK,113,-2408.2507,1985.0962,19.0050,179.2792,0,0,WEAPON_SNIPER,210,WEAPON_M4,300,WEAPON_SHOTGUN,300},
- {TEAM_DEFEND,124,-2177.8948,1527.8690,14.1751,356.6401,0,0,WEAPON_SNIPER,210,WEAPON_M4,300,WEAPON_SHOTGUN,300}
- };
- #if MAX_MAP_OBJECTS != 0
- new Object[MAX_MAP_OBJECTS];
- CreateMap()
- {
- Object[0] = CreateObject(6982,-2384.3571800,1849.5330800,13.1090400,0.0000000,0.0000400,0.0000000); //
- Object[1] = CreateObject(6983,-2317.2873500,1764.9034400,10.0500700,0.0000000,0.0000400,0.0000000); //
- Object[2] = CreateObject(7357,-2331.8857400,1929.8802500,16.1359300,0.0000000,0.0000400,0.0000000); //
- Object[3] = CreateObject(6915,-2410.1335400,2018.8156700,19.5188200,0.0000000,0.0000400,0.0000000); //
- Object[4] = CreateObject(4112,-2393.7639200,1954.9863300,28.9981900,0.0000000,0.0000000,0.0000000); //
- Object[5] = CreateObject(4112,-2421.5026900,1957.1076700,28.9981900,0.0000000,0.0000000,0.0000000); //
- Object[6] = CreateObject(4594,-2409.4860800,1903.0615200,19.2708000,0.0000000,0.0000000,-90.0599900); //
- Object[7] = CreateObject(4594,-2379.0681200,2001.4565400,17.9344600,0.0000000,0.0000000,-90.0599900); //
- Object[8] = CreateObject(972,-2187.3190900,1650.6822500,10.4114200,0.0000000,0.0000000,113.8800700); //
- Object[9] = CreateObject(6984,-2234.7304700,1693.1379400,11.3096200,0.0000000,0.0000000,0.0000000); //
- }
- #endif
- //==============================================================================
- // Basic vars
- //==============================================================================
- new bool:MissionStarted;
- new bool:ObjectiveStarted;
- new bool:MissionCancelled;
- new bool:ObjectiveStolen;
- new ObjectiveStolenBy;
- native IsValidVehicle(vehicleid);
- enum obj
- {
- ObjectiveVeh,
- ObjectiveName[30],
- ObjectiveMarker,
- Float:ObjectiveEndX,
- Float:ObjectiveEndY,
- Float:ObjectiveEndZ
- };
- enum teamdata
- {
- Name[32],
- Members,
- Kills
- };
- enum playerdata
- {
- UserName[MAX_PLAYER_NAME],
- bool:TeamChosen,
- TeamSelection,
- PlayerClassID
- };
- new Team[2][teamdata];
- new PlayerMissionInfo[MAX_PLAYERS][playerdata];
- new ObjectiveInfo[obj];
- //==============================================================================
- // Basic script
- //==============================================================================
- main()
- {
- print("----------------------------------");
- print(" Mission: "MISSION_NAME" started.");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- AddStaticVehicleEx(468,-2411.0889000,1977.3751000,18.3254000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2411.1375000,1980.0914000,18.3991000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2411.2300000,1982.9172000,18.5653000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2411.2952000,1985.7749000,18.7043000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2410.9011000,1974.6755000,18.3254000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2411.2349000,1988.2758000,18.7796000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2405.8425000,1974.5273000,18.3479000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2405.9063000,1977.5974000,18.3254000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2405.8535000,1981.0378000,18.3991000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2405.9844000,1984.3181000,18.5653000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2405.7859000,1988.1534000,18.7796000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2405.9055000,1971.7267000,18.3479000,-174.8400000,-1,-1,15); //Sanchez
- AddStaticVehicleEx(468,-2410.7207000,1971.7883000,18.3479000,-174.8400000,-1,-1,15); //Sanchez
- MissionStarted= true;
- format(Team[TEAM_DEFEND][Name],32,"%s",TEAM_DEFEND_NAME);
- format(Team[TEAM_ATTACK][Name],32,"%s",TEAM_ATTACK_NAME);
- format(ObjectiveInfo[ObjectiveName],sizeof(ObjectiveInfo[ObjectiveName]),"%s",OBJ_NAME);
- ObjectiveInfo[ObjectiveVeh] = CreateVehicle(OBJ_ID,OBJ_POS,random(225),random(225),3);
- SetVehicleHealth(ObjectiveInfo[ObjectiveVeh],1100);
- new iEngine, iLights, iAlarm, iDoors, iBonnet, iBoot, iObjective;
- GetVehicleParamsEx(ObjectiveInfo[ObjectiveVeh], iEngine, iLights, iAlarm, iDoors, iBonnet, iBoot, iObjective);
- SetVehicleParamsEx(ObjectiveInfo[ObjectiveVeh], iEngine, iLights, iAlarm, iDoors, iBonnet, iBoot, 1);
- for(new i=0; i<sizeof(SkinData); i++)
- {
- AddPlayerClassEx(SkinData[i][TeamID],SkinData[i][SkinID],SkinData[i][SpawnX],SkinData[i][SpawnY],SkinData[i][SpawnZ],SkinData[i][SpawnAngle],0,0,0,0,0,0);
- }
- for(new i=0; i<MAX_PLAYERS; i++) PlayerMissionInfo[i][TeamSelection]= NO_TEAM;
- for(new i=0; i<MAX_VEHICLES; i++) if(IsValidVehicle(i)) SetVehicleHealth(i,VEHICLE_HEALTH);
- if(CallRemoteFunction("GetCurrentMissionCJWalk","")) UsePlayerPedAnims();
- 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
- for(new i=0; i<MAX_VEHICLES; i++)
- {
- DestroyVehicle(i);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- if(PlayerMissionInfo[playerid][TeamChosen] && PlayerMissionInfo[playerid][TeamSelection] != NO_TEAM)
- {
- Team[PlayerMissionInfo[playerid][TeamSelection]][Members] --;
- PlayerMissionInfo[playerid][TeamChosen]=false;
- }
- return 1;
- }
- public OnPlayerRequestClass(playerid,classid)
- {
- SetPlayerPos(playerid,CLASS_POSTION);
- SetPlayerCameraPos(playerid,CLASS_CAMERA);
- SetPlayerCameraLookAt(playerid,CLASS_POSTION);
- SetPlayerFacingAngle(playerid,CLASS_FACING_AGNLE);
- CallRemoteFunction("ShowClassSelection","iisiii",playerid, SkinData[classid][TeamID],Team[SkinData[classid][TeamID]][Name], SkinData[classid][Weapon1], SkinData[classid][Weapon2], SkinData[classid][Weapon3]);
- if(PlayerMissionInfo[playerid][TeamChosen])
- {
- PlayerMissionInfo[playerid][TeamChosen] = false;
- Team[PlayerMissionInfo[playerid][TeamSelection]][Members]--;
- }
- PlayerMissionInfo[playerid][TeamSelection] = SkinData[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!",0);
- return 0;
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SetPlayerHealth(playerid,Health);
- new string[124];
- CallRemoteFunction("UpdateAliveState","ii",playerid,1);
- if(CallRemoteFunction("GetSpectateStatus","d",playerid)) return CallRemoteFunction("SpecOffAdmin","d",playerid);
- if(CallRemoteFunction("GetJailedStatus","d",playerid)) CallRemoteFunction("SetJailed","d",playerid);
- else
- {
- SetPlayerPos(playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][SpawnX],SkinData[PlayerMissionInfo[playerid][PlayerClassID]][SpawnY],SkinData[PlayerMissionInfo[playerid][PlayerClassID]][SpawnZ]);
- SetPlayerInterior(playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][SpawnInterior]);
- SetPlayerFacingAngle(playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][SpawnAngle]);
- SetPlayerVirtualWorld(playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][VirtualWorld]);
- if(!PlayerMissionInfo[playerid][TeamChosen])
- {
- Team[PlayerMissionInfo[playerid][TeamSelection]][Members]++;
- PlayerMissionInfo[playerid][TeamChosen] = true;
- if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK)
- {
- format(string,sizeof(string),"You are a %s, your mission is to steal the %s.",Team[TEAM_ATTACK][Name],ObjectiveInfo[ObjectiveName]);
- CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,string,2000);
- format(string,sizeof(string),"%s will try to stop you, eliminate them!.",Team[TEAM_DEFEND][Name]);
- CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1, string,4000);
- format(string,sizeof(string),"Steal the ~y~%s~w~!",ObjectiveInfo[ObjectiveName]);
- CallRemoteFunction("ShowInfoText", "iisi", playerid, -1, string,1000);
- }
- else
- {
- format(string,sizeof(string),"You are a %s, your mission is to protect the %s from %s.",Team[TEAM_DEFEND][Name],ObjectiveInfo[ObjectiveName],Team[TEAM_ATTACK][Name]);
- CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,string,2000);
- format(string,sizeof(string),"Protect the ~y~%s~w~!.",ObjectiveInfo[ObjectiveName]);
- CallRemoteFunction("ShowInfoText", "iisi", playerid, -1, string,1000);
- }
- CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Weapon1],SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Ammo1]);
- CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Weapon2],SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Ammo2]);
- CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Weapon3],SkinData[PlayerMissionInfo[playerid][PlayerClassID]][Ammo3]);
- }
- }
- SetPlayerTeam(playerid,PlayerMissionInfo[playerid][TeamSelection]);
- if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK) SetPlayerColor(playerid,COLOR_TEAM_ATTACK);
- else SetPlayerColor(playerid,COLOR_TEAM_DEFEND);
- #if SPAWN_PROTECTION == true
- CallRemoteFunction("SetSpawnProtection","df",playerid,Health);
- #endif
- if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_DEFEND) SetVehicleParamsForPlayer(ObjectiveInfo[ObjectiveVeh],playerid,1,1);
- else SetVehicleParamsForPlayer(ObjectiveInfo[ObjectiveVeh],playerid,1,0);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(killerid != INVALID_PLAYER_ID)
- {
- SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
- Team[PlayerMissionInfo[killerid][TeamSelection]][Kills]++;
- }
- if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK)
- {
- if(GetPlayerVehicleID(playerid) == ObjectiveInfo[ObjectiveVeh])
- {
- new string[124];
- format(string,sizeof(string),"%s has died and left the %s's %s.",PlayerMissionInfo[playerid][UserName],Team[TEAM_DEFEND][Name],ObjectiveInfo[ObjectiveName]);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1, string,0);
- DisablePlayerRaceCheckpoint(playerid);
- }
- }
- CallRemoteFunction("UpdateAliveState","ii",playerid,0);
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK)
- {
- if(vehicleid == ObjectiveInfo[ObjectiveVeh])
- {
- new string[124];
- format(string,sizeof(string),"%s is stealing the %s's %s.",PlayerMissionInfo[playerid][UserName],Team[TEAM_DEFEND][Name],ObjectiveInfo[ObjectiveName]);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1, string,0);
- SetPlayerCheckpoint(playerid,CP_POS,10.0);
- }
- }
- else
- {
- if(vehicleid == ObjectiveInfo[ObjectiveVeh])
- {
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- SetPlayerPos(playerid,x,y,z+3);
- ClearAnimations(playerid);
- }
- }
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK)
- {
- if(vehicleid == ObjectiveInfo[ObjectiveVeh])
- {
- new string[124];
- format(string,sizeof(string),"%s has left the %s's %s.",PlayerMissionInfo[playerid][UserName],Team[TEAM_DEFEND][Name],ObjectiveInfo[ObjectiveName]);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1, string,0);
- DisablePlayerCheckpoint(playerid);
- }
- }
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- if(!MissionStarted || ObjectiveStolen) return 1;
- if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK)
- {
- if(GetPlayerVehicleID(playerid) == ObjectiveInfo[ObjectiveVeh])
- {
- new string[124];
- format(string,sizeof(string),"%s has stolen the %s's %s.",PlayerMissionInfo[playerid][UserName],Team[TEAM_DEFEND][Name],ObjectiveInfo[ObjectiveName]);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1, string,0);
- for(new i=0,j=GetPlayerPoolSize(); i <= j; i++) if(IsPlayerConnected(i)) DisablePlayerCheckpoint(i);
- DestroyVehicle(ObjectiveInfo[ObjectiveVeh]);
- ObjectiveStolen= true;
- ObjectiveStolenBy=playerid;
- CallRemoteFunction("EndMission","");
- PlayerPlaySound(playerid,1097,0,0,0);
- }
- }
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- if(vehicleid == ObjectiveInfo[ObjectiveVeh])
- {
- if(PlayerMissionInfo[forplayerid][TeamSelection] == TEAM_DEFEND) SetVehicleParamsForPlayer(ObjectiveInfo[ObjectiveVeh],forplayerid,1,1);
- else SetVehicleParamsForPlayer(ObjectiveInfo[ObjectiveVeh],forplayerid,1,0);
- }
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- SetVehicleHealth(vehicleid,VEHICLE_HEALTH);
- if(vehicleid == ObjectiveInfo[ObjectiveVeh]) SetVehicleHealth(ObjectiveInfo[ObjectiveVeh],VEHICLE_HEALTH + (100*Team[TEAM_DEFEND][Members]));
- return 1;
- }
- FUNCTION EndTheMission()
- {
- if(!MissionStarted) return 1;
- MissionStarted= false;
- if(!MissionCancelled)
- {
- new string[128];
- new amount= 10000;
- if(!ObjectiveStolen)
- {
- amount+=Team[TEAM_DEFEND][Kills]*100;
- format(string,sizeof(string),""SERVER_KEY_MSG" %s has won the mission, by successfully defending the %s. Reward: $%d",Team[TEAM_DEFEND][Name],ObjectiveInfo[ObjectiveName],amount);
- SendClientMessageToAll(COLOR_SERVER,string);
- CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
- format(string,sizeof(string),""SERVER_KEY_MSG" You have received $%i because your team has won the mission!",amount);
- for(new i=0,j=GetPlayerPoolSize(); i <= j; i++)
- {
- if(!PlayerMissionInfo[i][TeamChosen]) continue;
- if(PlayerMissionInfo[i][TeamSelection] == TEAM_DEFEND)
- {
- PlayerPlaySound(i,3200,0,0,0);
- SendClientMessage(i,COLOR_TEAM_DEFEND,string);
- CallRemoteFunction("GivePlayerCash","ii",i,amount);
- CallRemoteFunction("PlayerMissionStats","dd",i,0);
- }
- if(PlayerMissionInfo[i][TeamSelection] != TEAM_DEFEND)
- {
- PlayerPlaySound(i,17004,0,0,0);
- GameTextForPlayer(i,"~R~MISSION FAILED~w~!",3000,3);
- CallRemoteFunction("PlayerMissionStats","dd",i,1);
- }
- }
- }
- else
- {
- amount+=Team[TEAM_ATTACK][Kills]*100;
- format(string,sizeof(string),""SERVER_KEY_MSG" %s (%d) has stolen %s for %s to win the mission. Reward: $%d + Token",PlayerMissionInfo[ObjectiveStolenBy][UserName],ObjectiveInfo[ObjectiveName],ObjectiveStolenBy,Team[TEAM_ATTACK][Name],amount);
- SendClientMessageToAll(COLOR_SERVER,string);
- CallRemoteFunction("PlayerMissionStats","dd",ObjectiveStolenBy,7);
- CallRemoteFunction("GivePlayerToken","dd",ObjectiveStolenBy,1);
- CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
- format(string,sizeof(string),""SERVER_KEY_MSG" You have received $%i because your team has won the mission!",amount);
- for(new i=0,j=GetPlayerPoolSize(); i <= j; i++)
- {
- if(!PlayerMissionInfo[i][TeamChosen]) continue;
- if(PlayerMissionInfo[i][TeamSelection] == TEAM_ATTACK)
- {
- PlayerPlaySound(i,3200,0,0,0);
- SendClientMessage(i,COLOR_TEAM_ATTACK,string);
- CallRemoteFunction("GivePlayerCash","ii",i,amount);
- CallRemoteFunction("PlayerMissionStats","dd",i,0);
- }
- if(PlayerMissionInfo[i][TeamSelection] != TEAM_ATTACK)
- {
- PlayerPlaySound(i,17004,0,0,0);
- GameTextForPlayer(i,"~R~MISSION FAILED~w~!",3000,3);
- CallRemoteFunction("PlayerMissionStats","dd",i,1);
- }
- }
- }
- }
- 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;
Add Comment
Please, Sign In to add comment