Jump to content
Sign in to follow this  
oktane

kicking off 'ghost' players

Recommended Posts

Been up all night trying to get this to work.. every bit seems to work ok in an #exec command, but when I put it in the server cfg, it doesn't work. I test by using 2 instances of arma, join server then taskkill that client and join with the other instance. This would kick off ghost players if it worked.. sad_o.gif Tried with kickduplicate 1 and 0, no difference. Even tried in onPlayerConnected. No errors in RPT. (there were when I had syntax errors however) To be clear, I am trying to kick the original user that hasn't timed out yet, not the new client reconnecting.. the new client will get kicked regardless. (either by kickduplicate or key checks) I want to kick the old ghost off so the person can reconnect successfully.

Its supposed to work like this:

First foreach gets dupe player name

for loops get length and converts string to array

Second foreach compares dupe player name minus " (2)" that Arma appends and kicks all players with that base name.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

doubleIdDetected = "_a = -1;{if((_this select 0)==(_x select 0)) then {_a=_x select 1;};} foreach users;_arr=toArray(_a);_out = [];for ""_i"" from 0 to (count _arr)-1 do {_out=_out+[toString([_arr select _i])];};_len=count (_out);_i=0;_end="""";for ""_i"" from 0 to _len - 5 do {_end=_end + (_out select _i);};{if((_x select 1)==_end) then {kick (_x select 0);};} foreach users;";

Here is a normal version for VM with linebreaks:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_a = -1;

{

if((_this select 0)==(_x select 0)) then {

_a=_x select 1;

};

} foreach users;

_arr=toArray(_a);_out = [];for "_i" from 0 to (count _arr)-1 do {_out=_out+[toString([_arr select _i])];};_len=count (_out);

_i=0;_end="";_ret = "";

for "_i" from 0 to _len - 5 do {_end=_end + (_out select _i);};

{

if((_x select 1)==_end) then {

kick _x select 0;

};

} foreach users;

Here is a version that could run in game as an example (outside of server VM):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

users = [[3, "larry"],[5,"moe"],[4,"moe (2)"]];

command = {

_a = -1;

{

if((_this select 0)==(_x select 0)) then {

_a=_x select 1;

};

player sidechat format ["%1", _a];

} foreach users;

_arr=toArray(_a);_out = [];for "_i" from 0 to (count _arr)-1 do {_out=_out+[toString([_arr select _i])];};_len=count (_out);

player sidechat format ["len %1", _len];

_i=0;_end="";_ret = "";

for "_i" from 0 to _len - 5 do {_end=_end + (_out select _i);};

{

if((_x select 1)==_end) then {

_ret = _x select 0;

};

player sidechat format ["'%1' '%2' '%3'", _x select 1, _x select 0, _end];

} foreach users;

_ret

};

_eh = [4] call command;

player globalchat format ["player to be kicked: %1", _eh];

here are is the way I broke it up to make sure every command was supported by the VM. Since I couldn't execute it all at once, I had to simulate the variables being set. The players name is 'a' and his dupe would be 'a (2)' or similar. (4 extra chars)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

OK (get name): #exec _a=-1;{if(8==(_x select 0)) then {_a=_x select 1;};} foreach users;_a

OK (str2arr): #exec _arr=toArray("a (2)");_out=[];for "_i" from 0 to (count _arr)-1 do {_out=_out+[toString([_arr select _i])];};_len=count(_out);_out;

OK (same as above but returns len): #exec _arr=toArray("a (2)");_out=[];for "_i" from 0 to (count _arr)-1 do {_out=_out+[toString([_arr select _i])];};_len=count(_out);_len;

OK (example trim off " (2)"): #exec _len=5;_out=["a"," ","(","2",")"];_i=0;_end="";for "_i" from 0 to _len - 5 do {_end=_end + (_out select _i);};_end;

OK (replace 'a' with a valid player name on the server): #exec _r="";{if((_x select 1)=="a") then {_r = _x select 0};} foreach users;_r;

Sorry the code is so compacted, there is limited paste buffer for the chatline when running exec commands. Here is a pastie url: http://www.pastie.org/349619

Anyone have any ideas? I think this would be pretty useful for a dedicated server to have.

--

String function bits by Kronzky

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×