added requests amb565 and amb445
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401078
This commit is contained in:
parent
6dd0ff6b07
commit
9a2fbe5f9f
@ -108,6 +108,18 @@ static cell_t sm_strconvint(IPluginContext *pCtx, const cell_t *params)
|
|||||||
return static_cast<cell_t>(strtol(str, &dummy, params[2]));
|
return static_cast<cell_t>(strtol(str, &dummy, params[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t StringToIntEx(IPluginContext *pCtx, const cell_t *params)
|
||||||
|
{
|
||||||
|
char *str, *dummy = NULL;
|
||||||
|
cell_t *addr;
|
||||||
|
pCtx->LocalToString(params[1], &str);
|
||||||
|
pCtx->LocalToPhysAddr(params[2], &addr);
|
||||||
|
|
||||||
|
*addr = static_cast<cell_t>(strtol(str, &dummy, params[3]));
|
||||||
|
|
||||||
|
return dummy - str;
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t sm_numtostr(IPluginContext *pCtx, const cell_t *params)
|
static cell_t sm_numtostr(IPluginContext *pCtx, const cell_t *params)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
@ -127,6 +139,20 @@ static cell_t sm_strtofloat(IPluginContext *pCtx, const cell_t *params)
|
|||||||
return sp_ftoc(val);
|
return sp_ftoc(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t StringToFloatEx(IPluginContext *pCtx, const cell_t *params)
|
||||||
|
{
|
||||||
|
char *str, *dummy = NULL;
|
||||||
|
cell_t *addr;
|
||||||
|
pCtx->LocalToString(params[1], &str);
|
||||||
|
pCtx->LocalToPhysAddr(params[2], &addr);
|
||||||
|
|
||||||
|
float val = (float)strtod(str, &dummy);
|
||||||
|
|
||||||
|
*addr = sp_ftoc(val);
|
||||||
|
|
||||||
|
return dummy - str;
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t sm_floattostr(IPluginContext *pCtx, const cell_t *params)
|
static cell_t sm_floattostr(IPluginContext *pCtx, const cell_t *params)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
@ -539,7 +565,9 @@ REGISTER_NATIVES(basicStrings)
|
|||||||
{"strcopy", sm_strcopy},
|
{"strcopy", sm_strcopy},
|
||||||
{"StrCopy", sm_strcopy}, /* Backwards compat shim */
|
{"StrCopy", sm_strcopy}, /* Backwards compat shim */
|
||||||
{"StringToInt", sm_strconvint},
|
{"StringToInt", sm_strconvint},
|
||||||
|
{"StringToIntEx", StringToIntEx},
|
||||||
{"StringToFloat", sm_strtofloat},
|
{"StringToFloat", sm_strtofloat},
|
||||||
|
{"StringToFloatEx", StringToFloatEx},
|
||||||
{"TrimString", TrimString},
|
{"TrimString", TrimString},
|
||||||
{"VFormat", sm_vformat},
|
{"VFormat", sm_vformat},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
|
@ -165,6 +165,16 @@ native VFormat(String:buffer[], maxlength, const String:format[], varpos);
|
|||||||
*/
|
*/
|
||||||
native StringToInt(const String:str[], nBase=10);
|
native StringToInt(const String:str[], nBase=10);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a string to an integer with some more options.
|
||||||
|
*
|
||||||
|
* @param str String to convert.
|
||||||
|
* @param result Variable to store the result in.
|
||||||
|
* @param nBase Numerical base to use. 10 is default.
|
||||||
|
* @return Number of characters consumed.
|
||||||
|
*/
|
||||||
|
native StringToIntEx(const String:str[], &result, nBase=10);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an integer to a string.
|
* Converts an integer to a string.
|
||||||
*
|
*
|
||||||
@ -183,6 +193,15 @@ native IntToString(num, String:str[], maxlength);
|
|||||||
*/
|
*/
|
||||||
native Float:StringToFloat(const String:str[]);
|
native Float:StringToFloat(const String:str[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a string to a floating point number with some more options.
|
||||||
|
*
|
||||||
|
* @param str String to convert to a foat.
|
||||||
|
* @param result Variable to store result in.
|
||||||
|
* @return Number of characters consumed.
|
||||||
|
*/
|
||||||
|
native StringToFloatEx(const String:str[], &Float:result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a floating point number to a string.
|
* Converts a floating point number to a string.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user