Advertisement
Guest User

Deathmatch arena system. By PawnHunter

a guest
Nov 13th, 2015
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.09 KB | None | 0 0
  1. /*             DM arena System           */
  2. //  Credits: ---
  3. //      PawnHunter - Creating this script.
  4. //      Yashas - Awesome I-ZCMD include.
  5. //      Emmet_ - For the mighty sscanf.
  6. //      If you don't like the credits
  7. //      you can remove it,
  8. //      "I don't really care" ~Demi Lovato.
  9. //  Notes: ---
  10. //   1. Redefine MAX_PLAYERS to your
  11. //      server is max players to save
  12. //      some memories. no need to use
  13. //      1000 cells while we just going
  14. //      to use 20 - 100 cells.
  15. //   2. This is simple system
  16. //      Contains 2 things.
  17. //      WW Arena / RW Arena.
  18. //      You can enter by following
  19. //      Skull Icon in the mini-map.
  20. //   3. If you want to change
  21. //      the place, make sure
  22. //      to change it OnPlayerSpawn.
  23. //      And change the random spawns.
  24. //   4. Players should be near DM Icon
  25. //      to be able to use DM commands.
  26. //   5. Sorry for my bad English. x[
  27. /*                                       */
  28.  
  29. #define FILTERSCRIPT
  30.  
  31. #include <a_samp>
  32.  
  33. #undef MAX_PLAYERS
  34.  
  35. #define MAX_PLAYERS 40 // Change this define to your server's slots.
  36.  
  37. #include <izcmd>
  38.  
  39. #include <sscanf2>
  40.  
  41.  
  42. #define COLOR_RED       0xFF0000FF
  43. #define COLOR_ORANGE    0xEE9911FF
  44. #define COLOR_LIME      0x00FF00FF
  45.  
  46.  
  47. #define DM_WW_ARENA_VW 7500
  48.  
  49. #define DM_RW_ARENA_VW 7501
  50.  
  51. new
  52.     Text3D:DMALabel,
  53.     bool:InDM[MAX_PLAYERS],
  54.     RWCount = 0,
  55.     WWCount = 0,
  56.     Float:RandomDMSpawn[][] =
  57.     {
  58.         {1746.588, -1743.243, 52.050},
  59.         {1808.576, -1806.984, 52.050},
  60.         {1747.467, -1806.729, 52.050},
  61.         {1809.255, -1743.406, 52.050}
  62.     };
  63. forward OnPlayerSpawnEx(playerid);
  64. stock Float:GetRandomArenaSpawn(&Float:x, &Float:y, &Float:z)
  65. {
  66.     new Random = random(sizeof(RandomDMSpawn));
  67.     x = RandomDMSpawn[Random][0];
  68.     y = RandomDMSpawn[Random][1];
  69.     z = RandomDMSpawn[Random][2];
  70.     return 0.0;
  71. }
  72. stock SetPlayerRASpawn(playerid, virtualworld)
  73. {
  74.     new Float:x, Float:y, Float:z;
  75.     GetRandomArenaSpawn(x, y, z);
  76.     SetPlayerVirtualWorld(playerid, virtualworld);
  77.     SetPlayerPos(playerid, x, y, z);
  78.     SetCameraBehindPlayer(playerid);
  79.     SetPlayerHealth(playerid, 100.0);
  80.     SetPlayerArmour(playerid, 100.0);
  81.     switch(virtualworld)
  82.     {
  83.         case DM_WW_ARENA_VW:
  84.         {
  85.             ResetPlayerWeapons(playerid);
  86.             GivePlayerWeapon(playerid, WEAPON_SNIPER, cellmax);
  87.             GivePlayerWeapon(playerid, WEAPON_SHOTGUN, cellmax);
  88.             GivePlayerWeapon(playerid, WEAPON_DEAGLE, cellmax);
  89.         }
  90.         case DM_RW_ARENA_VW:
  91.         {
  92.             ResetPlayerWeapons(playerid);
  93.             GivePlayerWeapon(playerid, WEAPON_SAWEDOFF, cellmax);
  94.             GivePlayerWeapon(playerid, WEAPON_UZI, cellmax);
  95.             GivePlayerWeapon(playerid, WEAPON_DEAGLE, cellmax);
  96.         }
  97.     }
  98.     return 1;
  99. }
  100. stock UpdateTextLabel()
  101. {
  102.     new tmpstr[128];
  103.     format(tmpstr, sizeof(tmpstr), "Deathmatch Arena Entrance\nUse /dma [WW - RW] to enter arena.\nWW Players Count: %i\nRW Players Count: %i", WWCount, RWCount);
  104.     Update3DTextLabelText(DMALabel, COLOR_LIME, tmpstr);
  105. }
  106. stock SendDMJoinMessage(playerid, type)
  107. {
  108.     new
  109.         pName[MAX_PLAYER_NAME], tmpstr[128], pType[48], count;
  110.     if(type == DM_RW_ARENA_VW) count = RWCount, format(pType, sizeof(pType), "Running Weapons");
  111.     else if(type == DM_WW_ARENA_VW) count = WWCount, format(pType, sizeof(pType), "Walking Weapons");
  112.     GetPlayerName(playerid, pName, sizeof(pName));
  113.     format(tmpstr, sizeof(tmpstr), "(DM) %s(ID:%d) has joined DM arena, type: %s, count: %i", pName, playerid, pType, count);
  114.     return SendClientMessageToAll(COLOR_ORANGE, tmpstr);
  115. }
  116. stock SendDMLeaveMessage(playerid, type)
  117. {
  118.     new
  119.         pName[MAX_PLAYER_NAME], tmpstr[128], pType[48], count;
  120.     if(type == DM_RW_ARENA_VW) count = RWCount, format(pType, sizeof(pType), "Running Weapons");
  121.     else if(type == DM_WW_ARENA_VW) count = WWCount, format(pType, sizeof(pType), "Walking Weapons");
  122.     GetPlayerName(playerid, pName, sizeof(pName));
  123.     format(tmpstr, sizeof(tmpstr), "(DM) %s(ID:%d) has left DM arena, type: %s, count: %i", pName, playerid, pType, count);
  124.     return SendClientMessageToAll(COLOR_ORANGE, tmpstr);
  125. }
  126. public OnFilterScriptInit()
  127. {
  128.     print("\n--------------------------------------\n  Basic deathmatch arena system\n    Made by PawnHunter\n--------------------------------------");
  129.     DMALabel = Create3DTextLabel("Deathmatch Arena Entrance\nUse /dma [WW - RW] to enter arena.\nWW Players Count: 0\nRW Players Count: 0",COLOR_LIME,2185, 1114, 14,40,0,0);
  130.     return 1;
  131. }
  132.  
  133.  
  134. public OnFilterScriptExit()
  135. {
  136.     return 1;
  137. }
  138.  
  139.  
  140. public OnPlayerConnect(playerid)
  141. {
  142.     InDM[playerid] = false;
  143.     SetPlayerMapIcon(playerid, 20, 2185, 1114, 12, 23, 0, MAPICON_GLOBAL);
  144.     return 1;
  145. }
  146.  
  147. public OnPlayerDisconnect(playerid, reason)
  148. {
  149.     if(InDM[playerid])
  150.     {
  151.         switch(GetPVarInt(playerid, "dmVirtualWorld"))
  152.         {
  153.             case DM_RW_ARENA_VW: RWCount--, SendDMLeaveMessage(playerid, DM_RW_ARENA_VW);
  154.             case DM_WW_ARENA_VW: WWCount--, SendDMLeaveMessage(playerid, DM_WW_ARENA_VW);
  155.         }
  156.         UpdateTextLabel();
  157.     }
  158.     return 1;
  159. }
  160.  
  161. public OnPlayerSpawn(playerid)
  162. {
  163.     if(InDM[playerid])
  164.     {
  165.         SetTimerEx("OnPlayerSpawnEx", 700, false, "i", playerid);
  166.     }
  167.     else if(GetPVarInt(playerid, "ExitingDMArena") == 1)
  168.     {
  169.         SetPlayerVirtualWorld(playerid, 0);
  170.         DeletePVar(playerid, "ExitingDMArena");
  171.     }
  172.     return 1;
  173. }
  174. public OnPlayerSpawnEx(playerid)
  175. {
  176.     if(IsPlayerConnected(playerid)) return SetPlayerRASpawn(playerid, GetPVarInt(playerid, "dmVirtualWorld"));
  177.     return 0;
  178. }
  179. public OnPlayerDeath(playerid, killerid, reason)
  180. {
  181.     return 1;
  182. }
  183. CMD:dma(playerid, params[])
  184. {
  185.     extract params -> new string:Usage[64]; else
  186.         return SendClientMessage(playerid, COLOR_RED, "USAGE: dma <WW / RW / EXIT>");
  187.     else if(IsPlayerInAnyVehicle(playerid))
  188.         return SendClientMessage(playerid, COLOR_RED, "ERROR: Leave your vehicle before using this command.");
  189.     else
  190.     {
  191.         if(!strcmp(Usage, "ww", true))
  192.         {
  193.             if (!IsPlayerInRangeOfPoint(playerid, 5.1, 2185.2, 1114.1, 12.3))
  194.                 return SendClientMessage(playerid, COLOR_RED, "ERROR: You can use this command while near deathmatch arena entrance (Skull icon).");
  195.             InDM[playerid] = true;
  196.             SetPlayerRASpawn(playerid, DM_WW_ARENA_VW);
  197.             SetPVarInt(playerid, "dmVirtualWorld", DM_WW_ARENA_VW);
  198.             WWCount++;
  199.             UpdateTextLabel();
  200.             SendDMJoinMessage(playerid, DM_WW_ARENA_VW);
  201.         }
  202.         else if(!strcmp(Usage, "rw", true))
  203.         {
  204.             if (!IsPlayerInRangeOfPoint(playerid, 5.1, 2185.2, 1114.1, 12.3))
  205.                 return SendClientMessage(playerid, COLOR_RED, "ERROR: You can use this command while near deathmatch arena entrance (Skull icon).");
  206.             InDM[playerid] = true;
  207.             SetPlayerRASpawn(playerid, DM_RW_ARENA_VW);
  208.             SetPVarInt(playerid, "dmVirtualWorld", DM_RW_ARENA_VW);
  209.             RWCount++;
  210.             UpdateTextLabel();
  211.             SendDMJoinMessage(playerid, DM_RW_ARENA_VW);
  212.         }
  213.         else if(!strcmp(Usage, "exit", true))
  214.         {
  215.             if(!InDM[playerid])
  216.                 return SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot use this command while not inside one of deathmatch arena.");
  217.             switch(GetPVarInt(playerid, "dmVirtualWorld"))
  218.             {
  219.                 case DM_RW_ARENA_VW: RWCount--, SendDMLeaveMessage(playerid, DM_RW_ARENA_VW);
  220.                 case DM_WW_ARENA_VW: WWCount--, SendDMLeaveMessage(playerid, DM_WW_ARENA_VW);
  221.             }
  222.             UpdateTextLabel();
  223.             InDM[playerid] = false;
  224.             DeletePVar(playerid, "dmVirtualWorld");
  225.             SpawnPlayer(playerid);
  226.             SetPVarInt(playerid, "ExitingDMArena", 1);
  227.         }
  228.     }
  229.     return CMD_SUCCESS;
  230. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement