Advertisement
Guest User

Untitled

a guest
Feb 8th, 2013
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. /* @KEY BIND INGAME - SAMP
  2. @BY DARKZEROX
  3. */
  4. #include <a_samp>
  5. #define NO_MESSAGE "no message"
  6.  
  7.  
  8. new KeyBindActif[MAX_PLAYERS];
  9. new string[500];
  10. new gString[500];
  11. new ItemKey[MAX_PLAYERS];
  12. new Nom[25];
  13.  
  14. enum KeyBind
  15. {
  16. Message[250],
  17. Key
  18. }
  19. new KBT[MAX_PLAYERS][5][KeyBind];
  20.  
  21. public OnFilterScriptInit()
  22. {
  23. print("\n--------------------------------------");
  24. print("[Ouverture du Key Bind]");
  25. print("--------------------------------------\n");
  26. return 1;
  27. }
  28.  
  29.  
  30. public OnPlayerCommandText(playerid, cmdtext[])
  31. {
  32. if (strcmp("/key", cmdtext, true, 10) == 0)
  33. {
  34. DialogueKeyBind(playerid);
  35. return 1;
  36. }
  37. return 1;
  38. }
  39.  
  40.  
  41. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  42. {
  43. if(dialogid == 1)
  44. {
  45. if(!response) return 1;
  46. if(KeyBindActif[playerid] == 0)
  47. {
  48. KeyBindActif[playerid] = 1;
  49. DialogueKeyBind(playerid);
  50. return 1;
  51. }
  52. if(listitem == 0) return 1;
  53. ItemKey[playerid] = listitem;
  54. if(KBT[playerid][listitem][Key] == 0)
  55. ShowPlayerDialog(playerid,2, DIALOG_STYLE_INPUT, "{33AA33}KeyBind","Enter the desired message", "Next", "Cancel");
  56. else
  57. ShowPlayerDialog(playerid,2, DIALOG_STYLE_INPUT, "{33AA33}KeyBind","Enter the desired message", "Next", "Cancel");
  58. return 1;
  59. }
  60. if(dialogid == 2)
  61. {
  62. strmid(KBT[playerid][ItemKey[playerid]][Message],inputtext, 0, strlen(inputtext), 250);
  63. if(ItemKey[playerid] == 1)
  64. KBT[playerid][ItemKey[playerid]][Key] = 2;
  65. if(ItemKey[playerid] == 2)
  66. KBT[playerid][ItemKey[playerid]][Key] = 4;
  67. if(ItemKey[playerid] == 3)
  68. KBT[playerid][ItemKey[playerid]][Key] = 6;
  69. if(ItemKey[playerid] == 4)
  70. KBT[playerid][ItemKey[playerid]][Key] = 8;
  71. DialogueKeyBind(playerid);
  72. return 1;
  73. }
  74. return 1;
  75. }
  76.  
  77.  
  78. stock DialogueKeyBind(playerid)
  79. {
  80.  
  81. if(KeyBindActif[playerid] == 0)
  82. {
  83. ShowPlayerDialog(playerid,1, DIALOG_STYLE_LIST, "{33AA33}KeyBind","Click to activate the keybind", "Ok", "Cancel");
  84. return 1;
  85. }
  86. else
  87. {
  88. gString = "";
  89. string = "";
  90. for(new i = 0; i < 6; i++)
  91. {
  92. if(KBT[playerid][i][Key] == 0)
  93. format(string, 64, NO_MESSAGE);
  94. else
  95. format(string, 64, "{FF0000}Key : %d\tMessage : %s",KBT[playerid][i][Key],KBT[playerid][i][Message]);
  96. format(gString, sizeof(gString), "%s%s\n", gString, string);
  97. ShowPlayerDialog(playerid,1, DIALOG_STYLE_LIST, "{33AA33}KeyBind",gString, "Next", "Cancel");
  98. }
  99. return 1;
  100. }
  101. return 1;
  102. }
  103.  
  104. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  105. {
  106. if (newkeys == 512)
  107. {
  108. if (!IsPlayerInAnyVehicle(playerid))
  109. {
  110. if(KBT[playerid][1][Message] != 0)
  111. {
  112. GetPlayerName(playerid,Nom, sizeof(Nom));
  113. format(string, 64, "%s : %s",Nom,KBT[playerid][1][Message]);
  114. SendClientMessageToAll(-1,string);
  115. }
  116. }
  117. }
  118. if (newkeys == 8192)
  119. {
  120. if (!IsPlayerInAnyVehicle(playerid))
  121. {
  122. if(KBT[playerid][2][Message] != 0)
  123. {
  124. GetPlayerName(playerid,Nom, sizeof(Nom));
  125. format(string, 64, "%s : %s",Nom,KBT[playerid][2][Message]);
  126. SendClientMessageToAll(-1,string);
  127. }
  128. }
  129. }
  130. if (newkeys == 16384)
  131. {
  132. if (!IsPlayerInAnyVehicle(playerid))
  133. {
  134. if(KBT[playerid][3][Message] != 0)
  135. {
  136. GetPlayerName(playerid,Nom, sizeof(Nom));
  137. format(string, 64, "%s : %s",Nom,KBT[playerid][3][Message]);
  138. SendClientMessageToAll(-1,string);
  139. }
  140. }
  141. }
  142. if (newkeys == 2048)
  143. {
  144. if (!IsPlayerInAnyVehicle(playerid))
  145. {
  146. if(KBT[playerid][4][Message] != 0)
  147. {
  148. GetPlayerName(playerid,Nom, sizeof(Nom));
  149. format(string, 64, "%s : %s",Nom,KBT[playerid][4][Message]);
  150. SendClientMessageToAll(-1,string);
  151. }
  152. }
  153. }
  154. return 1;
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement