`````````````````````````````````````````````````````````````````````````````
`///////////////////////////////////////////////////////////////////////////`
`/ /`
`/ 888b 88 88888888888 888888888888 88 88 88888888ba /`
`/ 8888b 88 88 88 88 88 88 "8b /`
`/ 88 `8b 88 88 88 88 88 ,8P /`
`/ 88 `8b 88 88aaaaa 88 88 v2.0 88 88aaaaaa8P' /`
`/ 88 `8b 88 88""""" 88 88 88 88""""""8b, /`
`/ 88 `8b 88 88 88 88 88 88 `8b /`
`/ 88 `8888 88 88 88 88 88 a8P /`
`/ 88 `888 88888888888 88 88888888888 88 88888888P" /`
`/ /`
`///////////////////////////////////////////////////////////////////////////`
`/`````````````````````````````````````````````````````````````````````````/`
`/ By Adam "RUCCUS" Eisfeld /`
`/ Updated: Dec 2nd, 2007. 12:51 PM EST /`
`/ Requires: Multisync V1.0, DBP V5.4 /`
`///////////////////////////////////////////////////////////////////////////`
`/`````````````````````````````````````````````````````````````````````````/`
`/ Instructions: /`
`/ 1. Include network library in project /`
`/ 2. Call net_start() to run the default connection wizard, or call /`
`/ net_connect() to manually connect. /`
`/ 3. Call net_recieve(), net_send(), and net_update constantly each loop. /`
`/ Or call net_handle each loop. /`
`///////////////////////////////////////////////////////////////////////////`
`/`````````````````````````````````````````````````````````````````````````/`
`/ Usage: /`
`/ - Place any important init / login data in the LOGIN PACKET sent to /`
`/ connecting clients in the net_recieve function. /`
`/ - Place any data that must constantly be sent each loop in the net_send /`
`/ function. /` /`
`/ - Any processing code that the host does on user-recieved data can be /`
`/ placed in a net_process() /`
`/ function that goes between the net_recieve() and net_send() functions /`
`/ in the main loop. /`
`///////////////////////////////////////////////////////////////////////////`
`/`````````````````````````````````````````````````````````````````````````/`
`/ Network Variables: /`
`/ - players: Current number of connected (logged-in) players (players /`
`/ merging with network are excluded) /`
`/ - maxplayers: Maximum number of players allowed to connect to the /`
`/ session /`
`/ - packetdelay: Delay in seconds between data transfer. (Recommended /`
`/ at least 0.05s). /`
`/ - debug: Set this manually via the UDT to 1. /`
`/ See the Debug section below or the help files /`
`/ at the bottom of the page for more information. /`
`///////////////////////////////////////////////////////////////////////////`
`/`````````````````````````````````````````````````````````````````````````/`
`/ Network Connection Constants: /`
`/ - IS_DISCONNECTED : The user isn't in the current game. Users with a /`
`/ connection of this type are automatically removed /`
`/ from the players list in the next loop. /`
`/ - IS_CONNECTED : The user is connected to the game, but has not /`
`/ logged in yet. (Awaiting merge) /`
`/ - IS_LOGGED_IN : The user is included in the players list, and has /`
`/ successfully logged into the session. /`
`/ - NOTE : To kick a user, set their connection to /`
`/ IS_DISCONNECTED on the server-side, or call the /`
`/ net_kick() function, with the user's ID number. /`
`///////////////////////////////////////////////////////////////////////////`
`/`````````````````````````````````````````````````````````````````````````/`
`/ Packets: /`
`/ - There are 5 default packet types that should work for most if not all /`
`/ possible packet requirements. They are described below: /`
`/ /`
`/ 1. PACKET_LOGIN: This packet is sent from a connecting client /`
`/ to the server containing any initial client /`
`/ information (user name, character choice, etc.) /`
`/ /`
`/ 2. PACKET_SETUP: This packet is sent from the server back to the /`
`/ connecting client that previously sent the /`
`/ PACKET_LOGIN packet. It contains any initial /`
`/ network data the client requires to log in with /`
`/ (game settings, current player kills, etc). /`
`/ /`
`/ 3. PACKET_DATA: This packet is sent between the client and server. /`
`/ Each client sends the packet to the server /`
`/ individually, the server recieves the packet, and /`
`/ passes it on to the other clients. Place any /`
`/ information that all clients need in this packet /`
`/ (chat messages, a client's current weapon, etc. ) /`
`/ /`
`/ 4 . PACKET_INFO: This packet contains data obtained by the host, /`
`/ that all clients require. Things like player IP's, /`
`/ updated positions if you're processing positions /`
`/ based on key-presses on the server-side, etc. /`
`/ /`
`/ 5. PACKET_PROCESS: This packet holds any data obtained by the client, /`
`/ that the host needs to process and send back out /`
`/ via PACKET_INFO. (For example, clients could send /`
`/ a byte of data representing their current key /`
`/ being pressed. The host recieves the process packet,/`
`/ checks if the key is the upkey, and if so /`
`/ moves the client's object forward. The host then /`
`/ sends the player's updated position back out to the /`
`/ other clients via packet_info. /`
`///////////////////////////////////////////////////////////////////////////`
`/`````````````````````````````````````````````````````````````````````````/`
`/ Debugging: /`
`/ /`
`/ Set net.debug to 1 to active the debugger, and back to 0 to deactive./`
`/ When activated, all net events are recorded in a dynamic /`
`/ array called debug() as strings of text, in /`
`/ chronological order. The events are in a UDT in the array /`
`/ called event$. debug_output() is a helper function that /`
`/ can be called anywhere to print the debug information /`
`/ to the screen as it occurs. This function also takes /`
`/ care of activating the debugger so setting net.debug to /`
`/ 1 is not required. 2 other debug functions are provided; /`
`/ debug_getEvent() and debug_clearEvents /`
`/ /`
`/ Calling debug_save() will export the current debug array /`
`/ as a .debug file in the specified directory, with the specified name /`
`/ (defaults to appname_xx.debug in the current directory). These files /`
`/ can be opened in Notepad or any text editor, and read back in with /`
`/ the file commands. /`
`/ /`
`/ One other command the debug functions use on their own; /`
`/ debug_addEvent(), can also be called manually to add events to the /`
`/ debug list. This commands allows you to use the debug command-set /`
`/ for any future projects. /`
`/ /`
`/ Finally, debug_clearFiles() can be called at any time to delete all /`
`/ files in the specified directory that have a .debug extension. /`
`///////////////////////////////////////////////////////////////////////////`
`/`````````````````````````````````````````````````````````````````````````/`
`/ Help Files: /`
`/ /`
`/ A complete list of all functions in this library can be found at the /`
`/ bottom of this page, where an explanation along with syntax, example /`
`/ usage, and more, is given for each function. /`
`/ /`
`///////////////////////////////////////////////////////////////////////////`
````````````````````````````````````````
``````CONSTANTS`````````````````````````
````````````````````````````````````````
#CONSTANT PACKET_LOGIN = 1
#CONSTANT PACKET_SETUP = 2
#CONSTANT PACKET_DATA = 3
#CONSTANT PACKET_INFO = 4
#CONSTANT PACKET_PROCESS = 5
#CONSTANT IS_DISCONNECTED = -1
#CONSTANT IS_CONNECTED = 1
#CONSTANT IS_LOGGED_IN = 2
````````````````````````````````````````
``````UDT's / VARIABLES`````````````````
````````````````````````````````````````
TYPE net
players, maxplayers
packettime#, packetdelay#
debug
ENDTYPE
GLOBAL net AS net
TYPE players
ID, connection
msg$, IP$
ENDTYPE
TYPE usr
ID, connection
status$, msg$
ENDTYPE
GLOBAL usr AS usr
TYPE debug
event$
ENDTYPE
````````````````````````````````````````
``````FUNCTIONS`````````````````````````
````````````````````````````````````````
`````````````````````````
```````````net_``````````
`````````````````````````
``Net Start: Gathers user input and begins network connection
FUNCTION net_start()
SET WINDOW ON
PRINT ""
PRINT "NETLIB 2.0 - By Adam 'RUCCUS' Eisfeld"
PRINT ""
INPUT "Host or Client (H/C): ",usr.status$
INPUT "IP Address: ",IP$
usr.status$ = UPPER$(usr.status$)
IF usr.status$ = "H" THEN INPUT "Max Players: ", net.maxplayers
net_connect(IP$,usr.status$,net.maxplayers)
ENDFUNCTION
``Net Init: Initializes Network Data
FUNCTION net_init()
net.packetdelay# = 0.05
DIM players(0) AS players
DIM debug(0) AS debug
ENDFUNCTION
``Net Enable: Enables application from Windows Firewall
FUNCTION net_enable()
debug_addEvent("Enabling Firewall...")
IF NET FIREWALL ENABLED()
debug_addEvent("Windows Firewall -- Enabled")
IF NOT NET FIREWALL APPLICATION ENABLED(APPNAME$())
IF NET FIREWALL ENABLE APPLICATION(APPNAME$(),APPNAME$())
debug_addEvent("Application -- Enabled")
ELSE
debug_addEvent("Application -- Failed")
ENDIF
ELSE
debug_addEvent("Application -- Previously Enabled")
ENDIF
ELSE
debug_addEvent("Windows Firewall -- Disabled")
ENDIF
ENDFUNCTION
``Net Connect: Attempts to connect to or host the application.
FUNCTION net_connect(IP$,status$,maxplayers)
net_init()
net_enable()
debug_addEvent("Attemping to connect... ")
IF status$ = "C"
connected = NET CONNECT(IP$)
IF NOT connected THEN debug_addEvent("Failed to join server: "+NET GET ERROR()):WAIT KEY:END
debug_addEvent("Merging with network...")
net_merge()
ELSE
connected = NET HOST(net.maxplayers)
plr_create(1)
usr.connection = IS_LOGGED_IN
players(1).connection = IS_LOGGED_IN
IF NOT connected THEN debug_addEvent("Failed to host server: "+NET GET ERROR()):WAIT KEY:END
ENDIF
debug_addEvent("Connection Established.")
ENDFUNCTION
``Net Merge: Gathers all initial information for the connecting client before letting the client into the main loop.
FUNCTION net_merge()
NET PUT BYTE PACKET_LOGIN
NET SEND 1
REPEAT
net_recieve()
UNTIL usr.connection = IS_LOGGED_IN
debug_addEvent("Merge Complete.")
ENDFUNCTION
``Net Recieve: Recieves any information.
FUNCTION net_recieve()
WHILE NET GET MESSAGE()
SELECT NET GET BYTE()
IF usr.connection = IS_LOGGED_IN
CASE PACKET_DATA:
WHILE NET GET MESSAGE REMAINDER()
ID = NET GET BYTE()
IF plr_exist(ID)
index = plr_IDtoIndex(ID)
players(index).connection = NET GET BYTE()
players(index).msg$ = NET GET STRING()
ENDIF
ENDWHILE
ENDCASE
CASE PACKET_INFO:
ID = NET GET BYTE()
index = plr_IDtoIndex(ID)
players(index).IP$ = NET GET STRING()
ENDCASE
CASE PACKET_PROCESS:
ID = NET GET BYTE()
index = plr_IDtoIndex(ID)
ENDCASE
ENDIF
CASE PACKET_LOGIN:
ID = NET MESSAGE FROM()
NET PUT BYTE PACKET_SETUP
NET PUT BYTE ID
FOR p = 1 TO net.players
NET PUT BYTE players(p).ID
NEXT p
NET SEND ID
plr_create(ID)
ENDCASE
CASE PACKET_SETUP:
usr.ID = NET GET BYTE()
WHILE NET GET MESSAGE REMAINDER()
plr_create(NET GET BYTE())
ENDWHILE
plr_create(usr.ID)
usr.connection = IS_LOGGED_IN
ENDCASE
ENDSELECT
ENDWHILE
ENDFUNCTION
``Net Process: Process / Evaluate user-recieved data on the server-side and client-side.
FUNCTION net_process()
FOR p = 1 TO net.players
IF usr.status$ = "H"
//edit player information here, server-side.
ELSE
//edit player information here, client-side.
ENDIF
//edit player information here, client / server - side.
NEXT p
ENDFUNCTION
``Net Send: Sends all relevant data to the host and clients.
FUNCTION net_send()
IF (TIMER()-net.packettime#) / 1000 >= net.packetdelay#
net.packettime# = TIMER()
IF net.players > 1
IF usr.status$ = "H"
FOR p = 1 TO net.players
//Put all data that needs to be sent from clients, through the host,
//to the other clients, in packet data.
//Things like chat messages.
NET PUT BYTE PACKET_DATA
NET PUT BYTE players(p).ID
NET PUT BYTE players(p).connection
NET PUT STRING players(p).msg$
NET SEND ALL
//Put all data that is obtained by the host that the clients require,
//in packet info. (Updated positions, health, kill stats, IP addresses,
// etc.)
NET PUT BYTE PACKET_INFO
NET PUT BYTE players(p).ID
NET SEND ALL
NEXT p
ELSE
NET PUT BYTE PACKET_DATA
NET PUT BYTE usr.ID
NET PUT BYTE players(usr.ID).connection
NET PUT STRING usr.msg$
NET SEND
//Put all data that clients send to the host to be processed, but not sent
//directly back, in packet process.
NET PUT BYTE PACKET_PROCESS
NET PUT BYTE usr.ID
NET SEND
ENDIF
ENDIF
ENDIF
ENDFUNCTION
``Net Send All Except: Sends the last pushed data to all users except ID.
FUNCTION net_sendallexcept(ID)
FOR p = 1 TO net.players
IF p <> ID THEN NET SEND p
NEXT p
ENDFUNCTION
``Net Update: Updates any relevant information, clears buffers, removes disconnected players, etc.
FUNCTION net_update()
IF usr.status$ = "H"
in = NET PLAYER JOINED()
out = NET PLAYER LEFT()
IF in
debug_addEvent("Player joined session.")
ENDIF
IF out
debug_addEvent("Player left session.")
plr_delete(out)
ENDIF
ELSE
IF NET CONNECTED() = 0
debug_addEvent("Connection lost: " + NET GET ERROR())
ENDIF
ENDIF
IF usr.connection = IS_LOGGED_IN THEN plr_cleanup()
ENDFUNCTION
``Net Handle: Handles the 4 main net functions.
FUNCTION net_handle()
net_recieve()
net_process()
net_send()
net_update()
ENDFUNCTION
``Net Kick: Removes player from the game
FUNCTION net_kick(ID)
NET KICK ID
ENDFUNCTION
`````````````````````````
```````````plr_``````````
`````````````````````````
``Plr Create: Adds the player's ID to the player array, and updates net.players.
FUNCTION plr_create(ID)
INC net.players
ARRAY INSERT AT BOTTOM players(0)
players(net.players).ID = ID
ENDFUNCTION
``Plr Delete: Removes the player ID from the player list.
FUNCTION plr_delete(ID)
index = plr_IDtoIndex(ID)
players(index).connection = IS_DISCONNECTED
ENDFUNCTION
``Plr CleanUp: Removes any disconnected players from the players array
FUNCTION plr_cleanup()
FOR p = 1 TO net.players
IF net.players = ARRAY COUNT(players(0))
IF players(p).connection = IS_DISCONNECTED
ARRAY DELETE ELEMENT players(0),p
p = 0
INC total
ENDIF
ENDIF
NEXT p
DEC net.players, total
ENDFUNCTION
``Plr Exist: Returns 1 if the player's ID exists
FUNCTION plr_exist(ID)
FOR p = 1 TO net.players
IF players(p).ID = ID
retval = 1
EXIT
ENDIF
NEXT p
ENDFUNCTION retval
``Plr IDtoIndex: Converts an ID to an array index for the players array
FUNCTION plr_IDtoIndex(ID)
FOR p = 1 TO net.players
IF players(p).ID = ID
retval = p
EXIT
ENDIF
NEXT p
ENDFUNCTION retval
`````````````````````````
```````````debug_````````
`````````````````````````
``Debug Output: Outputs debug array to screen via print. Set removeWhenDisplayed
` to 1 to remove the event from the debug array after printing it.
FUNCTION debug_output(removeWhenDisplayed)
FOR e = 1 TO ARRAY COUNT(debug())
PRINT debug_getOldestEvent(removeWhenDisplayed)
e = 1
NEXT e
ENDFUNCTION
``Debug Add Event: Adds event$ to the debug array.
FUNCTION debug_addEvent(event$)
ARRAY INSERT AT BOTTOM debug()
index = ARRAY COUNT(debug())
debug(index).event$ = event$
ENDFUNCTION
``Debug Get Last Event: Gets the most recent event, set removeWhenGiven to 1 to delete
` the event from the debug array after returning it.
FUNCTION debug_getLastEvent(removeWhenGiven)
ret$ = debug(ARRAY COUNT(debug())).event$
IF removeWhenGiven THEN ARRAY DELETE ELEMENT debug(), ARRAY COUNT(debug())
ENDFUNCTION ret$
``Debug Get Oldest Event: Gets the oldest event, set removeWhenGiven to 1 to
` delete the event from the debug array after returning it.
FUNCTION debug_getOldestEvent(removeWhenGiven)
ret$ = debug(1).event$
IF removeWhenGiven THEN ARRAY DELETE ELEMENT debug(), 1
ENDFUNCTION ret$
``Debug Clear Events: Clears the debug array.
FUNCTION debug_clearEvents()
UNDIM debug()
DIM debug(0) AS debug
ENDFUNCTION
``Debug Save: Saves the debug array to the specified file.
FUNCTION debug_save(prefix$, directory$, file)
IF prefix$ = "" THEN prefix$ = APPNAME$()
currentDir$ = GET DIR$()
IF directory$ <> "" THEN SET DIR directory$
REPEAT
INC suffix
UNTIL FILE EXIST(prefix$ + STR$(suffix) + ".debug") = 0
name$ = prefix$ + STR$(suffix) + ".debug"
OPEN TO WRITE file, name$
WRITE STRING file, APPNAME$() + " Debug Log: "
WRITE STRING file, GET DATE$() + " | " + GET TIME$()
events = ARRAY COUNT(debug())
FOR e = 1 TO events
WRITE STRING file, debug(e).event$
NEXT e
WRITE STRING file, "-- Debug End --"
CLOSE FILE file
SET DIR currentDir$
ENDFUNCTION
``Debug Clear Files: Deletes all files with .debug extension in the specified directory.
FUNCTION debug_clearFiles(directory$)
FIND FIRST
REPEAT
file$ = GET FILE NAME$()
IF RIGHT$(file$,6) = ".debug"
DELETE FILE file$
ENDIF
FIND NEXT
UNTIL file$ = ""
ENDFUNCTION
`````````````````````````````````````````````````````````````````````````````
`///////////////////////////////////////////////////////////////////////////`
`/ Help Files : /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET CONNECT /`
`/ /`
`/ Description: Attempt to connect to / host a server. The IP$ address is /`
`/ the IP of the host's computer. Status is either a 0 for /`
`/ client (connecting to a server), or 1 for host (creating a /`
`/ server). Maxplayers is only needed for the host, and /`
`/ sets the maximum number of clients allowed in the game /`
`/ before it is automatically closed (limited by the max /`
`/ number of ports allowed open and how fast the CPU runs). /`
`/ /`
`/ Syntax: net_connect( IP$, status$, maxplayers ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET ENABLE /`
`/ /`
`/ Description: Adds the current program to Windows Firewall's "Allow" /`
`/ list. /`
`/ /`
`/ Syntax: net_enable() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET INIT /`
`/ /`
`/ Description: Initializes any important network data. /`
`/ /`
`/ Syntax: net_init() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET KICK /`
`/ /`
`/ Description: Kicks the player with the specified ID from /`
`/ the game. /`
`/ /`
`/ Syntax: net_kick( ID ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET MERGE /`
`/ /`
`/ Description: Called when a client has successfully connected to a /`
`/ server. This stops the client from continuing into the /`
`/ main loop until they recieve PACKET_SETUP from the host, /`
`/ at which point their connection is set to IS_LOGGED_IN. /`
`/ Place any relevant authentication / setup data in the /`
`/ PACKET_SETUP packet that the client requires from the host /`
`/ to join the game. Place any relevant auth / setup data /`
`/ in the PACKET_LOGIN packet that the host requires from the /`
`/ client to add them to the player's list of logged in /`
`/ players. /`
`/ /`
`/ Syntax: net_merge() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET PROCESS /`
`/ /`
`/ Description: This should be called in the main game loop, after /`
`/ net_recieve() and before net_send(). Any processing the /`
`/ host or clients need to do on recieved data before sending /`
`/ it back out should go here. (For example, if the host /`
`/ recieves a value indicating if a client is attempting to /`
`/ move forward, the host would then calculate the client's /`
`/ new position, and then possibly check for collision, in /`
`/ this function. Then the host would send out this position /`
`/ to all other clients in the net_send() function inside of /`
`/ the PACKET_INFO. /`
`/ /`
`/ Syntax: net_process() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET RECIEVE /`
`/ /`
`/ Description: Checks if any new packets have arrived. If one is found, /`
`/ it figures out which type of packet it is (based on the /`
`/ packet protocol used - all packets have a byte representing/`
`/ which packet they are (check the packet information /`
`/ at the top of the page for more info). Once the packet /`
`/ is determined, the message is stored in the appropriate /`
`/ manner, and another check is made for a new packet. /`
`/ /`
`/ NOTE: Its very important to calibrate your net.packetdelay# /`
`/ value with the frame rate of the clients. If a /`
`/ client's frame rate is low, its a good idea to send /`
`/ packets less often, otherwise a large qeue of packets /`
`/ will build up, and the clients wont be able to leave /`
`/ the net recieve function's while-loop. /`
`/ /`
`/ Syntax: net_recieve() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET SEND /`
`/ /`
`/ Description: Checks if the time since the last data send is at least /`
`/ equal to the net.packetdelay# variable. If so, /`
`/ all necessary packets are sent out (to the host if /`
`/ the user is a client, otherwise to all clients if /`
`/ the user is a host). See the packet information /`
`/ at the top of the page for more info. /`
`/ /`
`/ NOTE: Its very important to calibrate your net.packetdelay# /`
`/ value with the frame rate of the clients. If a /`
`/ client's frame rate is low, its a good idea to send /`
`/ packets less often, otherwise a large qeue of packets /`
`/ will build up, and the clients wont be able to leave /`
`/ the net recieve function's while-loop. /`
`/ /`
`/ Syntax: net_send() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET SEND ALL EXCEPT /`
`/ /`
`/ Description: Will send the current message to all users except for /`
`/ the specified ID. /`
`/ /`
`/ Syntax: net_sendallexcept( ID ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET START /`
`/ /`
`/ Description: This is an example command provided for a quick game setup./`
`/ It prompts the user for their status, IP$, and maxplayers, /`
`/ via the input / print commands, and then calls /`
`/ net connect. /`
`/ /`
`/ Syntax: net_start() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ NET UPDATE /`
`/ /`
`/ Description: Updates any variables / calls any functions that the /`
`/ library requires to work. Also checks if any players have /`
`/ left or joined (required by Multisync), or if the current /`
`/ user has lost their connection. /`
`/ /`
`/ NOTE: Should be called after net_recieve, net_handle, and net_send. /`
`/ /`
`/ Syntax: net_update() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ PLR CLEANUP /`
`/ /`
`/ Description: Cycles through all players, checking if any have been /`
`/ disconnected. If so, they are removed from the players /`
`/ array, and net.players is updated accordingly. /`
`/ /`
`/ Syntax: plr_cleanup() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ PLR CREATE /`
`/ /`
`/ Description: Adds a new player to the players array, with the ID /`
`/ specified. Also updates net.players. It's recommend you /`
`/ call any player creation commands from this function /`
`/ (loading their character for example). /`
`/ /`
`/ Syntax: plr_create( ID ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ PLR DELETE /`
`/ /`
`/ Description: This command will set the player's connection status to /`
`/ -1 (IS_DISCONNECTED). It will NOT remove them from the /`
`/ players list. That is done by plr_cleanup. The reason for /`
`/ this is so the host can send out the player's connection /`
`/ status to all other players first, allowing them to set /`
`/ the player's connection status to IS_DISCONNECTED as well, /`
`/ at which time plr_cleanup will be called soon after, /`
`/ perfmanently removing them from the players array. /`
`/ /`
`/ Syntax: plr_delete( ID ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ PLR EXIST /`
`/ /`
`/ Description: Checks if the specified ID exists in the players
`/ array. /`
`/ /`
`/ Syntax: plr_exist( ID ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ PLR ID TO INDEX /`
`/ /`
`/ Description: Converts an ID number to an array index number in the /`
`/ players array. /`
`/ /`
`/ Syntax: plr_IDtoIndex( ID ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ DEBUG ADD EVENT /`
`/ /`
`/ Description: Adds the string event$ to the debug array. /`
`/ /`
`/ Syntax: debug_addEvent( event$ ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ DEBUG CLEAR EVENTS /`
`/ /`
`/ Description: Clears all events from the debug array /`
`/ /`
`/ Syntax: debug_clearEvents() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ DEBUG CLEAR FILES /`
`/ /`
`/ Description: Deletes all files with an extension of .debug from the /`
` specified directory$. /`
`/ /`
`/ Syntax: net_clearFiles() /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ DEBUG GET LAST EVENT /`
`/ /`
`/ Description: Returns the last event to be recorded. Setting /`
`/ removeWhenGiven to 1 will delete the event from the array /`
`/ after returning it. /`
`/ /`
`/ Syntax: debug_getLastEvent( removeWhenGiven ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ DEBUG GET OLDEST EVENT /`
`/ /`
`/ Description: Returns the oldest event to be recorded. Setting /`
`/ removeWhenGiven to 1 will delete the event from the array /`
`/ after returning it. /`
`/ /`
`/ Syntax: debug_getOldestEvent( removeWhenGiven ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ DEBUG OUTPUT /`
`/ /`
`/ Description: Prints all of the events recorded in the debug() array /`
`/ in order of oldest to most recent. Set removeWhenDisplayed /`
`/ to 1 to delete the events as they are printed. /`
`/ /`
`/ Syntax: debug_output( removeWhenDisplayed ) /`
`/ /`
`/`````````````````````````````````````````````````````````````````````````/`
`/ DEBUG SAVE /`
`/ /`
`/ Description: Saves the entire debug array to a file. prefix$ is the /`
`/ name of the file, and defaults to the application's name /`
`/ if empty quotes are given. Directory$ is where the file is /`
`/ to be saved to, and defaults to the current working /`
`/ directory if empty quotes are given. File is a free file /`
`/ number to use for the file creation. /`
`/ All debug files are saved with a .debug prefix. A check /`
`/ is made when the debug_save() command is called to see /`
`/ how many files exist in the directory with the prefix /`
`/ specified. All debug files have numbers at the end. This /`
`/ allows you to use the same prefix file name as many times /`
`/ as you want, and the files will be created with a numbered /`
`/ suffix (eg; mygame1.debug, mygame2.debug, mygame3.debug). /`
`/ /`
`/ Syntax: debug_save( prefix$, directory$, file ) /`
`/ /`
`///////////////////////////////////////////////////////////////////////////`
`````````````````````````````````````````````````````````````````````````````