]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/miscfunctions.qc
Merge remote branch 'origin/master' into samual/updatecommands
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qc
index f9a9990a4c4349ca6d018d0283016754b28a9452..e4ee39e9174a2f7e6b2435c3ddc08f01c2552c2f 100644 (file)
@@ -3137,3 +3137,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;
+}