]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Give getfilternumber the functionality to also get edict numbers from player
authorSamual <samual@xonotic.org>
Thu, 17 Nov 2011 22:13:23 +0000 (17:13 -0500)
committerSamual <samual@xonotic.org>
Thu, 17 Nov 2011 22:13:23 +0000 (17:13 -0500)
names.. This way you can supply the name of a player you want to select
instead of just being able to supply the entity number.

qcsrc/common/util.qc
qcsrc/server/miscfunctions.qc

index 105b7e7768f84136062ae6087a0b19a9dbb77419..38bb3914d13f22edfbd35d50dd151cd676be606b 100644 (file)
@@ -2106,18 +2106,4 @@ float lowestbit(float f)
        f &~= f * 256;
        f &~= f * 65536;
        return f;
-}
-
-// used by gamecommand/clientcommand system
-float GetFilteredNumber(string input)
-{
-       float output;
-       
-       if(substring(input, 0, 1) == "#")
-               output = stof(substring(input, 1, -1));
-       else
-               output = stof(input);
-               
-       //print(strcat("input: ", input, ", output: ", ftos(output), ",\n"));
-       return output;
 }
\ No newline at end of file
index 2fe562774d0d625468b36e4333f1e9547e17a607..4e43f17fdae175842b88c3ba33d120b783339d10 100644 (file)
@@ -3135,3 +3135,29 @@ float isPushable(entity e)
                return TRUE;
        return FALSE;
 }
+
+// used by gamecommand/clientcommand/votecommand/bancommand system
+float GetFilteredNumber(string input)
+{
+       entity tmp_player, selection;
+       float output, matches;
+       
+       // check and see if we can get a number from input like "#3" or "3" 
+       if(substring(input, 0, 1) == "#")
+               output = stof(substring(input, 1, -1));
+       else
+               output = stof(input);
+               
+       // if we can't, check and see if we can match the input to the netname of any player in the game
+       if not(output) 
+       {
+               FOR_EACH_CLIENT(tmp_player)
+                       if (strdecolorize(tmp_player.netname) == strdecolorize(input))
+                               selection = tmp_player;
+
+               if (selection) { output = num_for_edict(selection); }
+       }
+               
+       print(strcat("input: ", input, ", output: ", ftos(output), ",\n"));
+       return output;
+}
\ No newline at end of file