Guest User

Untitled

a guest
Dec 29th, 2018
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.24 KB | None | 0 0
  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. #define DIALOG_DUEL_BET 3
  18. #define DIALOG_DUEL_INVITE 4
  19.  
  20. //============================================================================//
  21.  
  22. new InDuel[MAX_PLAYERS],
  23. DuelInvite[MAX_PLAYERS],
  24. DuelAccepter[MAX_PLAYERS],
  25. DuelWeapon[MAX_PLAYERS],
  26. DuelMap[MAX_PLAYERS],
  27. DuelBet[MAX_PLAYERS];
  28. #pragma dynamic 145000
  29. //============================================================================//
  30. IsNumeric(const string[])
  31. {
  32. for (new i = 0, j = strlen(string); i < j; i++)
  33. {
  34. if (string[i] > '9' || string[i] < '0') return 0;
  35. }
  36. return 1;
  37. }
  38. FormatNumber(number)
  39. {
  40. new numOfPeriods = 0, tmp = number;
  41. new str[32];
  42. while(tmp > 1000) {
  43. tmp = floatround(tmp / 1000, floatround_floor), ++numOfPeriods;
  44. }
  45. valstr(str, number);
  46. new slen = strlen(str);
  47. for(new i = 1; i != numOfPeriods + 1; ++i) {
  48. strins(str, ",", slen - 3*i);
  49. }
  50. return str;
  51. }
  52. stock GetName(playerid)
  53. {
  54. new szName[MAX_PLAYER_NAME];
  55. GetPlayerName(playerid, szName, sizeof(szName));
  56. return szName;
  57. }
  58. //============================================================================//
  59. main(){printf("Gamemode-ul se proceseaza...");}
  60.  
  61. forward resetDuel(playerid);
  62. public resetDuel(playerid)
  63. {
  64. InDuel[playerid] = 0;
  65. DuelInvite[playerid] = -1;
  66. DuelWeapon[playerid] = -1;
  67. DuelMap[playerid] = -1;
  68. DuelAccepter[playerid] = -1;
  69. return true;
  70. }
  71.  
  72. forward duelTimer(playerid);
  73. public duelTimer(playerid)
  74. {
  75. TogglePlayerControllable(playerid, 1);
  76. TogglePlayerControllable(DuelInvite[playerid], 1);
  77. TogglePlayerControllable(DuelAccepter[playerid], 1);
  78. }
  79. public OnGameModeInit()
  80. {
  81. SetGameModeText("Gamemode Pentru Teste");
  82. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  83. return 1;
  84. }
  85. public OnPlayerRequestClass(playerid, classid)
  86. {
  87. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  88. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  89. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  90. return 1;
  91. }
  92.  
  93. public OnPlayerConnect(playerid)
  94. {
  95. resetDuel(playerid);
  96. GivePlayerMoney(playerid, 500000);
  97. SetSpawnInfo(playerid, 23, 23, 1954.1691, 1343.0311, 15.3712, 90, 0,0,0,0,0,0);
  98. return 1;
  99. }
  100.  
  101. public OnPlayerDeath(playerid, killerid, reason)
  102. {
  103. if(InDuel[playerid] == 1)
  104. {
  105. SpawnPlayer(playerid);
  106. SetPlayerInterior(playerid, 0);
  107. GameTextForPlayer(playerid, "You have lost the duel.", 3000, 3);
  108. GivePlayerMoney(playerid, -DuelBet[playerid]), SCM(playerid, 0xFF7A7AAA, "You have lost the duel and the money");
  109. resetDuel(playerid);
  110. }
  111. if(InDuel[killerid] == 1 && killerid != INVALID_PLAYER_ID)
  112. {
  113. SpawnPlayer(killerid);
  114. SetPlayerInterior(killerid, 0);
  115. GameTextForPlayer(killerid, "You have won the duel.", 3000, 3);
  116. GivePlayerMoney(killerid, DuelBet[playerid]);
  117. SCM(killerid, 0x88FF7AAA, "You have won the duel and the money");
  118. ResetPlayerWeapons(killerid);
  119. resetDuel(killerid);
  120. }
  121. return 1;
  122. }
  123.  
  124. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  125. {
  126. switch(dialogid)
  127. {
  128.  
  129. case DIALOG_DUEL_BET:
  130. {
  131. if(!response) return resetDuel(playerid);
  132. else
  133. {
  134. if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_DUEL_BET, DIALOG_STYLE_INPUT, "Duel System [Bet Select]", "Insert bet amount for duel.\n(bet amount must be > $0 and < $100,000", "Select", "");
  135. if(strval(inputtext) < 0 || strval(inputtext) > 100000) return ShowPlayerDialog(playerid, DIALOG_DUEL_BET, DIALOG_STYLE_INPUT, "Duel System [Bet Select]", "Insert bet amount for duel.\n(bet amount must be > $0 and < $100,000", "Select", "");
  136. if(GetPlayerMoney(playerid) < strval(inputtext)) return ShowPlayerDialog(playerid, DIALOG_DUEL_BET, DIALOG_STYLE_INPUT, "Duel System [Bet Select]", "You don't have the amount inserted.\nInsert bet amount for duel.\n(bet amount must be > $0 and < $100,000", "Select", "");
  137. DuelBet[playerid] = strval(inputtext);
  138. ShowPlayerDialog(playerid, DIALOG_DUEL_WEAPON, DIALOG_STYLE_LIST, "Duel System [Weapon Select]",
  139. "Desert Eagle\nM4\nShotgun\nMP5\nSniper", "Select", "");
  140. }
  141.  
  142. }
  143. case DIALOG_DUEL_MAP:
  144. {
  145. if(!response) return resetDuel(playerid);
  146. switch(listitem)
  147. {
  148. case 0: DuelMap[playerid] = 0;
  149. case 1: DuelMap[playerid] = 1;
  150. case 2: DuelMap[playerid] = 2;
  151. }
  152. new map[56], weapon[56], string[256];
  153. switch(DuelMap[playerid])
  154. {
  155. case 0: format(map, 56, "Chilliad");
  156. case 1: format(map, 56, "Ammunation");
  157. case 2: format(map, 56, "Warehouse");
  158. }
  159. switch(DuelWeapon[playerid])
  160. {
  161. case 0: format(weapon, 56, "Desert Eagle");
  162. case 1: format(weapon, 56, "M4");
  163. case 2: format(weapon, 56, "Shotgun");
  164. case 3: format(weapon, 56, "MP5");
  165. case 4: format(weapon, 56, "Sniper");
  166. }
  167. format(string, sizeof(string), "Duel Invitation sent to: {87ff3d}%s (%d){ffe4a3} | Bet: {87ff3d}%s{ffe4a3} | Weapon: {87ff3d}%s{ffe4a3} | Map: {87ff3d}%s ", GetName(DuelAccepter[playerid]), DuelAccepter[playerid], FormatNumber(DuelBet[playerid]), weapon, map);
  168. SCM(playerid, 0xffe4a3AA, string);
  169. format(string, sizeof(string), "{ffe4a3}Duel Invitation from: {87ff3d}%s (%d){ffe4a3}\nBet Amount: {87ff3d}%s{ffe4a3}\nMap: {87ff3d}%s{ffe4a3}\nWeapon: {87ff3d}%s", GetName(playerid), playerid, FormatNumber(DuelBet[playerid]), map, weapon);
  170. ShowPlayerDialog(DuelAccepter[playerid], DIALOG_DUEL_INVITE, DIALOG_STYLE_MSGBOX, "Duel System [Invitation]", string, "Accept", "Cancel");
  171.  
  172. }
  173. case DIALOG_DUEL_INVITE:
  174. {
  175. if(!response) return resetDuel(playerid);
  176. else
  177. {
  178. new userid = DuelInvite[playerid];
  179. TogglePlayerControllable(playerid, 0);
  180. TogglePlayerControllable(userid, 0);
  181. SetTimer("duelTimer", 4000, false);
  182. GameTextForPlayer(playerid, "BATTLE IS STARTING...", 3000, 3);
  183. GameTextForPlayer(userid, "BATTLE IS STARTING...", 3000, 3);
  184. switch(DuelWeapon[userid])
  185. {
  186. case 0:
  187. {
  188. GivePlayerWeapon(playerid, WEAPON_DEAGLE, 1337);
  189. GivePlayerWeapon(DuelInvite[playerid], WEAPON_DEAGLE, 1337);
  190. }
  191. case 1:
  192. {
  193. GivePlayerWeapon(playerid, WEAPON_M4, 1337);
  194. GivePlayerWeapon(DuelInvite[playerid], WEAPON_M4, 1337);
  195. }
  196. case 2:
  197. {
  198. GivePlayerWeapon(playerid, WEAPON_SHOTGUN, 1337);
  199. GivePlayerWeapon(DuelInvite[playerid], WEAPON_SHOTGUN, 1337);
  200. }
  201. case 3:
  202. {
  203. GivePlayerWeapon(playerid, WEAPON_MP5, 1337);
  204. GivePlayerWeapon(DuelInvite[playerid], WEAPON_MP5, 1337);
  205. }
  206. case 4:
  207. {
  208. GivePlayerWeapon(playerid, WEAPON_SNIPER, 1337);
  209. GivePlayerWeapon(DuelInvite[playerid], WEAPON_SNIPER, 1337);
  210. }
  211. }
  212. switch(DuelMap[userid])
  213. {
  214. case 0:
  215. {
  216. SetPlayerPos(playerid, -2319.5796, -1636.9464, 483.7679);
  217. SetPlayerPos(DuelInvite[playerid], -2324.5034, -1623.0521, 483.7335);
  218. }
  219. case 1:
  220. {
  221. SetPlayerInterior(playerid, 7);
  222. SetPlayerPos(playerid, 293.5793, -134.6942, 1004.1299);
  223. SetPlayerInterior(DuelInvite[playerid], 7);
  224. SetPlayerPos(DuelInvite[playerid], 283.1079, -134.7406, 1004.0901);
  225. }
  226. case 2:
  227. {
  228. SetPlayerPos(playerid, 1399.5500, -19.3916, 1000.9594);
  229. SetPlayerPos(DuelInvite[playerid], 1383.6892, -19.3346, 1000.9594);
  230. SetPlayerInterior(playerid, 1);
  231. SetPlayerInterior(DuelInvite[playerid], 1);
  232. }
  233. }
  234. SetPlayerHealth(playerid, 100);
  235. SetPlayerHealth(userid, 100);
  236. SetPlayerArmour(playerid, 100);
  237. SetPlayerArmour(userid, 100);
  238. InDuel[playerid] = 1;
  239. InDuel[userid] = 1;
  240. }
  241. }
  242. case DIALOG_DUEL_WEAPON:
  243. {
  244. if(!response) return 1;
  245. switch(listitem)
  246. {
  247. case 0:
  248. {
  249. DuelWeapon[playerid] = 0;
  250. ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
  251. }
  252. case 1:
  253. {
  254. DuelWeapon[playerid] = 1;
  255. ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
  256. }
  257. case 2:
  258. {
  259. DuelWeapon[playerid] = 2;
  260. ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
  261. }
  262. case 3:
  263. {
  264. DuelWeapon[playerid] = 3;
  265. ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
  266. }
  267. case 4:
  268. {
  269. DuelWeapon[playerid] = 4;
  270. ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
  271. }
  272.  
  273. }
  274. }
  275. }
  276. return 1;
  277. }
  278. //Comenzi_Publice
  279. //Duel_System
  280. CMD:duel(playerid, params[])
  281. {
  282. if(InDuel[playerid] == 1) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}You are already in a duel.");
  283. new userid;
  284. if(sscanf(params, "u", userid)) return SCM(playerid, COLOR_GREY, "Usage: {FFFFFF}/duel <playerid>");
  285. if(userid == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}Player is not connected.");
  286. DuelInvite[userid] = playerid;
  287. DuelAccepter[playerid] = userid;
  288. if(InDuel[userid] == 1) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}Player is already in a duel.");
  289.  
  290. ShowPlayerDialog(playerid, DIALOG_DUEL_BET, DIALOG_STYLE_INPUT, "Duel System [Bet Select]", "Insert bet amount for duel.\n(bet amount must be > $0 and < $100,000", "Select", "");
  291.  
  292. return 1;
  293. }
Add Comment
Please, Sign In to add comment