'Morse' system to send data from client to server
Posted: Sat Jan 03, 2004 6:32 pm
I think I've found a way to make clients able to send data (e.g. a button pressed in an urc file) to the server. It's a very expedient, slow and inflexible way, but hey... it works
. Basically it works with very well timed pulses of use commands. To accomplish the timing, either a keybind could be made or a urc file could execute a stuffcommand. I don't know how well it works when clients have considerable ping, though.
This is the code I used:
Along with these keybinds:
As you can see, 'wait 100' is used to designate a '.', whereas 'wait 200' is used for a '-' and 'wait 400' seperates the characters. This means that for even a simple 2-character 'data packet' nearly 1 second of broadcasting time is required, in which the player cannot move. Hence it isn't very smooth, but seems to work ok.
Possible applications include sending commands to bots, choosing a certain 'class' (like sniper/mg/medic) for class-base mods, additional voice messages and maybe urc-controlled objects in a multiplayer map like multi-floor elevators.
This is the code I used:
Code: Select all
// self is a player
monitor:
while(1)
{
while !(self.useheld)
waitframe
local.text = ""
local.chars = 0
while(1)
{
local.frames = 0
while(self.useheld)
{
waitframe
waitframe
local.frames++
}
if(local.frames == 2)
{
local.chars++
local.char = "-"
}
else if(local.frames == 1)
{
local.chars++
local.char = "."
}
else
break
local.text += local.char
wait 0.40
}
println "client broadcast: " local.text
// need at least 2 chars for a valid command
if(local.chars >= 2)
waitthread clientcommand local.text
}
end
clientcommand local.text:
switch (local.text)
{
case "--":
iprintln "client pressed m"
break
case "-.":
iprintln "client pressed n"
break
default:
iprintln "unknown client command " local.text
}
end
Code: Select all
bind m "+use;wait 200;-use;wait 400;+use;wait 200;-use"
bind n "+use;wait 200;-use;wait 400;+use;wait 100;-use"
Possible applications include sending commands to bots, choosing a certain 'class' (like sniper/mg/medic) for class-base mods, additional voice messages and maybe urc-controlled objects in a multiplayer map like multi-floor elevators.