SHARE
TWEET

DeathMatch Event [v1.2]

Rxert Feb 24th, 2018 (edited) 139 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #if defined DME
  2.  
  3. Death Match Event System By RxErT!
  4. First Version: 1.0 //Old not recommended.
  5. Second Version: 1.1 //Old not recommended.
  6. Third Version 1.2 // New and recommended!
  7.  
  8. #endif
  9.  
  10.  
  11. //====== INCLUDES & DEFINES =======//
  12. #include <a_samp>
  13. #include <zcmd>
  14. #include <sscanf>
  15. #include <foreach>
  16. #define SCM    SendClientMessage //defining SendClientMessage to be more easier to write it and to stop wasting time in writing it completely.
  17. #define SCMTA  SendClientMessageToAll //same to SendClientMessage's story.
  18. //======== EVENT VARIABLES =========//
  19. new
  20. InEvent[MAX_PLAYERS],  //Checking player if he is in/out event
  21. EventOpened[MAX_PLAYERS], //Checking if Event is opened to join it.
  22. weapon, //Weapon variable.
  23. EventStarted[MAX_PLAYERS],
  24. Float:RandomEventSpawns[][] =
  25. {
  26.     {-1351.4404,27.2709,14.1484,229.3567},
  27.     {-1270.1122,-52.0604,14.1484,44.1982},
  28.     {-1284.0488,13.3623,14.1484,132.5356}
  29. }; //This is Random Event spawns.
  30. //======== FORWARD =========//
  31. forward EventStart(); //we did forwarded this as timer to event stats.
  32. //======== STOCKS =========//
  33. /*
  34.        REMOVED STOCKS
  35. */
  36. //======= COMMANDS AND MAP AND EVENT THINGYS GOES HERE! ========//
  37. CMD:dmevent(playerid, params[])
  38. {
  39.     if(IsPlayerAdmin(playerid))
  40.     {
  41.         if(EventOpened[playerid] == 0)
  42.         {
  43.             new string[128];
  44.             if(sscanf(params,"i",weapon)) return SCM(playerid,-1,"{fdfe1d}Syntax: {FFFFFF}/dmevent <weaponid>");
  45.             if(weapon < 0 || weapon > 46) return SCM(playerid,-1,"{f00f00}[ERROR]: {ffffff}Invalid Weapon ID!");
  46.             EventOpened[playerid] = 1;
  47.             EventStarted[playerid] = 0;
  48.             SCMTA(-1,"{800080}[EVENT INFO] {fef65b}An Administrator has opened a DM Event!");
  49.             format(string,sizeof(string),"{800080}[EVENT INFO] {fef65b}Type {2faced}/joindm {fef65b}to join the DM Event! {F00f00}(Weapon: %d)",weapon);
  50.             SCMTA(-1,string);
  51.             GameTextForAll("~R~DM ~W~EVENT ~G~OPENED!",3000,3);
  52.             SetTimerEx("EventStart", 1000, false, "i", playerid);
  53.         }
  54.         else
  55.         {
  56.             if(EventOpened[playerid] == 1)
  57.             {
  58.                 SCMTA(-1,"{800080}[EVENT INFO] {fef65b}An Administrator has closed the DM Event, and started it!");
  59.                 EventOpened[playerid] = 0;
  60.                 foreach(Player, i)
  61.                 {
  62.                 if(IsPlayerConnected(i))
  63.                 {
  64.                 TogglePlayerControllable(i, 1);
  65.                 InEvent[playerid] = 1;
  66.                 EventStarted[playerid] = 1;
  67.                 GameTextForPlayer(i, "~W~EVENT ~Y~HAS ~G~BEEN ~B~STARTED!", 3000, 3);
  68.                 }
  69.                 }
  70.             }
  71.         }
  72.     }
  73.     else
  74.     {
  75.         SCM(playerid, -1,"{F00f00}[ERROR]: {FFFFFF}You aren't authorized to use this command!");
  76.     }
  77.     return 1;
  78. }
  79.  
  80.  
  81. CMD:fire(playerid,params[])
  82. {
  83.     new ID, string[128], tname[MAX_PLAYER_NAME];
  84.     GetPlayerName(ID, tname,sizeof(tname));
  85.     if(sscanf(params,"is",ID,params)) return SCM(playerid,-1,"{fdfe1d}Syntax: {FFFFFF}/fire <id> <reason>");
  86.     if(!IsPlayerAdmin(playerid)) return  SCM(playerid, -1, "{F00f00}[ERROR]: {FFFFFF}You are not authorized to use this command!");
  87.     if(!IsPlayerConnected(ID)) return SCM(playerid, -1, "{f00f00}[ERROR]: {FFFFFF}Player isn't connected!");
  88.     if(InEvent[ID] == 0) return SCM(playerid, -1, "{f00f00}[ERROR]: {FFFFFF}Player isn't in the DM Event!");
  89.     format(string,sizeof(string),"{800080}[EVENT FIRE] {Fef65b}%s has been fired from the DM Event! {f00f00}[REASON: %s]",tname, params);
  90.     SCMTA(-1,string);
  91.     InEvent[ID] = 0;
  92.     SpawnPlayer(ID);
  93.     return 1;
  94. }
  95.  
  96.  
  97. CMD:joindm(playerid,params[])
  98. {
  99.     if(InEvent[playerid] == 1) return SendClientMessage(playerid,-1,"{f00f00}[ERROR]: {FFFFFF}You're already in the DM Event!");
  100.     if(EventOpened[playerid] == 0) return SendClientMessage(playerid, -1,"{f00f00}[ERROR]: {FFFFFF}there isn't any DM Event at the moment!");
  101.     new Random = random(sizeof(RandomEventSpawns)), name[MAX_PLAYER_NAME], id, string[128];
  102.     GetPlayerName(id, name,sizeof(name));
  103.     SetPlayerPos(playerid,RandomEventSpawns[Random][0], RandomEventSpawns[Random][1], RandomEventSpawns[Random][2]);
  104.     SetPlayerVirtualWorld(playerid,1);
  105.     TogglePlayerControllable(playerid, 0);
  106.     ResetPlayerWeapons(playerid);
  107.     GivePlayerWeapon(playerid, weapon, 99999);
  108.     SetPlayerArmour(playerid, 100.0);
  109.     SetPlayerHealth(playerid, 100.0);
  110.     InEvent[playerid] = 1;
  111.     EventOpened[playerid] = 1;
  112.     format(string,sizeof(string),"{2faced}JOINED: {fef65b}%s(%i) {800080}has joined the DM event!",name,id);
  113.     SendClientMessageToAll(-1,string);
  114.     SendClientMessage(playerid, -1,"{800080}[INFO] {fef65b}Type {f00f00}/leavedm {fef65b}if you want to leave");
  115.     GameTextForPlayer(playerid, "~W~Event will start in ~P~Minutes!",3000,3);
  116.     return 1;
  117. }
  118.  
  119. CMD:leavedm(playerid,params[])
  120. {
  121.   if(InEvent[playerid] == 1)
  122.   {
  123.      if(EventStarted[playerid] == 1) return SendClientMessage(playerid, -1,"[ERROR]: {FFFFFF}You cannot leave when the DM is already started!");
  124.      new
  125.      name[MAX_PLAYER_NAME],
  126.      id,
  127.      string[128];
  128.      SpawnPlayer(playerid);
  129.      InEvent[playerid] = 0;
  130.      format(string,sizeof(string),"{2faced}LEFT: {fef65b}%s(%i) {800080}has left the DM event! {f00f00}(/leavedm)",name,id);
  131.      SCMTA(-1, string);
  132.   }
  133.   else
  134.   {
  135.   SendClientMessage(playerid, -1,"{f00f00}[ERROR]: {ffffff}You aren't in any DM event to leave!");
  136.   }
  137.   return 1;
  138. }
  139.      
  140. public EventStart()
  141. {
  142.     CreateObject(3453, -1221.230957, 432.340606, 9.336962, 0.000000, 0.000000, 0.000000);
  143.     CreateObject(3452, -1215.755615, 460.229461, 9.311964, 0.000000, 0.000000, 90.000000);
  144.     CreateObject(3453, -1222.101562, 474.111846, 9.367557, 0.000000, 0.000000, 90.000000);
  145.     CreateObject(3452, -1251.935424, 479.604248, 9.405378, 0.000000, 0.000000, 180.000000);
  146.     CreateObject(3453, -1241.440185, -24.832351, 15.722908, 0.000000, 0.000000, 45.000000);
  147.     CreateObject(3452, -1258.452270, -0.125663, 15.747909, 0.000000, 0.000000, 134.999969);
  148.     CreateObject(3452, -1300.089477, 41.548461, 15.697910, 0.000000, 0.000000, 134.999969);
  149.     CreateObject(3453, -1325.257934, 57.730583, 15.647909, 0.000000, 0.000000, 134.999969);
  150.     CreateObject(3452, -1350.413452, 40.271453, 15.647911, 0.000000, 0.000000, 225.000030);
  151.     CreateObject(3452, -1371.132446, 19.394195, 15.672910, 0.000000, 0.000000, 225.000030);
  152.     CreateObject(3452, -1257.617675, -50.034523, 15.722909, 0.000000, 0.000000, 45.000000);
  153.     CreateObject(3452, -1278.682861, -70.883903, 15.697908, 0.000000, 0.000000, 45.000000);
  154.     CreateObject(3453, -1386.855834, -5.336665, 15.715358, 0.000000, 0.000000, 225.000030);
  155.     CreateObject(3453, -1303.802490, -88.125671, 15.647909, 0.000000, 0.000000, 315.000000);
  156.     CreateObject(3452, -1369.440307, -30.486749, 15.747909, 0.000000, 0.000000, 315.000000);
  157.     CreateObject(3452, -1328.677368, -72.280700, 15.597913, 0.000000, 0.000000, 315.000000);
  158.     CreateObject(3279, -1327.697753, 47.628265, 13.224054, 0.000000, 0.000000, 134.999969);
  159.     CreateObject(3279, -1373.739013, 1.586212, 13.224054, 0.000000, 0.000000, 134.999969);
  160.     CreateObject(3279, -1253.568603, -26.533119, 13.224054, 0.000000, 0.000000, 315.000000);
  161.     CreateObject(3279, -1299.551025, -72.534378, 13.224054, 0.000000, 0.000000, 315.000000);
  162.     CreateObject(16776, -1241.716308, -69.387710, 22.292963, 0.000000, 0.000000, 315.000000);
  163.     CreateObject(7392, -1262.929931, 32.618263, 40.102794, 0.000000, 0.000000, 45.000000);
  164.     CreateObject(7073, -1277.822631, 50.415985, 31.428398, 0.000000, 0.000000, 45.000000);
  165.     CreateObject(3452, -1279.342285, 20.789491, 15.722909, 0.000000, 0.000000, 134.999969);
  166.     CreateObject(3749, -1346.161132, -48.366500, 19.006851, 0.000000, 0.000000, 315.000000);
  167.     CreateObject(971, -1357.530395, -39.579605, 16.718370, 0.000000, 0.000000, 225.000030);
  168.     CreateObject(971, -1362.657348, -44.729606, 16.743370, 0.000000, 0.000000, 45.000000);
  169.     CreateObject(971, -1352.056396, -39.570392, 16.768369, 0.000000, 0.000000, 134.999969);
  170.     CreateObject(971, -1337.760986, -60.380943, 16.743370, 0.000000, 0.000000, 225.000030);
  171.     CreateObject(971, -1342.364746, -65.028961, 16.743370, 0.000000, 0.000000, 225.000030);
  172.     CreateObject(971, -1337.698242, -54.490985, 16.693370, 0.000000, 0.000000, 134.999969);
  173.     CreateObject(14467, -1354.408935, -46.069114, 15.882230, 0.000000, 0.000000, 45.000000);
  174.     CreateObject(14467, -1343.873657, -57.543529, 15.882230, 0.000000, 0.000000, 225.000030);
  175.     CreateObject(10281, -1253.928955, 16.057811, 27.112640, 0.000000, 0.000000, 315.000000);
  176.     CreateObject(9527, -1348.007324, -50.055614, 20.397682, 0.000000, 0.000000, 315.000000);
  177.     CreateObject(9191, -1339.683349, -74.586944, 16.470876, 0.000000, 0.000000, 315.000000);
  178.     CreateObject(9190, -1327.904907, -86.385421, 16.420877, 0.000000, 0.000000, 315.000000);
  179.     CreateObject(9190, -1371.315429, -41.996185, 16.470876, 0.000000, 0.000000, 315.000000);
  180.     CreateObject(9191, -1382.572875, -30.718606, 16.470876, 0.000000, 0.000000, 315.000000);
  181.     CreateObject(9188, -1394.302368, -18.988555, 16.470876, 0.000000, 0.000000, 315.000000);
  182.     CreateObject(9188, -1316.148437, -98.181648, 16.420877, 0.000000, 0.000000, 315.000000);
  183.     CreateObject(7093, -1352.766357, -41.006092, 25.340902, 0.000000, 0.000000, 0.000000);
  184.     CreateObject(9191, -1400.149291, -4.900668, 16.470876, 0.000000, 0.000000, 270.000000);
  185.     CreateObject(972, -1387.840576, 11.532464, 12.677876, 0.000000, 0.000000, 134.999969);
  186.     CreateObject(972, -1370.220947, 29.158786, 12.685426, 0.000000, 0.000000, 134.999984);
  187.     CreateObject(972, -1352.855712, 46.681182, 12.660427, 0.000000, 0.000000, 134.999984);
  188.     CreateObject(972, -1338.070312, 61.488784, 12.685424, 0.000000, 0.000000, 134.999984);
  189.     CreateObject(972, -1319.473388, 64.975769, 12.658924, 0.000000, 0.000000, 78.750000);
  190.     CreateObject(9190, -1302.253662, -102.315498, 16.420877, 0.000000, 0.000000, 11.250030);
  191.     CreateObject(972, -1289.466796, -91.362266, 12.410429, 0.000000, 0.000000, 315.000000);
  192.     CreateObject(972, -1271.873901, -73.712463, 12.382879, 0.000000, 0.000000, 315.000000);
  193.     CreateObject(972, -1254.444335, -56.299110, 12.418819, 0.000000, 0.000000, 315.000000);
  194.     CreateObject(972, -1239.102050, -38.207252, 12.504232, 0.000000, 0.000000, 326.249969);
  195.     CreateObject(972, -1233.524902, -18.601697, 12.585428, 0.000000, 0.000000, 11.250030);
  196.     CreateObject(972, -1242.772094, 1.222285, 12.620326, 0.000000, 0.000000, 45.000000);
  197.     CreateObject(972, -1260.213378, 18.620136, 12.645326, 0.000000, 0.000000, 45.000000);
  198.     CreateObject(972, -1300.708129, 53.481170, 12.645326, 0.000000, 0.000000, 45.000000);
  199.     CreateObject(972, -1280.746337, 37.279335, 12.545328, 0.000000, 0.000000, 56.250000);
  200.     CreateObject(974, -1268.357666, 32.086219, 15.768571, 0.000000, 0.000000, 315.000000);
  201.     CreateObject(987, -1243.385375, 33.131969, 12.820373, 0.000000, 0.000000, 134.999969);
  202.     CreateObject(987, -1249.803222, 39.503234, 12.862133, 0.000000, 0.000000, 134.999969);
  203.     CreateObject(982, -1263.090332, -32.494636, 13.831992, 0.000000, 0.000000, 315.000000);
  204.     CreateObject(982, -1281.185913, -50.588050, 13.804745, 0.000000, 0.000000, 315.000000);
  205.     CreateObject(983, -1292.503295, -61.968704, 13.781992, 0.000000, 0.000000, 315.000000);
  206.     CreateObject(983, -1297.052124, -66.487190, 13.781992, 0.000000, 0.000000, 134.999969);
  207.     CreateObject(982, -1311.596801, -63.880908, 13.831992, 0.000000, 0.000000, 45.000000);
  208.     CreateObject(982, -1329.769409, -45.746337, 13.806992, 0.000000, 0.000000, 45.000000);
  209.     CreateObject(982, -1347.868774, -27.644811, 13.831992, 0.000000, 0.000000, 45.000000);
  210.     CreateObject(982, -1365.989990, -9.540893, 13.856991, 0.000000, 0.000000, 45.000000);
  211.     CreateObject(982, -1364.442382, 7.443561, 13.831992, 0.000000, 0.000000, 315.000000);
  212.     CreateObject(982, -1346.335815, 25.531946, 13.831992, 0.000000, 0.000000, 315.000000);
  213.     CreateObject(983, -1334.998413, 36.842609, 13.831992, 0.000000, 0.000000, 315.000000);
  214.     CreateObject(983, -1330.491943, 41.277942, 13.831992, 0.000000, 0.000000, 134.999969);
  215.     CreateObject(983, -1327.098388, 44.698101, 13.831992, 0.000000, 0.000000, 134.999969);
  216.     CreateObject(982, -1315.922607, 39.280868, 13.831992, 0.000000, 0.000000, 45.000000);
  217.     CreateObject(982, -1297.836425, 21.188003, 13.856991, 0.000000, 0.000000, 45.000000);
  218.     CreateObject(982, -1279.721069, 3.056617, 13.881991, 0.000000, 0.000000, 45.000000);
  219.     CreateObject(982, -1261.634643, -14.932929, 13.856991, 0.000000, 0.000000, 45.000000);
  220. }
  221.  
  222. public OnPlayerConnect(playerid)
  223. {
  224.     SendClientMessage(playerid, -1, "{fef65b}DM Event System Loaded!");
  225.     SendClientMessage(playerid, -1, "{95fa7f}it's Created by RxErT!");
  226.     SendClientMessage(playerid, -1, "{0099cc}Type /dmcmds & /updates to get available commands!");
  227.     return 1;
  228. }
  229.  
  230.  
  231. public OnPlayerSpawn(playerid)
  232. {
  233.     InEvent[playerid] = 0;
  234.     TogglePlayerControllable(playerid, 1);
  235.     SetPlayerVirtualWorld(playerid, 0);
  236.     return 1;
  237. }
  238.  
  239. CMD:dmcmds(playerid, params[])
  240. {
  241.     if(IsPlayerAdmin(playerid))
  242.     {
  243.         new string[500];
  244.         strcat(string, "{fef65b}/dmevent {1ffdc4}-> {fd1f58}to create the DM event!\n");
  245.         strcat(string, "{fef65b}/dmevent {1ffdc4}-> {fd1f58}again type to close and start the event!\n");
  246.         strcat(string, "{fef65b}/fire{1ffdc4} -> {fd1f58}to fire/kick someone from the DM event!\n");
  247.         strcat(string, "{fef65b}/updates{1ffdc4} -> {fd1f58}to see what's new!\n\n");
  248.         strcat(string, "{bbbbee}This DM Event system was created By: {fdfe1d}RxErT!");
  249.         ShowPlayerDialog(playerid, 1884, DIALOG_STYLE_MSGBOX,"DM Event - Commands", string, "Ok", "");
  250.     }
  251.     else
  252.     {
  253.         SCM(playerid, -1, "{F00f00}[ERROR]: {FFFFFF}You are not authorized to use this command!");
  254.     }
  255.     return 1;
  256. }
  257.  
  258. CMD:updates(playerid, params[])
  259. {
  260.    new string[500];
  261.    strcat(string, "{fef65b}1. {fd1f58}Added a {1ffdc4}`text` {fd1f58}for the reason of the /fire!\n");
  262.    strcat(string, "{fef65b}2. {fd1f58}Optimized the code and the language.\n");
  263.    strcat(string, "{fef65b}3. {fd1f58}Combined /startdm with /dmevent, so the event will start and close just when you type /dmevent again!\n\n");
  264.    ShowPlayerDialog(playerid, 1884, DIALOG_STYLE_MSGBOX,"News - Updates", string, "Ok", "");
  265.    return 1;
  266. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top