Add GetCmdArgFloat(Ex) stocks (#1742)
This commit is contained in:
parent
01203a5a44
commit
852703ccca
@ -383,9 +383,7 @@ public Action Command_Burn(int client, int args)
|
|||||||
|
|
||||||
if (args > 1)
|
if (args > 1)
|
||||||
{
|
{
|
||||||
char time[20];
|
if (!GetCmdArgFloatEx(2, seconds))
|
||||||
GetCmdArg(2, time, sizeof(time));
|
|
||||||
if (StringToFloatEx(time, seconds) == 0)
|
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
|
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
|
@ -197,9 +197,7 @@ public Action Command_Gravity(int client, int args)
|
|||||||
float amount = 1.0;
|
float amount = 1.0;
|
||||||
if (args > 1)
|
if (args > 1)
|
||||||
{
|
{
|
||||||
char arg2[20];
|
if (!GetCmdArgFloatEx(2, amount))
|
||||||
GetCmdArg(2, arg2, sizeof(arg2));
|
|
||||||
if (StringToFloatEx(arg2, amount) == 0)
|
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
|
ReplyToCommand(client, "[SM] %t", "Invalid Amount");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
|
@ -428,10 +428,11 @@ native int GetCmdArg(int argnum, char[] buffer, int maxlength);
|
|||||||
* console or server command. Will return 0 if the argument can not be
|
* console or server command. Will return 0 if the argument can not be
|
||||||
* parsed as a number. Use GetCmdArgIntEx to handle that explicitly.
|
* parsed as a number. Use GetCmdArgIntEx to handle that explicitly.
|
||||||
*
|
*
|
||||||
* @param argnum Argument number to retrieve.
|
* @param argnum Argument number to retrieve.
|
||||||
* @return Value of the command argument.
|
* @return Value of the command argument.
|
||||||
*/
|
*/
|
||||||
stock int GetCmdArgInt(int argnum) {
|
stock int GetCmdArgInt(int argnum)
|
||||||
|
{
|
||||||
char str[12];
|
char str[12];
|
||||||
GetCmdArg(argnum, str, sizeof(str));
|
GetCmdArg(argnum, str, sizeof(str));
|
||||||
|
|
||||||
@ -443,17 +444,51 @@ stock int GetCmdArgInt(int argnum) {
|
|||||||
* console or server command. Returns false if the argument can not be
|
* console or server command. Returns false if the argument can not be
|
||||||
* completely parsed as an integer.
|
* completely parsed as an integer.
|
||||||
*
|
*
|
||||||
* @param argnum Argument number to retrieve.
|
* @param argnum Argument number to retrieve.
|
||||||
* @param value Populated with the value of the command argument.
|
* @param value Populated with the value of the command argument.
|
||||||
* @return Whether the argument was entirely a numeric value.
|
* @return Whether the argument was entirely a numeric value.
|
||||||
*/
|
*/
|
||||||
stock bool GetCmdArgIntEx(int argnum, int &value) {
|
stock bool GetCmdArgIntEx(int argnum, int &value)
|
||||||
|
{
|
||||||
char str[12];
|
char str[12];
|
||||||
int len = GetCmdArg(argnum, str, sizeof(str));
|
int len = GetCmdArg(argnum, str, sizeof(str));
|
||||||
|
|
||||||
return StringToIntEx(str, value) == len && len > 0;
|
return StringToIntEx(str, value) == len && len > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a float command argument given its index, from the current
|
||||||
|
* console or server command. Will return 0.0 if the argument can not be
|
||||||
|
* parsed as a number. Use GetCmdArgFloatEx to handle that explicitly.
|
||||||
|
*
|
||||||
|
* @param argnum Argument number to retrieve.
|
||||||
|
* @return Value of the command argument.
|
||||||
|
*/
|
||||||
|
stock float GetCmdArgFloat(int argnum)
|
||||||
|
{
|
||||||
|
char str[18];
|
||||||
|
GetCmdArg(argnum, str, sizeof(str));
|
||||||
|
|
||||||
|
return StringToFloat(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a float command argument given its index, from the current
|
||||||
|
* console or server command. Returns false if the argument can not be
|
||||||
|
* completely parsed as a floating point.
|
||||||
|
*
|
||||||
|
* @param argnum Argument number to retrieve.
|
||||||
|
* @param value Populated with the value of the command argument.
|
||||||
|
* @return Whether the argument was entirely a floating point value.
|
||||||
|
*/
|
||||||
|
stock bool GetCmdArgFloatEx(int argnum, float &value)
|
||||||
|
{
|
||||||
|
char str[18];
|
||||||
|
int len = GetCmdArg(argnum, str, sizeof(str));
|
||||||
|
|
||||||
|
return StringToFloatEx(str, value) == len && len > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the entire command argument string in one lump from the current
|
* Retrieves the entire command argument string in one lump from the current
|
||||||
* console or server command.
|
* console or server command.
|
||||||
|
Loading…
Reference in New Issue
Block a user