Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PT_APPENDCHAR 1
- #define PT_WRITEINT 2
- str stringArray[INT_MAX];
- int intArray[INT_MAX];
- script acsnetutils_listener (int packet, int data, int data2)
- {
- switch(packet)
- {
- case PT_APPENDCHAR:
- // create new string
- if (!stringArray[data2])
- stringArray[data2] = NULL;
- StrAddChar(stringArray[data2], data);
- break;
- case PT_WRITEINT:
- intArray[data2] = data;
- break;
- }
- }
- function void Puke(int s, int arg1, int arg2, int arg3)
- {
- str command = "puke ";
- StrAddInt(command, s);
- StrAdd(command, " ");
- StrAddInt(command, arg1);
- StrAdd(command, " ");
- StrAddInt(command, arg2);
- StrAdd(command, " ");
- StrAddInt(command, arg3);
- ConsoleCommand(command);
- }
- function void NetWriteString(str string, int id)
- {
- int i;
- if (IsClient())
- {
- for (i = 0; i < strlen(string); i++)
- {
- Puke(acsnetutils_listener, PT_APPENDCHAR, GetChar(string, i), id);
- }
- }
- else
- {
- for (i = 0; i < strlen(string); i++)
- {
- ACS_ExecuteWithResult(acsnetutils_listener, PT_APPENDCHAR, GetChar(string, i), id);
- }
- }
- }
- function void NetWriteInt(int integer, int id)
- {
- if (IsClient())
- {
- Puke(acsnetutils_listener, PT_WRITEINT, integer, id);
- }
- else
- {
- ACS_ExecuteWithResult(acsnetutils_listener, PT_WRITEINT, integer, id);
- }
- }
- function str NetReadString(int id)
- {
- int result = stringArray[id];
- stringArray[id] = 0;
- return result;
- }
- function int NetReadInt(int id)
- {
- int result = intArray[id];
- intArray[id] = 0;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement