Guest User

Untitled

a guest
Dec 28th, 2018
926
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //============================================================================//
  2. #include < a_samp >
  3. #include < sscanf2 >
  4. #include < zcmd >
  5. #include < foreach >
  6. //============================================================================//
  7.  
  8. #define SCM SendClientMessage
  9. #define SCMALL SendClientMessageToAll
  10. #define COLOR_GREY 0xD4D4D4FF
  11.  
  12.  
  13. //DIALOGS DEFINE
  14.  
  15. #define DIALOG_DUEL_WEAPON 1
  16. #define DIALOG_DUEL_MAP 2
  17.  
  18. //============================================================================//
  19.  
  20. new InDuel[MAX_PLAYERS],
  21. DuelInvite[MAX_PLAYERS],
  22. DuelAccepter[MAX_PLAYERS],
  23. DuelWeapon[MAX_PLAYERS],
  24. DuelMap[MAX_PLAYERS];
  25. #pragma dynamic 145000
  26. //============================================================================//
  27. stock GetName(playerid)
  28. {
  29. new szName[MAX_PLAYER_NAME];
  30. GetPlayerName(playerid, szName, sizeof(szName));
  31. return szName;
  32. }
  33. //============================================================================//
  34. main(){printf("Gamemode-ul se proceseaza...");}
  35.  
  36. forward resetDuel(playerid);
  37. public resetDuel(playerid)
  38. {
  39. InDuel[playerid] = 0;
  40. DuelInvite[playerid] = -1;
  41. DuelWeapon[playerid] = -1;
  42. DuelMap[playerid] = -1;
  43. DuelAccepter[playerid] = -1;
  44. }
  45.  
  46. forward duelTimer(playerid);
  47. public duelTimer(playerid)
  48. {
  49. TogglePlayerControllable(playerid, 1);
  50. TogglePlayerControllable(DuelInvite[playerid], 1);
  51. TogglePlayerControllable(DuelInvite[playerid], 1);
  52. }
  53.  
  54. public OnPlayerDeath(playerid, killerid, reason)
  55. {
  56. if(InDuel[playerid] == 1)
  57. {
  58. SpawnPlayer(playerid);
  59. SetPlayerInterior(playerid, 0);
  60. GameTextForPlayer(playerid, "You have lost the duel.", 3000, 3);
  61. if(GetPlayerMoney(playerid) < 50000) return 1;
  62. else GivePlayerMoney(playerid, -50000), SCM(playerid, 0xFF7A7AAA, "You have lost the duel and $50,000.");
  63. resetDuel(playerid);
  64. }
  65. if(InDuel[killerid] == 1 )
  66. {
  67. SpawnPlayer(killerid);
  68. SetPlayerInterior(playerid, 0);
  69. GameTextForPlayer(killerid, "You have won the duel.", 3000, 3);
  70. GivePlayerMoney(killerid, 50000);
  71. SCM(killerid, 0x88FF7AAA, "You have won the duel and $50,000.");
  72. ResetPlayerWeapons(killerid);
  73. resetDuel(killerid);
  74. }
  75. return 1;
  76. }
  77.  
  78. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  79. {
  80. switch(dialogid)
  81. {
  82. case DIALOG_DUEL_MAP:
  83. {
  84. if(!response) return 1;
  85. switch(listitem)
  86. {
  87. case 0: DuelMap[playerid] = 0;
  88. case 1: DuelMap[playerid] = 1;
  89. case 2: DuelMap[playerid] = 2;
  90. }
  91. new string[256];
  92. format(string, sizeof(string), "Duel-System: {FFFFFF}%s (%d) has invited you to a duel. Usage (/acceptduel <playerid>) to accept it.", GetName(playerid), playerid);
  93. SCM(DuelAccepter[playerid], COLOR_GREY, string);
  94. format(string, sizeof(string), "Duel-System: {FFFFFF}You have invited %s (%d) to a duel.", GetName(DuelAccepter[playerid]), DuelAccepter[playerid]);
  95. SCM(playerid, COLOR_GREY, string);
  96. }
  97. case DIALOG_DUEL_WEAPON:
  98. {
  99. if(!response) return 1;
  100. switch(listitem)
  101. {
  102. case 0:
  103. {
  104. DuelWeapon[playerid] = 0;
  105. ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
  106. }
  107. case 1:
  108. {
  109. DuelWeapon[playerid] = 1;
  110. ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
  111. }
  112. case 2:
  113. {
  114. DuelWeapon[playerid] = 2;
  115. ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
  116. }
  117. case 3:
  118. {
  119. DuelWeapon[playerid] = 3;
  120. ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
  121. }
  122. case 4:
  123. {
  124. DuelWeapon[playerid] = 4;
  125. ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
  126. }
  127.  
  128. }
  129. }
  130. }
  131. return 1;
  132. }
  133.  
  134. //Duel_System
  135. CMD:duel(playerid, params[])
  136. {
  137. if(InDuel[playerid] == 1) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}You are already in a duel.");
  138. new userid;
  139. if(sscanf(params, "u", userid)) return SCM(playerid, COLOR_GREY, "Usage: {FFFFFF}/duel <playerid>");
  140. if(userid == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}Player is not connected.");
  141. DuelInvite[userid] = playerid;
  142. DuelAccepter[playerid] = userid;
  143. if(InDuel[userid] == 1) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}Player is already in a duel.");
  144.  
  145. ShowPlayerDialog(playerid, DIALOG_DUEL_WEAPON, DIALOG_STYLE_LIST, "Duel System [Weapon Select]", "Desert Eagle\nM4\nShotgun\nMP5\nSniper", "Select", "");
  146.  
  147. return 1;
  148. }
  149. CMD:acceptduel(playerid, params[])
  150. {
  151. if(InDuel[playerid] == 1) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}You are already in a duel.");
  152. if(DuelInvite[playerid] == -1)return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}You haven't been invited in a duel.");
  153. if(DuelInvite[playerid] != -1 && DuelInvite[playerid] == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}Player is not connected.");
  154. new userid, string[256];
  155.  
  156. if(sscanf(params, "u", userid)) return SCM(playerid, COLOR_GREY, "Usage: {FFFFFF}/acceptduel <playerid>");
  157.  
  158. if(userid != DuelInvite[playerid] ) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}You haven't been invited to duel by that player.");
  159. userid = DuelInvite[playerid];
  160. DuelInvite[playerid] = userid;
  161. format(string, sizeof(string), "Duel-System: {FFFFFF}%s (%d) has accepted the duel. You are being teleported in the arena.", GetName(playerid), playerid);
  162. SCM(userid, COLOR_GREY, string);
  163. format(string, sizeof(string), "Duel-System: {FFFFFF}You have accepted the duel from %s (%d). You are being teleported in the arena.", GetName(userid), userid);
  164. SCM(playerid, COLOR_GREY, string);
  165. TogglePlayerControllable(playerid, 0);
  166. TogglePlayerControllable(userid, 0);
  167. SetTimer("duelTimer", 4000, false);
  168. GameTextForPlayer(playerid, "BATTLE IS STARTING...", 3000, 3);
  169. GameTextForPlayer(userid, "BATTLE IS STARTING...", 3000, 3);
  170.  
  171. switch(DuelWeapon[userid])
  172. {
  173. case 0:
  174. {
  175. GivePlayerWeapon(playerid, WEAPON_DEAGLE, 1337);
  176. GivePlayerWeapon(DuelInvite[playerid], WEAPON_DEAGLE, 1337);
  177. }
  178. case 1:
  179. {
  180. GivePlayerWeapon(playerid, WEAPON_M4, 1337);
  181. GivePlayerWeapon(DuelInvite[playerid], WEAPON_M4, 1337);
  182. }
  183. case 2:
  184. {
  185. GivePlayerWeapon(playerid, WEAPON_SHOTGUN, 1337);
  186. GivePlayerWeapon(DuelInvite[playerid], WEAPON_SHOTGUN, 1337);
  187. }
  188. case 3:
  189. {
  190. GivePlayerWeapon(playerid, WEAPON_MP5, 1337);
  191. GivePlayerWeapon(DuelInvite[playerid], WEAPON_MP5, 1337);
  192. }
  193. case 4:
  194. {
  195. GivePlayerWeapon(playerid, WEAPON_SNIPER, 1337);
  196. GivePlayerWeapon(DuelInvite[playerid], WEAPON_SNIPER, 1337);
  197. }
  198. }
  199. switch(DuelMap[userid])
  200. {
  201. case 0:
  202. {
  203. SetPlayerPos(playerid, -2319.5796, -1636.9464, 483.7679);
  204. SetPlayerPos(DuelInvite[playerid], -2324.5034, -1623.0521, 483.7335);
  205. }
  206. case 1:
  207. {
  208. SetPlayerInterior(playerid, 7);
  209. SetPlayerPos(playerid, 293.5793, -134.6942, 1004.1299);
  210. SetPlayerInterior(DuelInvite[playerid], 7);
  211. SetPlayerPos(DuelInvite[playerid], 283.1079, -134.7406, 1004.0901);
  212. }
  213. case 2:
  214. {
  215. SetPlayerPos(playerid, 1399.5500, -19.3916, 1000.9594);
  216. SetPlayerPos(DuelInvite[playerid], 1383.6892, -19.3346, 1000.9594);
  217. SetPlayerInterior(playerid, 1);
  218. SetPlayerInterior(DuelInvite[playerid], 1);
  219. }
  220. }
  221. InDuel[playerid] = 1;
  222. InDuel[userid] = 1;
  223. return 1;
  224. }
RAW Paste Data