Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.00 KB | None | 0 0
  1. str ValueTable[71] = {
  2. "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
  3. "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
  4. "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", " ", ",", ".", "!", "(", ")", "?", "-", "'"
  5. };
  6.  
  7. // Gets sent to server, the optional parameters for the server call
  8. str BTechCallParams = "";
  9.  
  10. // Response parameter buffer read from server's response
  11. str ReceiveParam[1024] = {
  12. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  13. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  14. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  15. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  16. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  17. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  18. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  19. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  20. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  21. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  22. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00"
  23. };
  24.  
  25. // Response callback function name buffer read from server's response
  26. str ReceiveCallbackName[1024] = {
  27. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  28. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  29. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  30. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  31. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  32. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  33. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  34. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  35. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  36. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00",
  37. "00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00"
  38. };
  39.  
  40. // Send function call to server
  41. function void BTech_Call(str FunctionName) {
  42. str start = "btechjson{'_call':'";
  43. str FNameEnd = "'";
  44. str End = "}";
  45. str send = StrParam(s: start, s: FunctionName, s: FNameEnd, s: BTechCallParams , s: end);
  46.  
  47. BTechCallParams = "";
  48. Server_NamedExecute(send);
  49. }
  50.  
  51. // Add string parameter to function call (to server)
  52. function void BTech_AddParamStr (str key, str value) {
  53. BTechCallParams = StrParam(s:BTechCallParams , s: ",", s: "'", s: key, s: "'", s:":", s: "'", s: value, s: "'");
  54. }
  55.  
  56. // Add integer parameter to function call (to server)
  57. function void BTech_AddParamInt (str key, str value) {
  58. BTechCallParams = StrParam(s:BTechCallParams , s: ",", s: "'", s: key, s: "'", s:":", d: value);
  59. }
  60.  
  61. // Set a callback for when the server executes the requested function
  62. function void BTech_SetClientCallback (str FunctionName, int PlayerNum) {
  63. BTechCallParams = StrParam(s:BTechCallParams , s: ",", s: "'", s: "_callback", s: "'", s:":", s: "'", s: FunctionName, s: "'");
  64. BTechCallParams = StrParam(s:BTechCallParams , s: ",", s: "'", s: "_clientId", s: "'", s:":", d: PlayerNum);
  65. }
  66.  
  67. // Processing the param response from server
  68. script "BTech_TransmitParam" (int position, int letter) {
  69. if (letter != 0) {
  70. ReceiveParam[position] = ValueTable[letter-1];
  71. }
  72. }
  73.  
  74. // Processing the callback name response from server
  75. script "BTech_TransmitCallbackName" (int position, int letter) {
  76. if (letter != 0) {
  77. ReceiveCallbackName[position] = ValueTable[letter-1];
  78. }
  79. //Log(s: "Transmitting..");
  80. //Log(s: "position: ", d: position);
  81. //Log(s: "letter: ", s: ValueTable[letter-1]);
  82. //Log(s: "--------------");
  83. }
  84.  
  85. // Receieve parameter reading in
  86. script "BTech_ReceiveParamBufferer" (int clientId, int position, int letter) {
  87. Client_NamedExecute(clientId, "BTech_TransmitParam", 0, position, letter);
  88. }
  89.  
  90. // Receieve callback function name reading in
  91. script "BTech_ReceiveCallbackNameBuferer" (int clientId, int position, int letter) {
  92. Client_NamedExecuteAlways(clientId, "BTech_TransmitCallbackName", 0, position, letter);
  93. }
  94.  
  95. // FAKE Call callback function. Calls the REAL one.
  96. script "BTech_FakeCallClientScript" (int clientId) {
  97. Client_NamedExecuteAlways(clientId, "BTech_RealCallClientScript", 0, clientId);
  98. }
  99.  
  100. // REAL Call callback function
  101. script "BTech_RealCallClientScript" (int clientId) {
  102. Client_NamedExecuteAlways(clientId, GetCallbackName());
  103. }
  104.  
  105. // Cleaning up buffers and temporary call data
  106. // THIS MUST BE CALLED AFTER EVERY CALLBACK FUNCTION EXEUCTION!
  107. function void CBEND (void) {
  108. for (int i = 0; i < 1024; i++) {
  109. ReceiveParam[i] = "00";
  110. ReceiveCallbackName[i] = "00";
  111. }
  112. }
  113.  
  114. // Put together the callback function parameter (created for the callback function itself)
  115. function str GetParam (void) {
  116. str param = "";
  117.  
  118. for (int i = 0; i < 1024; i++) {
  119. if (ReceiveParam[i] == "00") {
  120. break;
  121. }
  122.  
  123. param = StrParam(s: param, s: ReceiveParam[i]);
  124. }
  125.  
  126. return param;
  127. }
  128.  
  129. // Put together the callback function name
  130. function str GetCallbackName (void) {
  131. str CallbackName = "";
  132.  
  133. for (int i = 0; i < 1024; i++) {
  134. if (ReceiveCallbackName[i] == "00") {
  135. break;
  136. }
  137.  
  138. CallbackName = StrParam(s: CallbackName, s: ReceiveCallbackName[i]);
  139. }
  140.  
  141. return CallbackName;
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement