ItsMods

Full Version: kick command still need help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i have a problem with my kick command this is the code
Code:
if (Message.Substring(0,5) == "!kick")
                {
                    ServerCommand("kick " + Message.Substring(5));
                }
it only works on players without a space in their name anyone know why?
Try this
(Code from my engine)

ServerClient clienttokick = SV_GetPlayerByName(Message.substring(5).tostring());
Then use clienttokick infos

THIS should return fine name

Code:
public ServerClient SV_GetPlayerByName(string name)
        {
/*
            if (cvar_t.Get<int>("sv_running") == 0)
            {
                CLog.Print_f(Level.Info, "No server running.");
                return null;
            }
*/
            for (int i = 0; i < GetClients().Length; i++)
            {
                if (GetClients()[i] != null && GetClients()[i].Name == name)
                {
                    return GetClients()[i];
                }
            }
           ServerPrint("No player found");
            return null;
        }
im sorry i dont know how to use this im a noob.
I get this error: 'System.Collections.Generic.List<Addon.ServerClient>' does not contain a definition for 'Length' and no extension method 'Length' accepting a first argument of type 'System.Collections.Generic.List<Addon.ServerClient>' could be found (are you missing a using directive or an assembly reference?)