carlosxtreme

Untitled

Feb 12th, 2020
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.36 KB | None | 0 0
  1. #include <a_samp>
  2. #define DIALOG_DUEL 24245
  3. new
  4. bool:InvitedDuel[MAX_PLAYERS],
  5. IdDuel[MAX_PLAYERS],
  6. wep1[MAX_PLAYERS],
  7. wep2[MAX_PLAYERS],
  8. bool:UsingArena,
  9. Counting = 5,
  10. CountDueling[5][5] ={"~r~1","~b~2","~p~3","~y~4","~g~5"}
  11. ;
  12. forward ExecuteCount(playerid,pid);
  13. public ExecuteCount(playerid,pid)
  14. {
  15. if (Counting > 0)
  16. {
  17. GameTextForPlayer(playerid,CountDueling[Counting-1], 2500, 3);
  18. GameTextForPlayer(pid,CountDueling[Counting-1], 1000, 3);
  19. Counting--;
  20. SetTimerEx("GoDuel",1000,false,"ii",playerid,pid);
  21. }
  22. else
  23. {
  24. GameTextForPlayer(playerid,"~>~~g~Go~w~Go~r~Go~b~Go~<~", 2500, 3);
  25. GameTextForPlayer(pid,"~>~~g~Go~w~Go~r~Go~b~Go~<~", 2500, 3);
  26. Counting = 5;
  27. TogglePlayerControllable(playerid,true);
  28. TogglePlayerControllable(pid,true);
  29. }
  30. return true;
  31. }
  32.  
  33.  
  34. public OnPlayerCommandText(playerid, cmdtext[])
  35. {
  36. new cmd[128],idx;
  37.  
  38. cmd = strtok(cmdtext, idx);
  39. if(!strcmp("/duel", cmd, true))
  40. {
  41. new id,tmp[3][80],w1,w2,string[128];
  42.  
  43. tmp[0] = strtok(cmdtext, idx);
  44. tmp[1] = strtok(cmdtext, idx);
  45. tmp[2] = strtok(cmdtext, idx);
  46.  
  47. id = strval(tmp[0]);
  48. w1 = strval(tmp[1]);
  49. w2 = strval(tmp[2]);
  50.  
  51. if(InvitedDuel[playerid] == true)
  52. return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Have you invited someone, wait Expire Invitation");
  53.  
  54. if(UsingArena == true)
  55. return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : At the time the Arena is Being Used");
  56.  
  57. if(!IsValidWeapon(w1) || !IsValidWeapon(w2))
  58. return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use Valids Weapons IDs");
  59.  
  60. if(!strlen(tmp[1]) || !strlen(tmp[2]))
  61. return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use /duel [id] [wep1] [wep2]");
  62.  
  63. if(!strlen(tmp[0]))
  64. return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You must enter the ID of the player following the Way (/duel [playerid])");
  65.  
  66. if(id == playerid)
  67. return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You can not invite the Self");
  68.  
  69. if(InvitedDuel[id] == true)
  70. return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Currently the player is in a Duel, wait..");
  71.  
  72. new name[24];
  73. GetPlayerName(playerid, name, sizeof(name));
  74. format(string, sizeof(string), "»»[DUEL]«« : %s This inviting you to a \n Duel Runing (Press Accept to Accept Duel)",name);
  75. ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"»»[DUEL]«« :",string,"Accept", "No");
  76. GameTextForPlayer(id,"~r~DUE~w~LO !", 2500, 3);
  77. IdDuel[id] = playerid;
  78. wep1[id] = w1;
  79. wep2[id] = w2;
  80. SetTimerEx("ExpireDuel",15000,false,"ii",id,playerid);
  81. return true;
  82. }
  83. return false;
  84. }
  85.  
  86.  
  87. forward GoDuel(playerid,pid,w1,w2);
  88. public GoDuel(playerid,pid,w1,w2)
  89. {
  90. //-> Go To X1 <-//
  91. //SetPlayerPos
  92. //SetPlayerArmor
  93. //SetPlayerHealth
  94.  
  95. //-> Functions for Count x1<-//
  96. GivePlayerWeapon(playerid,w1,999999);
  97. GivePlayerWeapon(playerid,w2,999999);
  98. GivePlayerWeapon(pid,w1,999999);
  99. GivePlayerWeapon(pid,w2,999999);
  100. InvitedDuel[playerid] = true;
  101. InvitedDuel[pid] = true;
  102. TogglePlayerControllable(playerid,false);
  103. TogglePlayerControllable(pid,false);
  104. ExecuteCount(playerid,pid);
  105. return true;
  106. }
  107.  
  108.  
  109. forward ExpireDuel(playerid,pid);
  110. public ExpireDuel(playerid,pid)
  111. {
  112. if(UsingArena == false)
  113. {
  114. SendClientMessage(pid,0x1DF6F6AA,"»»[DUEL]«« : Expired challenge, He Refused");
  115. SendClientMessage(playerid,0x1DF6F6AA,"»»[DUEL]«« : Expired challenge, you automatically refuse");
  116. InvitedDuel[pid] = false;
  117. InvitedDuel[playerid] = false;
  118. IdDuel[playerid] = playerid;
  119. IdDuel[pid] = pid;
  120. }
  121. return true;
  122. }
  123.  
  124.  
  125. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  126. {
  127. if(dialogid == DIALOG_DUEL)
  128. {
  129. if(!response) return ExpireDuel(playerid,IdDuel[playerid]);
  130. if(response)
  131. {
  132. UsingArena = true;
  133. new name[MAX_PLAYER_NAME], string[44];
  134. GetPlayerName(playerid, name, sizeof(name));
  135. format(string, sizeof(string), "»»[DUEL]«« : %s accepted the challenge, wait 8 seconds to go to Duel.",name);
  136. SendClientMessage(IdDuel[playerid],0xF6F600AA,string);
  137. SendClientMessage(playerid,0xF6F600AA,"»»[DUEL]«« : You accepted the Duel Wait 8 seconds to process your Data");
  138. SetTimerEx("GoDuel",8000,false,"ii",playerid,IdDuel[playerid],wep1[playerid],wep2[playerid]);
  139. }
  140. return true;
  141. }
  142. return true;
  143. }
  144.  
  145. public OnPlayerDisconnect(playerid,reason)
  146. {
  147. if(InvitedDuel[playerid] == true)
  148. {
  149. for(new killerid; killerid < MAX_PLAYERS; killerid++) if(IsPlayerConnected(killerid) && InvitedDuel[killerid] == true)
  150. {
  151. new Float:healthkiller;
  152. new namekiller[24],namedeather[24],string[44];
  153. GetPlayerName(killerid, namekiller, 24);
  154. GetPlayerName(playerid, namedeather, 24);
  155. GetPlayerHealth(killerid,healthkiller);
  156. format(string, sizeof(string), "»»[DUELO]«« : %s Wins Duel of %s how %0.0f off Armour and Health",namekiller,namedeather,healthkiller);
  157. SendClientMessageToAll(0xF600F6AA, string);
  158. InvitedDuel[killerid] = false;
  159. InvitedDuel[playerid] = false;
  160. IdDuel[playerid] = playerid;
  161. IdDuel[killerid] = killerid;
  162. UsingArena = false;
  163. healthkiller = 0;
  164. SpawnPlayer(killerid);
  165. }
  166. }
  167. return true;
  168. }
  169. public OnPlayerDeath(playerid, killerid, reason)
  170. {
  171. if(InvitedDuel[killerid] == true)
  172. {
  173. new Float:healthkiller;
  174. new namekiller[24],namedeather[24],string[44];
  175. GetPlayerName(killerid, namekiller, 24);
  176. GetPlayerName(playerid, namedeather, 24);
  177. GetPlayerHealth(killerid,healthkiller);
  178. format(string, sizeof(string), "»»[DUELO]«« : %s Wins Duel of %s how %0.0f off Armour and Health",namekiller,namedeather,healthkiller);
  179. SendClientMessageToAll(0xF600F6AA, string);
  180. InvitedDuel[killerid] = false;
  181. InvitedDuel[playerid] = false;
  182. IdDuel[playerid] = playerid;
  183. IdDuel[killerid] = killerid;
  184. UsingArena = false;
  185. healthkiller = 0;
  186. SpawnPlayer(killerid);
  187. }
  188. return true;
  189. }
  190.  
  191. IsValidWeapon(weaponid)
  192. {
  193. new badWeapon[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 40, 44, 45, 46};
  194. for(new i=0; i <20; i++)
  195. if (weaponid == badWeapon[i])
  196. return false;
  197. return true;
  198. }
  199.  
  200.  
  201. strtok(const string[], &index)
  202. {
  203. new length = strlen(string);
  204. while ((index < length) && (string[index] <= ' '))
  205. {
  206. index++;
  207. }
  208. new offset = index;
  209. new result[20];
  210. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  211. {
  212. result[index - offset] = string[index];
  213. index++;
  214. }
  215. result[index - offset] = EOS;
  216. return result;
  217. }
Advertisement
Add Comment
Please, Sign In to add comment