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
:
Please help !Code:Argument `#1' cannot convert `string[]' expression to type `ConsoleSystem.Arg'![]()
Solved Kick and ban functions?
Discussion in 'Rust Development' started by Onyx, Jul 6, 2015.
-
Try this:
ConVar.Admin.kick(args[0]);
or
ConVar.Admin.kick((ConsoleSystem.Arg)args[0]); -
Nope, i tried
Code:ConVar.Admin.kick((ConsoleSystem.Arg)player.userID);
Ty for your answer anyway -
Wulf Community Admin
What language are you trying to do this with? Pretty sure you're going about it entirely wrong.
-
In C#, i found the function in the C# assembly.
Last edited by a moderator: Jul 6, 2015 -
try
Code:BasePlayer player = arg.GetPlayer(0); player.Kick(string.Concat("Kicked: ", arg.GetString(1, "No Reason Given")));
Code:string str = arg.GetString(1, "No Reason Given"); Net.sv.Kick(player.net.connection, string.Concat("Banned: ", str));
-
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 ... -
-
Wulf Community Admin
-
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 -
Wulf Community Admin
-
Yes i think your second example may be the kick resulting of a connection attempt when a user is banned. Thank you anyway man.
-
Wulf Community Admin
-
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 -
-
I tried it yesterday and no it's not. Or at least not in the cfg/bans.cfg file.
-
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 -
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.