Solved Kick and ban functions?

Discussion in 'Rust Development' started by Onyx, Jul 6, 2015.

  1. Hey !

    I'm looking for a way to kick and ban players.
    I found this function : ConVar.Admin.kick(ConsoleSystem.Arg arg);
    The compiler finds the function but the arguments are wrong ...
    I tried "player.userID" and "new string[]{player.userID}" but i still have the error
    :
    Code:
     Argument `#1' cannot convert `string[]' expression to type `ConsoleSystem.Arg'
    Please help ! :)
     
  2. Try this:
    ConVar.Admin.kick(args[0]);
    or
    ConVar.Admin.kick((ConsoleSystem.Arg)args[0]);
     
  3. Nope, i tried
    Code:
    ConVar.Admin.kick((ConsoleSystem.Arg)player.userID);
    but it looks like i can't cast anything to ConsoleSystem.Arg

    Ty for your answer anyway
     
  4. Wulf

    Wulf Community Admin

    What language are you trying to do this with? Pretty sure you're going about it entirely wrong.
     
  5. In C#, i found the function in the C# assembly.
     
    Last edited by a moderator: Jul 6, 2015
  6. try

    Code:
    BasePlayer player = arg.GetPlayer(0);
    player.Kick(string.Concat("Kicked: ", arg.GetString(1, "No Reason Given")));
    
    I also found

    Code:
    string str = arg.GetString(1, "No Reason Given");
    Net.sv.Kick(player.net.connection, string.Concat("Banned: ", str));
    
     
  7. Waw it was as simple as player.Kick ? Ty very much.
    How can i ban someone ? Looks like there's no function Ban for BasePlayer ...
     
  8. I think for banning is the second example that i gave u ;)
     
  9. Wulf

    Wulf Community Admin

    You gave two kick examples, not ban.
     
  10. Oh yeah.. gonna edit this post if i find anything else.

    I found only one ban example .. the one that i listed above
    Code:
    string str = arg.GetString(1, "No Reason Given");
    Net.sv.Kick(player.net.connection, string.Concat("Banned: ", str));
    
     
    Last edited by a moderator: Jul 6, 2015
  11. Wulf

    Wulf Community Admin

    That's still a kick, not a ban, as shown in the function name.
     
  12. Yes i think your second example may be the kick resulting of a connection attempt when a user is banned. Thank you anyway man.
     
  13. Wulf

    Wulf Community Admin

    They're just different methods of kicking. The ban function in Rust simply checks if a user is on a list, and then essentially kicks them.
     
  14. Oh ok so i just have to edit the ban file and add the user i want right?
    [DOUBLEPOST=1436214269][/DOUBLEPOST]Waw it looks like the ban stuff is a big mess. The ban.cfg doesn't ban shit, when you ban someone you don't know where it's saved etc ... I think i'll do something by myself ...
    Thank you Wulf and PaiN ! solved
     
  15. I think server.writecfg saves bans but I could be wrong...?
     
  16. I tried it yesterday and no it's not. Or at least not in the cfg/bans.cfg file.
     
  17. While searching the assembly i found something interesting.
    In the assembly the code checks if the player has the group (name.group.Banned) and the kicks him with the second example that i gave u
     
  18. Nice but i think i'll just check in my datas is the player is supposed to be banned and kick him on login if so. That will be easier for temporary bans.