Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1.  
  2. #define PT_APPENDCHAR 1
  3. #define PT_WRITEINT 2
  4.  
  5. str stringArray[INT_MAX];
  6. int intArray[INT_MAX];
  7.  
  8. script acsnetutils_listener (int packet, int data, int data2)
  9. {
  10.     switch(packet)
  11.     {
  12.     case PT_APPENDCHAR:
  13.         // create new string
  14.         if (!stringArray[data2])
  15.             stringArray[data2] = NULL;
  16.  
  17.         StrAddChar(stringArray[data2], data);
  18.         break;
  19.     case PT_WRITEINT:
  20.         intArray[data2] = data;
  21.         break;
  22.     }
  23. }
  24.  
  25. function void Puke(int s, int arg1, int arg2, int arg3)
  26. {
  27.     str command = "puke ";
  28.     StrAddInt(command, s);
  29.     StrAdd(command, " ");
  30.     StrAddInt(command, arg1);
  31.     StrAdd(command, " ");
  32.     StrAddInt(command, arg2);
  33.     StrAdd(command, " ");
  34.     StrAddInt(command, arg3);
  35.     ConsoleCommand(command);
  36. }
  37.  
  38. function void NetWriteString(str string, int id)
  39. {
  40.     int i;
  41.     if (IsClient())
  42.     {
  43.         for (i = 0; i < strlen(string); i++)
  44.         {
  45.             Puke(acsnetutils_listener, PT_APPENDCHAR, GetChar(string, i), id);
  46.         }
  47.     }
  48.     else
  49.     {
  50.         for (i = 0; i < strlen(string); i++)
  51.         {
  52.             ACS_ExecuteWithResult(acsnetutils_listener, PT_APPENDCHAR, GetChar(string, i), id);
  53.         }
  54.     }
  55. }
  56.  
  57. function void NetWriteInt(int integer, int id)
  58. {
  59.     if (IsClient())
  60.     {
  61.         Puke(acsnetutils_listener, PT_WRITEINT, integer, id);
  62.     }
  63.     else
  64.     {
  65.         ACS_ExecuteWithResult(acsnetutils_listener, PT_WRITEINT, integer, id);
  66.     }
  67. }
  68.  
  69. function str NetReadString(int id)
  70. {
  71.     int result = stringArray[id];
  72.     stringArray[id] = 0;
  73.     return result;
  74. }
  75.  
  76. function int NetReadInt(int id)
  77. {
  78.     int result = intArray[id];
  79.     intArray[id] = 0;
  80.     return result;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement