Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Script by: Sasuke_Uchiha
- Map by: FuTuRe
- Mission Base: Race
- Mission Type: Race
- Mission Type ID: 0
- */
- //==============================================================================
- // Includes
- //==============================================================================
- #include <a_samp>
- #include <crashdetect>
- #include <fixes2>
- #include "..\filterscripts\MM\stuff\defines"
- #include "..\filterscripts\MM\stuff\serverkeymsg"
- //==============================================================================
- // Defines
- //==============================================================================
- #define MISSION_NAME "San Fierro Drift"
- #define Health 99.0
- #define VEH 603
- #define GHOST_MODE 60
- #define MAX_MAP_OBJECTS 0
- #define CLASS_POSTION -1659.2405,1209.4226,8.1406
- #define CLASS_CAMERA -1658.4868,1211.2462,7.2500
- #define CLASS_FACING_AGNLE 355.4094
- #define ENABLE_NEON true
- #define START_TIME 20
- //==============================================================================
- // Per mission functions
- //==============================================================================
- enum cp_enum
- {
- Float:cp_x,
- Float:cp_y,
- Float:cp_z,
- cp_type,
- Float:cp_size
- };
- new cp[][cp_enum] =
- {
- {-1594.62744, 1136.01160, 6.16558,0,10.0},
- {-1569.24097, 924.99640, 6.01359,0,10.0},
- {-1713.45813, 925.32776, 23.72550,0,10.0},
- {-1794.21899, 890.55292, 23.71911,0,10.0},
- {-1775.53625, 845.17340, 23.72313,0,10.0},
- {-1729.35901, 845.44354, 23.72835,0,10.0},
- {-1714.05676, 822.31274, 23.72021,0,10.0},
- {-1713.97412, 683.61053, 23.69951,0,10.0},
- {-1741.69849, 606.84094, 23.72434,0,10.0},
- {-1876.85205, 605.87311, 34.00550,0,10.0},
- {-1899.20740, 628.49323, 34.00849,0,10.0},
- {-1899.10071, 715.74921, 44.28532,0,10.0},
- {-1914.33362, 731.53619, 44.28055,0,10.0},
- {-1983.45728, 731.26416, 44.28770,0,10.0},
- {-2004.14636, 752.91669, 44.28279,0,10.0},
- {-2004.18970, 833.67834, 44.28887,0,10.0},
- {-1983.57764, 845.39661, 44.28029,0,10.0},
- {-1921.25818, 845.29333, 35.44251,0,10.0},
- {-1899.14465, 870.07568, 34.00938,0,10.0},
- {-1898.84595, 947.10016, 33.99102,0,10.0},
- {-1884.15820, 1063.48547, 44.28746,0,10.0},
- {-1884.19727, 1150.02087, 44.28067,0,10.0},
- {-1900.57849, 1176.47754, 44.28330,0,10.0},
- {-2121.31763, 1176.36938, 54.55038,0,10.0},
- {-2235.07129, 1176.36157, 54.54927,0,10.0},
- {-2402.25879, 1176.69690, 33.99487,0,10.0},
- {-2455.53955, 1200.51086, 34.05154,0,10.0},
- {-2475.20801, 1200.37903, 34.52285,0,10.0},
- {-2645.30542, 1207.61780, 54.14656,0,10.0},
- {-2675.14453, 1222.41309, 54.40678,0,10.0},
- {-2681.44067, 1943.72156, 62.92292,1,10.0}
- };
- new Float:spawns[][4] =
- {
- {-1629.8545000,1248.4291000,6.7319000,-135.1201000},
- {-1632.5818000,1245.5577000,6.7319000,-135.1201000},
- {-1635.8564000,1242.4094000,6.7319000,-135.1201000},
- {-1635.3148000,1253.9724000,6.7319000,-135.1201000},
- {-1638.1663000,1251.3351000,6.7319000,-135.1201000},
- {-1641.3727000,1247.7578000,6.7319000,-135.1201000},
- {-1646.9188000,1253.2170000,6.7319000,-135.1201000},
- {-1644.1530000,1257.0940000,6.7319000,-135.1201000},
- {-1640.9828000,1259.7958000,6.7319000,-135.1201000},
- {-1646.3693000,1265.5712000,6.7319000,-135.1201000},
- {-1649.7823000,1262.8943000,6.7319000,-135.1201000},
- {-1653.0741000,1259.5309000,6.7319000,-135.1201000},
- {-1658.2887000,1264.8042000,6.7319000,-135.1201000},
- {-1655.2653000,1268.3777000,6.7319000,-135.1201000},
- {-1652.4067000,1271.6437000,6.7319000,-135.1201000},
- {-1657.3292000,1276.5154000,6.7319000,-135.1201000},
- {-1660.3801000,1273.8848000,6.7319000,-135.1201000},
- {-1663.7664000,1270.5311000,6.7319000,-135.1201000},
- {-1668.8921000,1275.6315000,6.7319000,-135.1201000},
- {-1665.6993000,1279.4570000,6.7319000,-135.1201000},
- {-1662.9774000,1282.3628000,6.7319000,-135.1201000},
- {-1668.2203000,1287.4918000,6.7319000,-135.1201000},
- {-1671.4022000,1284.7943000,6.7319000,-135.1201000},
- {-1674.4905000,1281.4668000,6.7319000,-135.1201000},
- {-1673.1425000,1292.5172000,6.7319000,-135.1201000},
- {-1676.0686000,1289.8345000,6.7319000,-135.1201000},
- {-1679.2971000,1286.6550000,6.7319000,-135.1201000},
- {-1678.1476000,1297.7715000,6.7319000,-135.1201000},
- {-1681.3748000,1294.8358000,6.7319000,-135.1201000},
- {-1684.5839000,1291.5449000,6.7319000,-135.1201000},
- {-1683.2721000,1302.8901000,6.7319000,-135.1201000},
- {-1686.5020000,1300.0546000,6.7319000,-135.1201000},
- {-1689.6841000,1296.9402000,6.7319000,-135.1201000},
- {-1688.1501000,1307.9071000,6.7319000,-135.1201000},
- {-1691.6289000,1305.1002000,6.7319000,-135.1201000},
- {-1694.6852000,1301.9216000,6.7319000,-135.1201000},
- {-1693.0881000,1312.9165000,6.7319000,-135.1201000},
- {-1696.9089000,1310.2965000,6.7319000,-135.1201000},
- {-1699.6553000,1307.3002000,6.7319000,-135.1201000},
- {-1698.2395000,1317.9698000,6.7319000,-135.1201000},
- {-1701.5410000,1315.2009000,6.7319000,-135.1201000},
- {-1704.5157000,1312.5842000,6.7319000,-135.1201000},
- {-1644.0074000,1233.8462000,6.7319000,-135.1201000},
- {-1646.9434000,1230.6471000,6.7319000,-135.1201000},
- {-1650.0283000,1227.5557000,6.7319000,-135.1201000},
- {-1648.8837000,1238.6093000,6.7319000,-135.1201000},
- {-1651.8314000,1235.6936000,6.7319000,-135.1201000},
- {-1654.8398000,1232.6967000,6.7319000,-135.1201000},
- {-1653.6462000,1243.5763000,6.7319000,-135.1201000},
- {-1656.6750000,1240.8347000,6.7319000,-135.1201000},
- {-1659.5765000,1237.8529000,6.7319000,-135.1201000},
- {-1661.9302000,1246.2150000,6.7319000,-135.1201000},
- {-1659.0320000,1249.0007000,6.7319000,-135.1201000},
- {-1664.8054000,1243.4785000,6.7319000,-135.1201000},
- {-1663.8452000,1253.9268000,6.7319000,-135.1201000},
- {-1666.7422000,1250.9668000,6.7319000,-135.1201000},
- {-1669.7517000,1248.4132000,6.7319000,-135.1201000},
- {-1668.7600000,1258.8916000,6.7319000,-135.1201000},
- {-1671.7219000,1256.1843000,6.7319000,-135.1201000},
- {-1674.5609000,1253.6086000,6.7319000,-135.1201000},
- {-1673.5575000,1263.7034000,6.7319000,-135.1201000},
- {-1676.4435000,1260.9568000,6.7319000,-135.1201000},
- {-1679.3312000,1258.1814000,6.7319000,-135.1201000},
- {-1678.3170000,1268.5015000,6.7319000,-135.1201000},
- {-1681.4276000,1266.0593000,6.7319000,-135.1201000},
- {-1684.4370000,1263.1340000,6.7319000,-135.1201000},
- {-1683.0923000,1273.1683000,6.7319000,-135.1201000},
- {-1686.1472000,1270.7148000,6.7319000,-135.1201000},
- {-1688.9408000,1267.7156000,6.7319000,-135.1201000},
- {-1687.7461000,1278.0189000,6.7319000,-135.1201000},
- {-1690.9408000,1275.3397000,6.7319000,-135.1201000},
- {-1693.4639000,1272.3022000,6.7319000,-135.1201000},
- {-1692.4491000,1282.9762000,6.7319000,-135.1201000},
- {-1695.6150000,1280.2172000,6.7319000,-135.1201000},
- {-1698.3401000,1277.3624000,6.7319000,-135.1201000},
- {-1697.2225000,1287.8403000,6.7319000,-135.1201000},
- {-1700.6698000,1285.0026000,6.7319000,-135.1201000},
- {-1703.2460000,1282.4064000,6.7319000,-135.1201000},
- {-1701.8821000,1292.7827000,6.7319000,-135.1201000},
- {-1705.2672000,1290.1982000,6.7319000,-135.1201000},
- {-1708.0918000,1287.3660000,6.7319000,-135.1201000},
- {-1706.3148000,1297.9919000,6.7319000,-135.1201000},
- {-1710.1111000,1294.7523000,6.7319000,-135.1201000},
- {-1713.0168000,1292.3708000,6.7319000,-135.1201000},
- {-1711.2457000,1303.1583000,6.7319000,-135.1201000},
- {-1714.9867000,1299.8538000,6.7319000,-135.1201000},
- {-1717.8710000,1297.5022000,6.7319000,-135.1201000},
- {-1709.0314000,1317.3516000,6.7319000,-135.1201000},
- {-1706.4867000,1319.7876000,6.7319000,-135.1201000},
- {-1703.4510000,1322.9078000,6.7319000,-135.1201000},
- {-1716.1768000,1308.1292000,6.7319000,-135.1201000},
- {-1719.9777000,1304.6821000,6.7319000,-135.1201000},
- {-1722.6945000,1302.4148000,6.7319000,-135.1201000},
- {-1720.8745000,1313.0215000,6.7319000,-135.1201000},
- {-1724.5375000,1309.7726000,6.7319000,-135.1201000},
- {-1727.6582000,1307.2693000,6.7319000,-135.1201000},
- {-1711.3175000,1324.7393000,6.7319000,-135.1201000},
- {-1708.1512000,1327.6727000,6.7319000,-135.1201000},
- {-1713.8826000,1322.0602000,6.7319000,-135.1201000},
- {-1712.8665000,1332.5868000,6.7319000,-135.1201000}
- };
- 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_DEFEND,59,211.8, 382.3, 136.8, 0.0,0,0,0,0,0,0,0,0}
- };
- #if MAX_MAP_OBJECTS != 0
- new Object[MAX_MAP_OBJECTS];
- CreateMap()
- {
- //Objects Here
- }
- #endif
- //==============================================================================
- // Basic vars
- //==============================================================================
- new bool:ObjectiveStarted= false;
- new bool:MissionStarted;
- new GMTimer;
- new GMSec;
- new bool:MissionCancelled;
- native IsValidVehicle(vehicleid);
- #if ENABLE_NEON == true
- new NEON[200];
- #endif
- new CurrentSpawn=-1;
- new TotalPlayers;
- new CurrentRacePos;
- new MAX_CPs;
- new RaceMin,RaceSec,RaceMili;
- new BARRELS_ALLOWED= false;
- new Ghost_Mode_Time;
- new RandomColor;
- enum playersdata
- {
- UserName[MAX_PLAYER_NAME],
- rSec,
- rMin,
- rMili,
- CurrentCheckpoint,
- PlayerSpawnID,
- PlayerVehicle,
- MissionFinished,
- PlayerClassID,
- PlayerCounted,
- rBestMin,
- rBestSec,
- rBestMili
- };
- new PlayerMissionInfo[MAX_PLAYERS][playersdata];
- //==============================================================================
- // Basic script
- //==============================================================================
- main()
- {
- print("----------------------------------");
- print(" Mission: "MISSION_NAME" started.");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- MissionStarted= true;
- #if MAX_MAP_OBJECTS != 0
- CreateMap();
- #endif
- #if ENABLE_NEON == true
- for(new i=0; i<100; i++)
- {
- new neon = random(6);
- switch(neon)
- {
- case 0:
- {
- NEON[i]= CreateObject(18648,0,0,0,0,0,0);
- NEON[i+100]= CreateObject(18648,0,0,0,0,0,0);
- }
- case 1:
- {
- NEON[i]= CreateObject(18647,0,0,0,0,0,0);
- NEON[i+100]= CreateObject(18647,0,0,0,0,0,0);
- }
- case 2:
- {
- NEON[i]= CreateObject(18649,0,0,0,0,0,0);
- NEON[i+100]= CreateObject(18649,0,0,0,0,0,0);
- }
- case 3:
- {
- NEON[i]= CreateObject(18652,0,0,0,0,0,0);
- NEON[i+100]= CreateObject(18652,0,0,0,0,0,0);
- }
- case 4:
- {
- NEON[i]= CreateObject(18651,0,0,0,0,0,0);
- NEON[i+100]= CreateObject(18651,0,0,0,0,0,0);
- }
- case 5:
- {
- NEON[i]= CreateObject(18650,0,0,0,0,0,0);
- NEON[i+100]= CreateObject(18650,0,0,0,0,0,0);
- }
- }
- }
- #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);
- }
- GMTimer = SetTimer("GMClock",1000,true);
- MAX_CPs = sizeof(cp);
- if(random(4) == 1) Ghost_Mode_Time= GHOST_MODE;
- else Ghost_Mode_Time= -1;
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- PlayerMissionInfo[i][PlayerSpawnID]=-1;
- PlayerMissionInfo[i][PlayerVehicle]=-1;
- }
- RandomColor=random(2);
- if(random(4) == 2)
- {
- CallRemoteFunction("SetUpBarrelSystem", "");
- BARRELS_ALLOWED = true;
- }
- CallRemoteFunction("UpdateRaceRecordsFunc","dd",INVALID_PLAYER_ID,0);
- if(CallRemoteFunction("GetCurrentMissionCJWalk","")) UsePlayerPedAnims();
- EnableVehicleFriendlyFire();
- return 1;
- }
- public OnGameModeExit()
- {
- #if MAX_MAP_OBJECTS != 0
- for(new i=0;i<MAX_MAP_OBJECTS;i++) DestroyObject(Object[i]);
- #endif
- KillTimer(GMTimer);
- for(new i=0; i<MAX_VEHICLES; i++)
- {
- if(IsValidVehicle(i))
- {
- DestroyVehicle(i);
- }
- }
- #if ENABLE_NEON == true
- for(new i=0;i<200;i++) DestroyObject(NEON[i]);
- #endif
- return 1;
- }
- FUNCTION GMClock()
- {
- GMSec++;
- switch(ObjectiveStarted)
- {
- case false:
- {
- switch(GMSec)
- {
- case 1:
- {
- new string[40];
- format(string,sizeof(string),"The race will start in %d seconds.",START_TIME);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1, string,0);
- }
- case START_TIME-2:
- {
- GameTextForAll("~r~~h~~h~ON YOUR MARKS!",1000,3);
- PlaySoundForAll(1056);
- }
- case START_TIME-1:
- {
- GameTextForAll("~y~GET SET!",1000,3);
- PlaySoundForAll(1056);
- }
- case START_TIME:
- {
- PlaySoundForAll(1057);
- CallRemoteFunction("StartMission","");
- GameTextForAll("~g~~h~~h~GO!",1000,3);
- ObjectiveStarted= true;
- ToggleControllable(true);
- SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" KA BOOM! The race has started. Good luck.");
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"KA BOOM! The race has started. Good luck.",0);
- RaceMili=GetTickCount();
- }
- }
- if(Ghost_Mode_Time > 0 || Ghost_Mode_Time == -1)
- {
- for(new i=0; i<MAX_PLAYERS; i++) DisableRemoteVehicleCollisions(i,1);
- }
- }
- case true:
- {
- if(Ghost_Mode_Time > 0)
- {
- Ghost_Mode_Time--;
- if(Ghost_Mode_Time == 0)
- {
- for(new i=0; i<MAX_PLAYERS; i++) DisableRemoteVehicleCollisions(i,0);
- SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" Ghost mode has been disabled by the server.");
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"Ghost mode has been disabled by the server.",0);
- CallRemoteFunction("IRC_SendMessage","ss",""SERVER_KEY_MSG" Ghost mode has been disabled by the server.",IRC_SERVER_COLOR);
- }
- }
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(IsPlayerConnected(i) && CallRemoteFunction("GetAliveState","i",i) && !PlayerMissionInfo[i][MissionFinished])
- {
- GetPlayerPosition(i);
- }
- }
- RaceSec++;
- if(RaceSec == 60)
- {
- RaceSec=0;
- RaceMin++;
- }
- }
- }
- }
- public OnPlayerDisconnect(playerid,reason)
- {
- if(IsValidVehicle(PlayerMissionInfo[playerid][PlayerVehicle])) DestroyVehicle(PlayerMissionInfo[playerid][PlayerVehicle]);
- PlayerMissionInfo[playerid][PlayerVehicle]=-1;
- if(!PlayerMissionInfo[playerid][MissionFinished])
- {
- if(PlayerMissionInfo[playerid][PlayerCounted])
- {
- TotalPlayers--;
- PlayerMissionInfo[playerid][PlayerCounted]= false;
- }
- }
- else PlayerMissionInfo[playerid][MissionFinished] = false;
- RemovePlayerMapIcon(playerid,MAP_ICON_NEXT_CP);
- DisablePlayerRaceCheckpoint(playerid);
- CallRemoteFunction("PlayerRaceRecords","dd",playerid,1);
- 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","ddsddd",playerid,2,"Drift King", PedInfo[classid][Weapon1], PedInfo[classid][Weapon2], PedInfo[classid][Weapon3]);
- SetPlayerColor(playerid,COLOR_SERVER);
- PlayerMissionInfo[playerid][PlayerClassID]=classid;
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- CallRemoteFunction("UpdateRaceRecordsFunc","dd",INVALID_PLAYER_ID,0);
- if(PlayerMissionInfo[playerid][PlayerSpawnID] == -1)
- {
- CurrentSpawn++;
- PlayerMissionInfo[playerid][PlayerSpawnID]=CurrentSpawn;
- PlayerMissionInfo[playerid][CurrentCheckpoint]=0;
- }
- if(!IsPlayerJailed(playerid))
- {
- new Float:x,Float:y,Float:z,Float:a;
- x=spawns[PlayerMissionInfo[playerid][PlayerSpawnID]][0];
- y=spawns[PlayerMissionInfo[playerid][PlayerSpawnID]][1];
- z=spawns[PlayerMissionInfo[playerid][PlayerSpawnID]][2];
- a=spawns[PlayerMissionInfo[playerid][PlayerSpawnID]][3];
- if(IsValidVehicle(PlayerMissionInfo[playerid][PlayerVehicle])) DestroyVehicle(PlayerMissionInfo[playerid][PlayerVehicle]);
- PlayerMissionInfo[playerid][PlayerVehicle] = CreateVehicle(VEH,x,y,z,a,random(255),random(255),-1);
- #if ENABLE_NEON == true
- AddNeon(PlayerMissionInfo[playerid][PlayerVehicle]);
- #endif
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- new string[124];
- CallRemoteFunction("UpdateAliveState","ii",playerid,1);
- SetPlayerHealth(playerid,Health);
- if(PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Skin] == 0)
- {
- back:
- new skin=random(312);
- if(skin == 74 || skin < 1) goto back;
- SetPlayerSkin(playerid,skin);
- }
- if(CallRemoteFunction("GetSpectateStatus","d",playerid)) return CallRemoteFunction("SpecOffAdmin","d",playerid);
- SetPlayerColor(playerid,(RandomColor == TEAM_ATTACK) ? COLOR_TEAM_ATTACK : COLOR_TEAM_DEFEND);
- SetPlayerTeam(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][TeamID]);
- switch(ObjectiveStarted)
- {
- case false:
- {
- TogglePlayerControllable(playerid,false);
- format(string,sizeof(string),"The race will start in %d seconds. Get ready.",(GMSec-START_TIME)*-1);
- CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,string,100);
- }
- case true:
- {
- TogglePlayerControllable(playerid,true);
- CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,"HURRY UP! The race has already started.",2000);
- }
- }
- if(Ghost_Mode_Time > 0)
- {
- DisableRemoteVehicleCollisions(playerid,1);
- format(string,sizeof(string),""SERVER_KEY_MSG" The ghost mode will last for %d seconds.",Ghost_Mode_Time);
- SendClientMessage(playerid,COLOR_SERVER,string);
- }
- if(Ghost_Mode_Time == -1) DisableRemoteVehicleCollisions(playerid,1);
- CallRemoteFunction("ShowInfoText", "iisi", playerid, -1,"Try to finish first!",2000);
- if(CallRemoteFunction("GetJailedStatus","d",playerid))
- {
- CallRemoteFunction("SetJailed","d",playerid);
- }
- else
- {
- if(BARRELS_ALLOWED)
- {
- SendClientMessage(playerid, COLOR_SERVER, ""SERVER_KEY_MSG" The system has chosen that barrels are enabled in this mission.");
- format(string,sizeof(string),""SERVER_KEY_MSG" You can throw a barrel by pressing 'submission key (2)' on your keyboard. (Costs: $%d / barrel)",BARREL_PRICE);
- SendClientMessage(playerid, COLOR_SERVER, string);
- }
- else
- {
- SendClientMessage(playerid, COLOR_SERVER, ""SERVER_KEY_MSG" The system has chosen that barrels are disabled in this mission.");
- }
- SetVehicleToRespawn(PlayerMissionInfo[playerid][PlayerVehicle]);
- PutPlayerInVehicle(playerid,PlayerMissionInfo[playerid][PlayerVehicle],0);
- LinkVehicleToInterior(PlayerMissionInfo[playerid][PlayerVehicle],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnInterior]);
- 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][MissionFinished])
- {
- PlayerMissionInfo[playerid][CurrentCheckpoint]= 0;
- PlayerMissionInfo[playerid][rMili]=0,PlayerMissionInfo[playerid][rMin]=0,PlayerMissionInfo[playerid][rSec]=0;
- SetVehicleVirtualWorld(PlayerMissionInfo[playerid][PlayerVehicle], 0);
- SetPlayerVirtualWorld(playerid,0);
- SetPlayerRaceCheckpoint(playerid,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_type],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_z],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_z],10.0);
- SetPlayerMapIcon(playerid, MAP_ICON_NEXT_CP,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_z], 0, 0xFF000033, MAPICON_LOCAL);
- }
- else
- {
- SetVehicleVirtualWorld(PlayerMissionInfo[playerid][PlayerVehicle], 2);
- SetPlayerVirtualWorld(playerid,2);
- CallRemoteFunction("OnPlayerMissionComplete","d",playerid);
- }
- if(!PlayerMissionInfo[playerid][PlayerCounted])
- {
- TotalPlayers++;
- PlayerMissionInfo[playerid][PlayerCounted]= true;
- }
- }
- CallRemoteFunction("GetPlayerPersonalBest","d",playerid);
- CallRemoteFunction("UpdateMissionHud","iiiiiiiiiiii",playerid,2,GetPlayerPosition(playerid),TotalPlayers,RaceMin,PlayerMissionInfo[playerid][rSec],PlayerMissionInfo[playerid][CurrentCheckpoint],MAX_CPs,PlayerMissionInfo[playerid][rBestMin],PlayerMissionInfo[playerid][rBestSec],PlayerMissionInfo[playerid][rBestMili],Ghost_Mode_Time);
- CallRemoteFunction("PlayerRaceRecords","dd",playerid,2);
- return 1;
- }
- public OnPlayerDeath(playerid,killerid,reason)
- {
- CallRemoteFunction("UpdateAliveState","ii",playerid,0);
- if(!PlayerMissionInfo[playerid][MissionFinished]) PlayerMissionInfo[playerid][CurrentCheckpoint]=0;
- CallRemoteFunction("PlayerRaceRecords","dd",playerid,1);
- CallRemoteFunction("UpdateLastCheckpoint","dfff",playerid,-1.0,-1.0,-1.0);
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- if(!MissionStarted || !ObjectiveStarted) return 0;
- new string[124],type;
- PlayerPlaySound(playerid,1139,0,0,0);
- CallRemoteFunction("UpdateLastCheckpoint","dfff",playerid,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_z]);
- if(PlayerMissionInfo[playerid][CurrentCheckpoint] != MAX_CPs-1)
- {
- type=cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_type];
- }
- if(PlayerMissionInfo[playerid][CurrentCheckpoint] == MAX_CPs-2)
- {
- SetPlayerRaceCheckpoint(playerid,type,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_z],0.0,0.0,0.0,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_size]);
- RemovePlayerMapIcon(playerid,MAP_ICON_NEXT_CP);
- }
- else if(PlayerMissionInfo[playerid][CurrentCheckpoint] == MAX_CPs-1)
- {
- PlaySoundForAll(1058);
- PlayerMissionInfo[playerid][MissionFinished]= true;
- DisablePlayerRaceCheckpoint(playerid);
- RemovePlayerMapIcon(playerid,MAP_ICON_NEXT_CP);
- new Pos=GetPlayerPosition(playerid);
- CurrentRacePos++;
- PlayerMissionInfo[playerid][rMin]=RaceMin;
- PlayerMissionInfo[playerid][rSec]=RaceSec;
- new Prize=floatround(10000/Pos, floatround_round)+(1000*TotalPlayers);
- PlayerMissionInfo[playerid][rMili]=(((GetTickCount()-RaceMili)-(1000*PlayerMissionInfo[playerid][rSec]))-((1000*60)*PlayerMissionInfo[playerid][rMin]));
- while(PlayerMissionInfo[playerid][rMili] >= 1000)
- {
- PlayerMissionInfo[playerid][rMili]-=1000;
- PlayerMissionInfo[playerid][rSec]++;
- if(PlayerMissionInfo[playerid][rSec] == 60)
- {
- PlayerMissionInfo[playerid][rSec]=0;
- PlayerMissionInfo[playerid][rMin]++;
- }
- }
- CallRemoteFunction("GetPlayerPersonalBest","d",playerid);
- CallRemoteFunction("UpdateMissionHud","iiiiiiiiiiii",playerid,2,Pos,TotalPlayers,PlayerMissionInfo[playerid][rMin],PlayerMissionInfo[playerid][rSec],PlayerMissionInfo[playerid][CurrentCheckpoint]+1,MAX_CPs,PlayerMissionInfo[playerid][rBestMin],PlayerMissionInfo[playerid][rBestSec],PlayerMissionInfo[playerid][rBestMili],Ghost_Mode_Time);
- CallRemoteFunction("GivePlayerCash","ii",playerid,Prize);
- if(Pos == 1)
- {
- CallRemoteFunction("PlayerMissionStats","dd",playerid,3);
- format(string,sizeof(string),""SERVER_KEY_MSG" %s (%d) has finished 1st in the race. Time Taken: %02d:%02d:%03d [Prize: $%d + Token].",PlayerMissionInfo[playerid][UserName],playerid,PlayerMissionInfo[playerid][rMin],PlayerMissionInfo[playerid][rSec],PlayerMissionInfo[playerid][rMili],Prize);
- CallRemoteFunction("GivePlayerToken","dd",playerid,1);
- CallRemoteFunction("CheckForBetWinners","d",playerid);
- }
- else format(string,sizeof(string),""SERVER_KEY_MSG" %s (%d) has finished %d%s in the race. Time Taken: %02d:%02d:%03d | Prize: $%d.",PlayerMissionInfo[playerid][UserName],playerid,Pos,GetEndStyle(Pos),PlayerMissionInfo[playerid][rMin],PlayerMissionInfo[playerid][rSec],PlayerMissionInfo[playerid][rMili],Prize);
- if(Pos == 2) CallRemoteFunction("PlayerMissionStats","dd",playerid,4);
- if(Pos == 3) CallRemoteFunction("PlayerMissionStats","dd",playerid,5);
- CallRemoteFunction("PlayerMissionStats","dd",playerid,0);
- CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
- new time = ((PlayerMissionInfo[playerid][rMin]*60000)+(PlayerMissionInfo[playerid][rSec]*1000)+(PlayerMissionInfo[playerid][rMili]));
- CallRemoteFunction("CheckRaceRecord","dd",playerid,time);
- SetVehicleVirtualWorld(PlayerMissionInfo[playerid][PlayerVehicle], 2);
- SetPlayerVirtualWorld(playerid,2);
- SendClientMessageToAll(COLOR_SERVER,string);
- CallRemoteFunction("OnPlayerMissionComplete","d",playerid);
- CallRemoteFunction("UpdateLastCheckpoint","dfff",playerid,-2.0,-2.0,-2.0);
- CallRemoteFunction("PlayerMissionStats","dd",playerid,9);
- }
- else if(PlayerMissionInfo[playerid][CurrentCheckpoint] < MAX_CPs-1)
- {
- SetPlayerRaceCheckpoint(playerid,type,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_z],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_z],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+1][cp_size]);
- SetPlayerMapIcon(playerid, MAP_ICON_NEXT_CP,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]+2][cp_z], 0, 0xFF000033, MAPICON_LOCAL);
- }
- PlayerMissionInfo[playerid][CurrentCheckpoint]++;
- return 1;
- }
- #if ENABLE_NEON == true
- public OnVehicleSpawn(vehicleid)
- {
- for(new i=0; i<100; i++)
- {
- if(!IsValidVehicle(i)) continue;
- AttachObjectToVehicle(NEON[i-1],i, -0.90, -0.15, -0.58, 0.0, 0.0, 0.0);
- AttachObjectToVehicle(NEON[i-1]+100,i, 0.90, -0.15, -0.58, 0.0, 0.0, 0.0);
- }
- return 1;
- }
- #endif
- FUNCTION EndTheMission()
- {
- if(!MissionStarted) return 1;
- MissionStarted= false;
- KillTimer(GMTimer);
- if(!MissionCancelled && ObjectiveStarted)
- {
- SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" The race has ended.");
- CallRemoteFunction("IRC_SendMessage","ss",""SERVER_KEY_MSG" The race has ended.",IRC_SERVER_COLOR);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"The race has ended.",0);
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(IsPlayerConnected(i) && !PlayerMissionInfo[i][MissionFinished])
- {
- PlayerPlaySound(i,17004,0,0,0);
- GameTextForPlayer(i,"~R~MISSION FAILED~w~!",3000,3);
- DisablePlayerCheckpoint(i);
- 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);
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(IsPlayerConnected(i))
- {
- GameTextForPlayer(i,"~R~MISSION CANCELLED~w~!",3000,3);
- DisablePlayerCheckpoint(i);
- RemovePlayerMapIcon(i,MAP_ICON_NEXT_CP);
- }
- }
- }
- return 1;
- }
- //==============================================================================
- // Mission functions
- //==============================================================================
- GetPlayerPosition(playerid)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- if(PlayerMissionInfo[playerid][MissionFinished]) return GetPlayerScore(playerid);
- new PlayerPositon=CurrentRacePos+1;
- new Float:PlayerDistance=GetPlayerDistanceFromPoint(playerid,cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_x],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_y],cp[PlayerMissionInfo[playerid][CurrentCheckpoint]][cp_z]);
- new Float:OtherPlayerDistance;
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(!CallRemoteFunction("GetAliveState","i",i) || !ObjectiveStarted || PlayerMissionInfo[i][MissionFinished]) continue;
- if(PlayerMissionInfo[playerid][CurrentCheckpoint] < PlayerMissionInfo[i][CurrentCheckpoint])
- {
- PlayerPositon++;
- continue;
- }
- else if(PlayerMissionInfo[playerid][CurrentCheckpoint] == PlayerMissionInfo[i][CurrentCheckpoint])
- {
- OtherPlayerDistance=GetPlayerDistanceFromPoint(i,cp[PlayerMissionInfo[i][CurrentCheckpoint]][cp_x],cp[PlayerMissionInfo[i][CurrentCheckpoint]][cp_y],cp[PlayerMissionInfo[i][CurrentCheckpoint]][cp_z]);
- if(PlayerDistance > OtherPlayerDistance)
- {
- PlayerPositon++;
- continue;
- }
- }
- }
- SetPlayerScore(playerid,PlayerPositon);
- CallRemoteFunction("UpdateMissionHud","iiiiiiiiiiii",playerid,2,PlayerPositon,TotalPlayers,RaceMin,RaceSec,PlayerMissionInfo[playerid][CurrentCheckpoint],MAX_CPs,PlayerMissionInfo[playerid][rBestMin],PlayerMissionInfo[playerid][rBestSec],PlayerMissionInfo[playerid][rBestMili],Ghost_Mode_Time);
- return PlayerPositon;
- }
- #if ENABLE_NEON == true
- AddNeon(vehicleid)
- {
- AttachObjectToVehicle(NEON[vehicleid],vehicleid, -0.90, -0.15, -0.58, 0.0, 0.0, 0.0);
- AttachObjectToVehicle(NEON[vehicleid]+100,vehicleid, 0.90, -0.15, -0.58, 0.0, 0.0, 0.0);
- }
- #endif
- GetEndStyle(pos)
- {
- new end[3];
- if(pos == 11 || pos == 12 || pos == 13) { end = "TH"; }
- else if(pos - (pos / 10) * 10 == 1) { end = "ST"; }
- else if(pos - (pos / 10) * 10 == 2) { end = "ND"; }
- else if(pos - (pos / 10) * 10 == 3) { end = "RD"; }
- else { end = "TH"; }
- return end;
- }
- PlaySoundForAll(sound)
- {
- for (new i=0,j=GetPlayerPoolSize(); i <=j ; i++)
- {
- if(IsPlayerConnected(i)) PlayerPlaySound(i,sound,0,0,0);
- }
- }
- ToggleControllable(control)
- {
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(CallRemoteFunction("GetAliveState","i",i)) TogglePlayerControllable(i,control);
- }
- }
- return 1;
- }
- //==============================================================================
- // Important functions required
- //==============================================================================
- FUNCTION OnPlayerGetPersonalBest(playerid,Min,Sec,Mili)
- {
- PlayerMissionInfo[playerid][rBestMin]=Min;
- PlayerMissionInfo[playerid][rBestSec]=Sec;
- PlayerMissionInfo[playerid][rBestMili]=Mili;
- CallRemoteFunction("UpdateMissionHud","iiiiiiiiiiii",playerid,2,GetPlayerPosition(playerid),TotalPlayers,PlayerMissionInfo[playerid][rMin],PlayerMissionInfo[playerid][rSec],PlayerMissionInfo[playerid][CurrentCheckpoint]+1,MAX_CPs,PlayerMissionInfo[playerid][rBestMin],PlayerMissionInfo[playerid][rBestSec],PlayerMissionInfo[playerid][rBestMili],Ghost_Mode_Time);
- return 1;
- }
- FUNCTION CancelTheMission()
- {
- MissionCancelled= true;
- return 1;
- }
- FUNCTION GetPlayerRaceVehicleID(playerid) return PlayerMissionInfo[playerid][PlayerVehicle];
- FUNCTION OnPlayerNameRecieve(playerid,name[])
- {
- format(PlayerMissionInfo[playerid][UserName],MAX_PLAYER_NAME,"%s",name);
- return 1;
- }
- FUNCTION MissionObjectiveStarted() return ObjectiveStarted;
Add Comment
Please, Sign In to add comment