PDA

View Full Version : [Advanced] Getting client binds



IzNoGoD
21st December 2014, 18:10
Just stumbled upon a ridiculously simple method to read client binds using libcod.

Here is the code:


CodeCallback_PlayerCommand(args)
{
self endon("disconnect");

args = fixChatArgs(args);
output = "" + gettime() + ": ";
for (i = 0; i < args.size; i++)
output += args[i] + " ";
if(args[0] == "here_comes_the_bindtrain")
{
self.binds = [];
self.keys = [];
self.bindlist_started = true;
return;
}
if(args[0] == "bindtrain_done")
{
self.bindlist_started = false;
for(i = 0; i < self.binds.size; i++)
{
self iprintln("You got " + self.keys[i] + " binded to " + self.binds[i]);
}
return;
}
if(isdefined(self.bindlist_started) && self.bindlist_started)
{
if(args[0] == "Dumped" && args[1] == "console")
return;
self.keys[self.keys.size] = args[0];
self.binds[self.binds.size] = args[1];
return;
}
self ClientCommand();
}

and it needs to be initiated by the following line:


self execclientcmd("clear; bindlist; condump binds.cfg; here_comes_the_bindtrain; exec binds.cfg; bindtrain_done; clear");

This will iprintln all the binds the client has.

Use it for good, not for evil

Edit: vid: http://classic.xfire.com/video/6305cf

Mitch
16th January 2015, 21:06
If you are having trouble with receiving the binds then you have got sv_floodProtect set to 1.

There are two ways to solve this.
- Set sv_floodProtect to 0
- Use resetNextReliableTime (https://github.com/M-itch/libcod/commit/20872455123c0dd85ddf23aa8be72d48b529c286) (Selbie's resetClientCommand) before execclientcmd and after 'here_comes_the_bindtrain' and each bind.