Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Script by: Bullet
- Map by: Ryses
- Mission Base: Last man standing
- Mission Type: Last man standing
- Mission Type ID: 4
- */
- //==============================================================================
- // Includes
- //==============================================================================
- #include <a_samp>
- #include <crashdetect>
- #include <float>
- #include <fixes2>
- #include "..\filterscripts\MM\stuff\defines"
- #include "..\filterscripts\MM\stuff\serverkeymsg"
- //==============================================================================
- // Defines
- //==============================================================================
- #define MISSION_NAME "The Solarin"
- #define Health 99.0
- #define VEHICLE_HEALTH 999.0
- #define CLASS_POSTION -712.2740,3682.5254,5.6844
- #define CLASS_CAMERA -712.2980,3678.3479,5.6844
- #define CLASS_FACING_AGNLE 183.5021
- #define MAX_MAP_OBJECTS 42
- #define START_TIME 20
- //==============================================================================
- // 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] = {
- {NO_TEAM, 0, -784.0209, 494.7463, 1376.1953, 88.6274,0,0, WEAPON_DEAGLE, 350, WEAPON_AK47, 500, 0, 0}
- };
- new Float:gSpawns[][] =
- {
- {-615.5201,3625.7786,5.6844},
- {-642.9300,3592.6814,5.6844},
- {-614.9897,3660.3071,5.6844},
- {-634.6559,3683.7617,5.6844},
- {-653.7584,3644.3799,5.6844},
- {-682.9399,3640.8691,5.6844},
- {-690.6001,3686.1350,5.6805},
- {-706.9310,3672.8542,5.6844},
- {-725.8123,3642.7778,5.6844},
- {-708.2620,3627.9392,5.6844},
- {-719.3558,3597.2273,5.6844},
- {-693.2117,3600.9492,5.6805}
- };
- #if MAX_MAP_OBJECTS != 0
- new Object[MAX_MAP_OBJECTS];
- CreateMap()
- {
- Object[0] = CreateObject(11093,-706.7000100,3599.0000000,7.4000000,0.0000000,0.0000000,270.0000000); //
- Object[1] = CreateObject(11093,-733.5000000,3608.1999500,7.4000000,0.0000000,0.0000000,267.9950000); //
- Object[2] = CreateObject(11093,-733.5000000,3608.1999500,13.2000000,0.0000000,0.0000000,267.9950000); //
- Object[3] = CreateObject(11093,-706.7000100,3599.0000000,12.9000000,0.0000000,0.0000000,269.9950000); //
- Object[4] = CreateObject(10775,-753.7999900,3638.5000000,25.6000000,0.0000000,0.0000000,0.0000000); //
- Object[5] = CreateObject(10826,-673.7999900,3642.5000000,-11.3000000,0.0000000,0.0000000,0.0000000); //
- Object[6] = CreateObject(10775,-757.7999900,3661.3999000,25.6000000,0.0000000,0.0000000,180.0000000); //
- Object[7] = CreateObject(10776,-675.2000100,3599.3000500,14.8000000,0.0000000,0.0000000,92.0000000); //
- Object[8] = CreateObject(10847,-695.0000000,3675.0000000,11.1000000,0.0000000,0.0000000,0.0000000); //
- Object[9] = CreateObject(10847,-728.7000100,3682.6999500,11.1000000,0.0000000,0.0000000,0.0000000); //
- Object[10] = CreateObject(10847,-738.0000000,3682.8999000,20.6000000,0.0000000,0.0000000,0.0000000); //
- Object[11] = CreateObject(10847,-731.5000000,3663.6999500,11.1000000,0.0000000,0.0000000,268.0000000); //
- Object[12] = CreateObject(10847,-740.4000200,3664.0000000,18.9000000,0.0000000,0.0000000,267.9950000); //
- Object[13] = CreateObject(10871,-790.9000200,3650.0000000,123.2000000,0.0000000,0.0000000,30.0000000); //
- Object[14] = CreateObject(10847,-694.7000100,3627.0000000,11.1000000,0.0000000,0.0000000,0.0000000); //
- Object[15] = CreateObject(10775,-593.7000100,3648.5000000,24.9000000,0.0000000,0.0000000,180.0000000); //
- Object[16] = CreateObject(10847,-615.0999800,3672.5000000,8.1000000,0.0000000,0.0000000,0.0000000); //
- Object[17] = CreateObject(10847,-614.9000200,3691.1001000,8.1000000,0.0000000,0.0000000,0.0000000); //
- Object[18] = CreateObject(10847,-606.7999900,3676.0000000,20.4000000,0.0000000,0.0000000,0.0000000); //
- Object[19] = CreateObject(10847,-598.7999900,3602.8000500,14.6000000,0.0000000,0.0000000,358.0000000); //
- Object[20] = CreateObject(10847,-609.5000000,3614.5000000,4.4000000,0.0000000,0.0000000,1.9950000); //
- Object[21] = CreateObject(10847,-608.9000200,3594.6999500,4.9000000,0.0000000,0.0000000,357.9950000); //
- Object[22] = CreateObject(10871,-576.4000200,3646.6001000,123.2000000,0.0000000,0.0000000,331.9980000); //
- Object[23] = CreateObject(10775,-591.4000200,3625.6001000,24.9000000,0.0000000,0.0000000,1.9950000); //
- Object[24] = CreateObject(10847,-694.7000100,3662.6999500,11.1000000,0.0000000,0.0000000,0.0000000); //
- Object[25] = CreateObject(10844,-667.4000200,3680.8999000,7.7000000,0.0000000,0.0000000,0.0000000); //
- Object[26] = CreateObject(10844,-667.2999900,3662.0000000,7.7000000,0.0000000,0.0000000,0.0000000); //
- Object[27] = CreateObject(10847,-670.5999800,3635.3000500,11.1000000,0.0000000,0.0000000,0.0000000); //
- Object[28] = CreateObject(10775,-709.4000200,3713.1001000,25.1000000,0.0000000,0.0000000,269.9950000); //
- Object[29] = CreateObject(10775,-638.5999800,3714.1999500,26.6000000,0.0000000,0.0000000,269.9890000); //
- Object[30] = CreateObject(10775,-631.9000200,3568.5000000,24.9000000,0.0000000,0.0000000,89.9940000); //
- Object[31] = CreateObject(10775,-703.2000100,3566.3999000,24.9000000,0.0000000,0.0000000,89.9890000); //
- Object[32] = CreateObject(10871,-670.4000200,3737.3999000,123.2000000,0.0000000,0.0000000,57.9960000); //
- Object[33] = CreateObject(10871,-684.7000100,3542.3999000,123.2000000,0.0000000,0.0000000,359.9910000); //
- Object[34] = CreateObject(10847,-654.7000100,3596.0000000,11.1000000,0.0000000,0.0000000,0.0000000); //
- Object[35] = CreateObject(10847,-640.5000000,3620.6999500,11.1000000,0.0000000,0.0000000,0.0000000); //
- Object[36] = CreateObject(10847,-639.7999900,3644.6001000,11.1000000,0.0000000,0.0000000,0.0000000); //
- Object[37] = CreateObject(10847,-639.7000100,3673.3000500,11.1000000,0.0000000,0.0000000,0.0000000); //
- Object[38] = CreateObject(10847,-611.0000000,3636.5000000,4.6000000,0.0000000,0.0000000,2.0000000); //
- Object[39] = CreateObject(10847,-606.2000100,3594.8000500,14.4000000,0.0000000,0.0000000,357.9950000); //
- Object[40] = CreateObject(10847,-606.0000000,3613.8000500,14.4000000,0.0000000,0.0000000,357.9950000); //
- Object[41] = CreateObject(10847,-713.2000100,3638.6001000,11.1000000,0.0000000,0.0000000,0.0000000); //
- }
- #endif
- //==============================================================================
- // Basic vars
- //==============================================================================
- new bool:MissionStarted;
- new bool:ObjectiveStarted;
- new bool:MissionCancelled;
- native IsValidVehicle(vehicleid);
- enum playersdata {
- UserName[MAX_PLAYER_NAME],
- Kills,
- bool:Counted,
- PlayerClassID,
- bool:AllowedToSpawn
- };
- new PlayerMissionInfo[MAX_PLAYERS][playersdata];
- new PlayersAlive;
- new GMTimer;
- new GMSec;
- new RandomColor;
- new MaxSpawns;
- //==============================================================================
- // Basic script
- //==============================================================================
- main()
- {
- print("----------------------------------");
- print(" Mission: "MISSION_NAME" started.");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- MissionStarted= true;
- MaxSpawns=sizeof(gSpawns);
- GMTimer = SetTimer("GMClock",1000,true);
- RandomColor=random(2);
- #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);
- if(CallRemoteFunction("GetCurrentMissionCJWalk","")) UsePlayerPedAnims();
- 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;
- }
- FUNCTION GMClock()
- {
- GMSec++;
- switch(ObjectiveStarted)
- {
- case false:
- {
- switch(GMSec)
- {
- case 1:
- {
- new string[100];
- format(string,sizeof(string),"The last man standing deathmatch will start in %d seconds.",START_TIME);
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1, string,0);
- }
- case START_TIME-3:
- {
- PlaySoundForAll(1056);
- GameTextForAll("~r~~h~3",1000,3);
- }
- case START_TIME-2:
- {
- PlaySoundForAll(1056);
- GameTextForAll("~r~~h~~h~2",1000,3);
- }
- case START_TIME-1:
- {
- PlaySoundForAll(1056);
- GameTextForAll("~y~1",1000,3);
- }
- case START_TIME:
- {
- PlaySoundForAll(1057);
- if(PlayersAlive > 1)
- {
- CallRemoteFunction("StartMission","");
- GameTextForAll("~r~Fight!",1000,3);
- ObjectiveStarted= true;
- ToggleControllable(true);
- SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" The last man standing deathmatch has started. KILL OR BE KILLED!");
- CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"The last man standing deathmatch has started. KILL OR BE KILLED!",0);
- }
- else CallRemoteFunction("EndMission","");
- KillTimer(GMTimer);
- }
- }
- }
- }
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(PlayerMissionInfo[playerid][Counted])
- {
- PlayersAlive --;
- CallRemoteFunction("LmsUpdate","d",PlayersAlive);
- PlayerMissionInfo[playerid][Counted]= false;
- if(PlayersAlive < 2) CallRemoteFunction("EndMission","");
- }
- return 1;
- }
- public OnPlayerRequestClass(playerid,classid)
- {
- SetPlayerPos(playerid,CLASS_POSTION);
- SetPlayerCameraPos(playerid,CLASS_CAMERA);
- SetPlayerCameraLookAt(playerid,CLASS_POSTION);
- SetPlayerFacingAngle(playerid,CLASS_FACING_AGNLE);
- CallRemoteFunction("LmsHide","i",playerid);
- CallRemoteFunction("ShowClassSelection","iisiii",playerid, 2,"Deathmatcher", PedInfo[classid][Weapon1], PedInfo[classid][Weapon2], PedInfo[classid][Weapon3]);
- PlayerMissionInfo[playerid][PlayerClassID]=classid;
- if(PlayerMissionInfo[playerid][Counted])
- {
- PlayersAlive --;
- CallRemoteFunction("LmsUpdate","d",PlayersAlive);
- PlayerMissionInfo[playerid][Counted]= false;
- if(PlayersAlive < 2) CallRemoteFunction("EndMission","");
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- new string[124];
- CallRemoteFunction("LmsShow","i",playerid);
- CallRemoteFunction("LmsUpdate","d",PlayersAlive);
- 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);
- new rand=random(MaxSpawns);
- if(!CallRemoteFunction("GetJailedStatus","d",playerid))
- {
- SetPlayerPos(playerid,gSpawns[rand][0],gSpawns[rand][1],gSpawns[rand][2]);
- //SetPlayerFacingAngle(playerid,gSpawns[rand][3]);
- SetPlayerTeam(playerid,NO_TEAM);
- SetPlayerColor(playerid,COLOR_GREY);
- 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(ObjectiveStarted && !PlayerMissionInfo[playerid][AllowedToSpawn])
- {
- if(PlayerMissionInfo[playerid][Counted])
- {
- PlayersAlive --;
- CallRemoteFunction("LmsUpdate","d",PlayersAlive);
- PlayerMissionInfo[playerid][Counted]= false;
- if(PlayersAlive < 2) CallRemoteFunction("EndMission","");
- }
- CallRemoteFunction("OnPlayerMissionComplete","d",playerid);
- SetPlayerVirtualWorld(playerid,2);
- }
- else
- {
- PlayerMissionInfo[playerid][AllowedToSpawn]= false;
- SetPlayerPos(playerid,gSpawns[rand][0],gSpawns[rand][1],gSpawns[rand][2]);
- //SetPlayerFacingAngle(playerid,gSpawns[rand][3]);
- SetPlayerTeam(playerid,NO_TEAM);
- SetPlayerColor(playerid,(RandomColor == TEAM_ATTACK) ? COLOR_TEAM_ATTACK : COLOR_TEAM_DEFEND);
- SetPlayerVirtualWorld(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][VirtualWorld]);
- CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,"Your mission is to kill other players and survive till the last.",2000);
- CallRemoteFunction("ShowInfoText", "iisi", playerid, -1,"~r~~h~Eliminate ~w~others!",2000);
- if(!ObjectiveStarted)
- {
- format(string,sizeof(string),""SERVER_KEY_MSG" The last man standing deathmatch will start in %d seconds.",(GMSec-START_TIME)*-1);
- SendClientMessage(playerid,COLOR_SERVER,string);
- CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,string,0);
- TogglePlayerControllable(playerid,false);
- }
- if(!PlayerMissionInfo[playerid][Counted])
- {
- PlayersAlive++;
- PlayerMissionInfo[playerid][Counted]= true;
- CallRemoteFunction("LmsUpdate","d",PlayersAlive);
- }
- CallRemoteFunction("UpdateAliveState","ii",playerid,1);
- }
- }
- else CallRemoteFunction("SetJailed","d",playerid);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(!MissionStarted)
- {
- PlayerMissionInfo[playerid][AllowedToSpawn]= true;
- return 1;
- }
- if(killerid != INVALID_PLAYER_ID)
- {
- PlayerMissionInfo[killerid][Kills]++;
- SetPlayerScore(killerid,PlayerMissionInfo[killerid][Kills]);
- }
- if(ObjectiveStarted && PlayerMissionInfo[playerid][Counted])
- {
- GameTextForPlayer(playerid,"~R~MISSION FAILED~w~!",3000,3);
- CallRemoteFunction("PlayerMissionStats","dd",playerid,1);
- }
- if(PlayerMissionInfo[playerid][Counted])
- {
- PlayersAlive--;
- PlayerMissionInfo[playerid][Counted]= false;
- }
- CallRemoteFunction("LmsUpdate","d",PlayersAlive);
- CallRemoteFunction("UpdateAliveState","ii",playerid,0);
- if(PlayersAlive < 2) CallRemoteFunction("EndMission","");
- return 1;
- }
- FUNCTION EndTheMission()
- {
- if(!MissionStarted) return 1;
- MissionStarted= false;
- KillTimer(GMTimer);
- if(!MissionCancelled && ObjectiveStarted)
- {
- new string[124];
- new winner = INVALID_PLAYER_ID;
- new bool:MoreThan1;
- if(PlayersAlive == 1)
- {
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(CallRemoteFunction("GetAliveState","i",i) && IsPlayerConnected(i) && PlayerMissionInfo[i][Counted])
- {
- winner=i;
- }
- }
- }
- else if(PlayersAlive > 1)
- {
- new MostKills;
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(CallRemoteFunction("GetAliveState","i",i) && IsPlayerConnected(i) && PlayerMissionInfo[i][Counted])
- {
- if(PlayerMissionInfo[MostKills][Kills] < PlayerMissionInfo[i][Kills])
- {
- MostKills=i;
- MoreThan1=false;
- continue;
- }
- if(PlayerMissionInfo[MostKills][Kills] == PlayerMissionInfo[i][Kills])
- {
- MoreThan1= true;
- }
- }
- }
- new Float:TopHealth;
- new Float:OtherHealth;
- if(MoreThan1)
- {
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(CallRemoteFunction("GetAliveState","i",i) && IsPlayerConnected(i) && PlayerMissionInfo[i][Counted])
- {
- if(PlayerMissionInfo[winner][Kills] == PlayerMissionInfo[i][Kills])
- {
- GetPlayerHealth(winner,TopHealth);
- GetPlayerHealth(i,OtherHealth);
- if(OtherHealth > TopHealth)
- {
- winner=i;
- MoreThan1= false;
- continue;
- }
- else if(OtherHealth == TopHealth)
- {
- MoreThan1= true;
- }
- }
- }
- }
- }
- if(MoreThan1)
- {
- SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" The last man standing deathmatch has been drawn.");
- CallRemoteFunction("IRC_SendMessage","ss",""SERVER_KEY_MSG" The last man standing deathmatch has been drawn.",IRC_SERVER_COLOR);
- for(new i=0,j=GetPlayerPoolSize(); i<=j; i++)
- {
- if(CallRemoteFunction("GetAliveState","i",i) && IsPlayerConnected(i) && PlayerMissionInfo[i][Counted])
- {
- CallRemoteFunction("PlayerMissionStats","dd",i,2);
- }
- }
- }
- }
- if(PlayersAlive > 0 && !MoreThan1 && winner != INVALID_PLAYER_ID)
- {
- new amount= (PlayerMissionInfo[winner][Kills]*1000)+(10000);
- format(string,sizeof(string),""SERVER_KEY_MSG" %s (%d) has won the last man standing deathmatch. Reward: $%d + Token.",PlayerMissionInfo[winner][UserName],winner,amount);
- CallRemoteFunction("GivePlayerToken","dd",winner,1);
- CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
- SendClientMessageToAll(COLOR_SERVER,string);
- CallRemoteFunction("GivePlayerCash","ii",winner,amount);
- CallRemoteFunction("PlayerMissionStats","dd",winner,0);
- CallRemoteFunction("PlayerMissionStats","dd",winner,12);
- CallRemoteFunction("CheckForBetWinners","d",winner);
- }
- }
- 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);
- }
- }
- 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 CancelTheMission()
- {
- MissionCancelled= true;
- return 1;
- }
- FUNCTION OnPlayerNameRecieve(playerid,name[])
- {
- format(PlayerMissionInfo[playerid][UserName],MAX_PLAYER_NAME,"%s",name);
- return 1;
- }
- FUNCTION MissionObjectiveStarted() return ObjectiveStarted;
- FUNCTION OnPlayerRespawned(playerid)
- {
- if(PlayerMissionInfo[playerid][Counted])
- {
- PlayersAlive--;
- PlayerMissionInfo[playerid][Counted]= false;
- }
- PlayerMissionInfo[playerid][AllowedToSpawn]= true;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment