]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host_cmd.c
Tomaz's nametime patch (prevent frequent name changes on the server)
[xonotic/darkplaces.git] / host_cmd.c
index b5d43ffec2299ac62a1776f9cc75b5b727454409..645a6a18ecb5053f89a39d75af19ca7f16f1a6d8 100644 (file)
@@ -686,14 +686,20 @@ void Host_Name_f (void)
 
        if (cmd_source == src_command)
        {
-               if (strcmp(cl_name.string, newName) == 0)
-                       return;
                Cvar_Set ("_cl_name", newName);
                if (cls.state == ca_connected)
                        Cmd_ForwardToServer ();
                return;
        }
 
+       if (sv.time < host_client->nametime)
+       {
+               SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
+               return;
+       }
+       
+       host_client->nametime = sv.time + 5;
+
        if (strcmp(host_client->name, newName) && host_client->name[0] && strcmp(host_client->name, "unconnected"))
                SV_BroadcastPrintf("%s changed name to %s\n", host_client->name, newName);
        strcpy(host_client->name, newName);