rendered paste body//---------------------------------------------------------// GhostBustersGhostBustersGhostBustersGhostBustersGhostBusters// By Vkmaster// GhostBustersGhostBustersGhostBustersGhostBustersGhostBusters// Ghostbusters: Ghost Hunt// GhostBustersGhostBustersGhostBustersGhostBustersGhostBusters// bugfixed by uncajesse//---------------------------------------------------------#include <a_samp>//#include <core>//#include <float>#define COLOR_LIGHTBLUE 0x33CCFFAA#define COLOR_GREY 0xAFAFAFAA#define COLOR_GREEN 0x33AA33AA#define COLOR_WHITE 0xFFFFFFAA#define COLOR_YELLOW 0xFFFF33AA//Forwardsforward GameModeExitFunc();forward EndTheRound();forward SetPlayerRandomSpawn(playerid);forward SetHuntedPlayer(playerid,exclude);forward HuntedSurvived();forward SurvivalOfTheHunted();forward SetupPlayerForClassSelection(playerid);forward SendPlayerFormattedText(playerid, const str[], define);new Float:gRandomPlayerSpawns[17][3] = { {1862.0592,3395.0449,9.8452}, {1830.7365,3382.5276,3.8551}, {1811.3085,3331.2612,3.8551}, {1804.0544,3295.2681,6.5579}, {1815.0781,3286.7593,9.5345}, {1832.8679,3287.2319,3.8551}, {1858.6534,3267.1855,7.8189}, {1898.7689,3276.0737,3.8551}, {1944.1643,3290.5618,19.2609}, {1860.6461,3222.6394,3.8551}, {1831.4391,3187.6030,3.8551}, //{1730.5558,3269.6633,27.6203}, //Special Spawn {1803.1881,3209.3726,4.6745}, {1822.3979,3224.4348,4.0248}, {1839.5925,3251.0117,3.8551}, {1904.9363,3236.7944,3.8551}, {1923.7394,3212.5139,3.8551}, {1908.4811,3184.6760,3.8551}};// GhostBusters Stuffnew ghostarea;new gStarted = 0; // Are we playing?new gActivePlayers[MAX_PLAYERS]; // Players in the game, spawned or notnew gSpawnedPlayers[MAX_PLAYERS]; // Keep track of the spawned playersnew gMinimumPlayers = 2; // Minimum players before Ghostbusters will select a playernew gHunted = INVALID_PLAYER_ID; // The Ghost Player.new gScores[MAX_PLAYERS]; // Local score trackernew gSurvivalTime = 300000; // 5 minsnew gSurvivalTimer = -1; // To keep track of the timernew gScoreIncreases[4] = { // Score changes 5, // Surviving the hunt -1, // Dying during the hunt 2, // Killing the hunted 1 // Killing a non-hunted player};new gRoundTime = 1200000; // Round time - 20 mins//new gRoundTime = 900000; // Round time - 15 mins//new gRoundTime = 600000; // Round time - 10 mins//new gRoundTime = 300000; // Round time - 5 mins//new gRoundTime = 120000; // Round time - 2 mins//new gRoundTime = 60000; // Round time - 1 minmain(){ print("\n----------------------------------"); print(" GhostBusters: Hunt The Ghost"); print("----------------------------------\n");}public OnGameModeInit(){ SetGameModeText("GhostBusters"); ghostarea = GangZoneCreate(1039.331, 2639.2, 2370.609, 4017.189); ShowPlayerMarkers(1); ShowNameTags(0); // Player Classes AddPlayerClass(17,0.0,0.0,0.0,0.0,24,300,29,1000,31,1000); AddPlayerClass(202,0.0,0.0,0.0,0.0,24,300,29,1000,31,1000); AddPlayerClass(111,0.0,0.0,0.0,0.0,24,300,29,1000,31,1000); AddPlayerClass(33,0.0,0.0,0.0,0.0,24,300,29,1000,31,1000); AddPlayerClass(34,0.0,0.0,0.0,0.0,24,300,29,1000,31,1000); //Objects CreateObject(4242, 1853.563477, 3283.068115, 2.855131, 0, 0, 0); CreateObject(9746, 1946.189941, 3209.182129, 5.222576, 0, 0, 1.7189); CreateObject(9746, 1896.361206, 3400.353516, 4.679146, 0, 0, 90.0001); CreateObject(10166, 1983.024170, 3318.546875, 20.650114, 0, 0, 101.25); CreateObject(9746, 1787.986206, 3361.821045, 4.846632, 0, 0, 177.4217); CreateObject(9746, 1816.881958, 3173.645996, 4.793167, 0, 0, 270); CreateObject(10166, 1724.404419, 3251.673584, 26.421629, 0, 0, 281.25); CreateObject(16112, 1903.565552, 3151.198242, 8.384983, 0, 304.9961, 277.4941); CreateObject(11502, 1899.450073, 3272.186768, 2.849882, 0, 0, 270); CreateObject(11428, 1813.668945, 3336.578857, 9.640918, 0, 0, 33.75); CreateObject(11440, 1856.467407, 3306.781494, 2.452047, 0, 0, 281.25); CreateObject(11441, 1839.332764, 3315.017090, 3.030035, 0, 0, 258.75); CreateObject(11442, 1891.675415, 3364.051514, 3.028884, 0, 0, 112.5001); CreateObject(11443, 1854.199219, 3348.407471, 3.026876, 0, 0, 0); CreateObject(11445, 1885.640381, 3296.865479, 3.026876, 0, 0, 123.75); CreateObject(11457, 1809.570557, 3296.618652, 2.456350, 0, 0, 22.5); CreateObject(16563, 1846.290894, 3284.571777, 1.339430, 0, 0, 258.75); CreateObject(3866, 1890.367554, 3329.571533, 10.693695, 0, 0, 225); CreateObject(3887, 1875.241211, 3200.948730, 10.223579, 0, 0, 225); CreateObject(8493, 1875.797974, 3364.269775, 14.127306, 0, 319.6065, 191.4045); CreateObject(11088, 1816.714233, 3222.803955, 8.362015, 0, 0, 0); CreateObject(11425, 1828.735107, 3283.632324, 4.676817, 0, 0, 292.5); CreateObject(11427, 1804.131836, 3314.923096, 10.044991, 0, 0, 157.5); CreateObject(11428, 1903.509399, 3296.771484, 8.758600, 0, 0, 326.25); CreateObject(11440, 1826.594238, 3366.282227, 2.452047, 0, 0, 315); CreateObject(18236, 1855.315186, 3326.311523, 2.850199, 0, 0, 281.25); CreateObject(3866, 1868.172974, 3259.946045, 10.693695, 0, 0, 292.5); CreateObject(647, 1841.133545, 3251.131104, 4.687047, 0, 0, 0); CreateObject(647, 1812.352661, 3266.665771, 4.687047, 0, 0, 0); CreateObject(647, 1839.999634, 3337.819580, 4.687047, 0, 0, 0); CreateObject(651, 1862.202759, 3289.250732, 3.054800, 0, 0, 0); CreateObject(651, 1815.076782, 3316.304199, 3.054800, 0, 0, 0); CreateObject(650, 1821.823730, 3268.313232, 3.079023, 0, 0, 0); CreateObject(650, 1833.151978, 3287.959717, 3.079023, 0, 0, 0); CreateObject(650, 1880.188477, 3313.945801, 3.079023, 0, 0, 0); CreateObject(692, 1849.740845, 3267.282227, 2.897834, 0, 0, 0); CreateObject(702, 1829.172974, 3247.502686, 3.422138, 0, 0, 0); CreateObject(754, 1839.051758, 3255.256592, 2.958615, 0, 0, 0); CreateObject(756, 1843.746460, 3309.702881, 2.957520, 0, 0, 0); CreateObject(760, 1832.549927, 3287.486084, 3.220326, 0, 0, 0); CreateObject(760, 1820.458984, 3295.601318, 3.220326, 0, 0, 0); CreateObject(806, 1856.701904, 3377.753418, 6.645785, 0, 0, 0); CreateObject(806, 1873.285156, 3360.601318, 6.645785, 0, 0, 0); CreateObject(855, 1872.416138, 3346.083008, 4.684847, 0, 0, 0); CreateObject(855, 1868.890381, 3385.539307, 4.684847, 0, 0, 0); CreateObject(855, 1872.881592, 3268.929443, 4.684847, 0, 0, 0); CreateObject(873, 1900.288208, 3240.073242, 4.648700, 0, 0, 0); CreateObject(874, 1896.766846, 3232.659180, 4.648700, 0, 0, 0); CreateObject(18013, 1866.585693, 3372.579346, 2.961451, 34.3775, 0, 102.1868); CreateObject(17958, 1832.118164, 3325.760010, 4.886566, 0, 0, 326.25); CreateObject(16390, 1821.649170, 3360.980469, 4.986922, 0, 0, 258.75); CreateObject(6430, 1844.536133, 3265.171143, 3.486773, 0, 0, 315); CreateObject(791, 1908.778198, 3239.898193, 3.199843, 0, 0, 0); CreateObject(791, 1911.010986, 3202.656006, 1.199846, 0, 0, 326.25); CreateObject(777, 1870.035522, 3270.492920, 2.876534, 0, 0, 303.75); CreateObject(771, 1892.989868, 3347.387207, 2.855207, 0, 0, 0); CreateObject(735, 1810.291382, 3335.581543, 2.285761, 0, 0, 0); CreateObject(734, 1822.781616, 3209.792480, 3.026052, 0, 0, 0); CreateObject(719, 1877.718872, 3230.630127, 2.903463, 0, 0, 0); CreateObject(719, 1915.216675, 3278.014893, 2.903465, 0, 0, 0); CreateObject(709, 1874.453613, 3332.495850, -10.920874, 0, 0, 0); CreateObject(3875, 1851.206177, 3230.611572, 10.353247, 0, 0, 292.5); CreateObject(16112, 1806.711182, 3370.766846, -0.611831, 0, 0, 258.75); CreateObject(18273, 1843.661499, 3315.004883, 25.471966, 0, 0, 0); CreateObject(762, 1951.434937, 3366.632568, 14.377007, 0, 0, 0); CreateObject(762, 1756.758789, 3202.114502, 24.216656, 0, 0, 0); CreateObject(4242, 1853.798950, 3283.103271, 2.851896, 0, 0, 0); CreateObject(744, 1705.553467, 3285.313965, 27.470259, 0, 0, 0); CreateObject(744, 2001.157715, 3284.793945, 21.983086, 0, 0, 335.0763); CreateObject(18228, 1943.502563, 3329.641113, 7.783781, 0, 0, 258.75); CreateObject(18228, 1766.319824, 3237.489258, 6.033785, 0, 0, 67.5); CreateObject(900, 1771.569702, 3236.979492, 18.510830, 46.4095, 33.518, 38.6747); CreateObject(900, 1752.834229, 3213.130127, 7.278911, 3.4377, 74.7709, 0); CreateObject(900, 1773.630859, 3266.439209, 6.166341, 62.7388, 31.7992, 15.4699); CreateObject(744, 1775.673584, 3277.580078, 2.616005, 0, 0, 0); CreateObject(900, 1953.415649, 3300.783447, 9.666341, 356.5623, 287.8074, 31.7992); CreateObject(10903, 1858.193115, 3463.470703, 28.845070, 0, 0, 269.1406); CreateObject(10903, 1731.605347, 3391.326904, 31.092510, 0, 0, 356.5623); CreateObject(10903, 1856.953735, 3121.988281, 39.233677, 0, 0, 89.1406); CreateObject(10903, 1998.835327, 3171.803711, 42.245705, 0, 0, 180.0001); CreateObject(10903, 1998.367432, 3378.646729, 35.193298, 0, 0, 180); CreateObject(10903, 1726.251587, 3221.574707, 40.586079, 0, 0, 0); CreateObject(900, 1973.430420, 3143.744385, 28.927525, 0, 84.2247, 97.9757); CreateObject(1225, 1855.437378, 3351.064209, 3.210886, 0, 0, 0); CreateObject(1225, 1805.287476, 3314.547852, 10.334836, 0, 0, 0); CreateObject(1225, 1846.324097, 3284.520508, 11.563180, 0, 0, 0); CreateObject(1225, 1828.020386, 3303.432861, 6.176023, 0, 0, 0); CreateObject(1225, 1888.887695, 3308.146973, 3.260886, 0, 0, 0); CreateObject(1225, 1865.720947, 3211.310791, 9.337265, 0, 0, 0); AddStaticPickup(358,2,1905.1234,3195.9839,3.8551); // wep AddStaticPickup(350,2,1873.0994,3246.3230,3.8551); // wep1 AddStaticPickup(352,2,1838.3467,3277.1653,3.8551); // wep2 AddStaticPickup(363,2,1853.9817,3306.6504,6.5614); // wep3 AddStaticPickup(365,2,1876.5217,3331.8857,3.8551); // wep4 AddStaticPickup(338,2,1891.8204,3340.2078,3.8551); // wep6 AddStaticPickup(335,2,1911.0603,3335.8521,3.8551); // wep7 AddStaticPickup(344,2,1895.7919,3363.2224,3.8551); // wep8 AddStaticPickup(357,2,1864.4105,3390.2351,5.4819); // wep9 AddStaticPickup(355,2,1874.3094,3363.3867,12.6425);// wep10 AddStaticPickup(347,2,1840.8125,3352.8979,3.8551); // wep11 AddStaticPickup(342,2,1814.5966,3358.6038,8.9893); // wep12 AddStaticPickup(326,2,1803.2240,3329.2114,3.8551); // wep13 AddStaticPickup(358,2,1796.8141,3302.4426,3.8551); // wep14 //Health AddStaticPickup(1240,2,1797.2213,3250.7407,4.0183); // Health 1 AddStaticPickup(1240,2,1797.0074,3245.6182,4.0183); // Health 2 SetTimer("EndTheRound", gRoundTime, 0); return 1;}//---------------------------------------------------------public OnPlayerCommandText(playerid, cmdtext[]){ new cmd[256]; new idx; new string[256]; new tmp[256]; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/help", true) == 0) { SendPlayerFormattedText(playerid,"Ghostbusters: Ghost Hunt Coded By Vkmaster.",0); SendPlayerFormattedText(playerid,"Type: /objective : to find out what to do in this gamemode.",0); return 1; } if(strcmp(cmd, "/objective", true) == 0) { SendPlayerFormattedText(playerid,"The Objective of this gamemode is to find and kill the ghost, the ghost",0); SendPlayerFormattedText(playerid,"must stay alive for 5 minutes to win, the ghost has the advantage of,",0); SendPlayerFormattedText(playerid,"300 health points.",0); return 1; } if(strcmp(cmd, "/me", true) == 0) { new playername[MAX_PLAYER_NAME]; strmid(tmp, cmdtext, 3, strlen(cmdtext)); GetPlayerName(playerid, playername, sizeof(playername)); if(!strlen(tmp)) SendClientMessage(playerid, COLOR_WHITE, "* USAGE: /me [action]"); else { format(string, sizeof(string), "* %s (id: %d)%s", playername,playerid,tmp); printf(string); SendClientMessageToAll(COLOR_LIGHTBLUE, string); } } return 1;}// PROCESS OTHER COMMANDSpublic SendPlayerFormattedText(playerid, const str[], define){ new tmpbuf[256]; format(tmpbuf, sizeof(tmpbuf), str, define); SendClientMessage(playerid, 0xFFFF00AA, tmpbuf);}//---------------------------------------------------------//---------------------------------------------------------public OnPlayerStateChange(playerid, newstate, oldstate){ if (playerid == gHunted) { new name[MAX_PLAYER_NAME]; new string[256]; GetPlayerName(playerid, name, sizeof(name)); switch (newstate) { case PLAYER_STATE_ONFOOT: format(string, sizeof(string), "*** %s is now on foot", name); } if (strlen(string) > 0) { SendClientMessageToAll(COLOR_GREEN, string); } } return 1;}//---------------------------------------------------------public OnPlayerConnect(playerid){ //Text new Text: gText; gText = TextDrawCreate(5.0, 431.0, "Ghostbuster: Hunt -- Coded And Mapped by VKMaster"); TextDrawUseBox(gText, true); TextDrawShowForPlayer(playerid, gText); SetWorldTime(0); SetWeather(9); SendClientMessage(playerid, COLOR_YELLOW, "Welcome for help type /help"); GameTextForPlayer(playerid,"~w~Ghostbusters: ~r~Ghost Hunt",2000,5); gActivePlayers[playerid] = 1; gScores[playerid] = 0; SetPlayerColor(playerid, COLOR_GREEN); if (gHunted != INVALID_PLAYER_ID) { new name[MAX_PLAYER_NAME]; new string[256]; GetPlayerName(gHunted, name, sizeof(name)); format(string, sizeof(string), "*** %s is the ghost", name); SendClientMessage(playerid, COLOR_WHITE, string); } return 1;}//---------------------------------------------------------public OnPlayerRequestClass(playerid, classid){ SetupPlayerForClassSelection(playerid); return 1;}//---------------------------------------------------------public OnPlayerDisconnect(playerid){ gSpawnedPlayers[playerid] = 0; gActivePlayers[playerid] = 0; gScores[playerid] = 0; if (playerid == gHunted) { SetHuntedPlayer(INVALID_PLAYER_ID, INVALID_PLAYER_ID); } return 1;}//---------------------------------------------------------public OnPlayerSpawn(playerid){ SetPlayerColor(playerid, COLOR_GREEN); SetWorldTime(0); SetWeather(9); GangZoneShowForPlayer(playerid, ghostarea, 0xFFFFFFAD); gSpawnedPlayers[playerid] = 1; //SetPlayerWorldBounds(playerid, 1981.8381, 1730.6501, 3141.5920, 3445.4937); if (gHunted == INVALID_PLAYER_ID) { if (!gStarted) { new count = 0; for (new i = 0; i < sizeof(gSpawnedPlayers); i++) { if (gSpawnedPlayers[i] == 1) { count++; } } if (count >= gMinimumPlayers) { gStarted = 1; SetHuntedPlayer(INVALID_PLAYER_ID, INVALID_PLAYER_ID); // Passing invalid_player_id chooses a random player } else { new NeededPlayers = gMinimumPlayers - count; new message[50]; format(message, sizeof(message), "*** We need %d more player to start ghost hunt!", NeededPlayers); SendClientMessageToAll(COLOR_WHITE, message); } } else { SetHuntedPlayer(playerid, INVALID_PLAYER_ID); } } SetPlayerRandomSpawn(playerid); return 1;}//---------------------------------------------------------public SetPlayerRandomSpawn(playerid){ new rand = random(sizeof(gRandomPlayerSpawns)); SetPlayerPos(playerid, gRandomPlayerSpawns[rand][0], gRandomPlayerSpawns[rand][1], gRandomPlayerSpawns[rand][2]); // Warp the player return 1;}//---------------------------------------------------------public SurvivalOfTheHunted() { gSurvivalTimer = -1; HuntedSurvived(); SetHuntedPlayer(INVALID_PLAYER_ID, gHunted);}public HuntedSurvived() { new name[MAX_PLAYER_NAME]; new string[256]; GetPlayerName(gHunted, name, sizeof(name)); format(string, sizeof(string), "*** %s survived the ghost hunt!", name); SetPlayerColor(gHunted, COLOR_GREEN); gScores[gHunted] += gScoreIncreases[0]; SetPlayerScore(gHunted, gScores[gHunted]); SendClientMessageToAll(COLOR_GREEN, string);}//---------------------------------------------------------public SetHuntedPlayer(playerid, exclude) { // Exclude only works for random pickage! new name[MAX_PLAYER_NAME]; new string[256]; if (gSurvivalTimer > -1) { KillTimer(gSurvivalTimer); gSurvivalTimer = -1; } gHunted = INVALID_PLAYER_ID; if (playerid == INVALID_PLAYER_ID) { new spawnedids[MAX_PLAYERS]; new count = 0; for (new id = 0; id < sizeof(gSpawnedPlayers); id++) { if ((gSpawnedPlayers[id] == 1) && (id != exclude)) { printf("Added %d to the spawnedids, cause it's not %d", id, exclude); spawnedids[count] = id; count++; } } if (count > 0) { gHunted = spawnedids[random(count)]; } else { // No people are spawned, we'll wait for the next person to spawn SendClientMessageToAll(COLOR_GREEN, " No-one is spawned. The next person to spawn will be hunted!"); return 0; } } else { gHunted = playerid; } GetPlayerName(gHunted, name, sizeof(name)); format(string, sizeof(string), "The new ghost is: %s!", name); SendClientMessageToAll(COLOR_WHITE, string); //Set Invisible SetPlayerColor(playerid, 0xFFFFFF00); //Remove Weapons ResetPlayerWeapons(playerid); //Weapons GivePlayerWeapon(playerid, 37, 1000); GivePlayerWeapon(playerid, 338, 10); GivePlayerWeapon(playerid, 335, 10); //Set Health SetPlayerHealth(playerid, 700); //Skin Ghost SetPlayerSkin(playerid, 62); gSurvivalTimer = SetTimer("SurvivalOfTheHunted", gSurvivalTime, 0); return 1;}//---------------------------------------------------------public OnPlayerDeath(playerid, killerid, reason){ gSpawnedPlayers[playerid] = 0; if (killerid == INVALID_PLAYER_ID) { if (playerid == gHunted) { gScores[playerid] += gScoreIncreases[1]; SetPlayerScore(playerid, gScores[playerid]); } } else { if (playerid == gHunted) { gScores[playerid] += gScoreIncreases[1]; SetPlayerScore(playerid, gScores[playerid]); gScores[killerid] += gScoreIncreases[2]; SetPlayerScore(killerid, gScores[killerid]); } else { gScores[killerid] += gScoreIncreases[3]; SetPlayerScore(killerid, gScores[killerid]); } } if (playerid == gHunted) { SetHuntedPlayer(killerid, playerid); } SetPlayerColor(playerid, COLOR_GREY); SendDeathMessage(killerid, playerid, reason); return 1;}//---------------------------------------------------------public SetupPlayerForClassSelection(playerid){ SetPlayerPos(playerid,1827.5363,3226.7122,5.1756); SetPlayerFacingAngle(playerid,0.0); SetPlayerCameraPos(playerid,1828.0337,3229.8081,4.2034); SetPlayerCameraLookAt(playerid,1827.5363,3226.7122,5.1756);}//---------------------------------------------------------public EndTheRound() { new draw = false; new winner = INVALID_PLAYER_ID; for (new i=0; i<MAX_PLAYERS; i++) { if (gActivePlayers[i]) { if (winner == INVALID_PLAYER_ID) winner = i; if (i != winner) { if (gScores[i] > gScores[winner]) { draw = false; winner = i; } else if (gScores[i] == gScores[winner]) { draw = true; } } } } if (winner == INVALID_PLAYER_ID) { } // Do nothing cause there's no players else if (draw) { GameTextForAll("The result was a draw!", 5000, 3); } else { new name[MAX_PLAYER_NAME]; new string[256]; GetPlayerName(winner, name, sizeof(name)); format(string, sizeof(string), "%s won~n~With a score of: %d", name, gScores[winner]); GameTextForAll(string, 5000, 3); } SetTimer("GameModeExitFunc", 5000, 0);}//---------------------------------------------------------public GameModeExitFunc(){ GameModeExit();}strtok(const string[], &index){ new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result;}