---
title: "strfloat | open.mp"
description: "将字符串转换为浮点数。"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/strfloat
language: zh-CN
---

# strfloat

注意

这个函数是在omp v1.1.0.2612中添加的，在以前的版本中不起作用！

## 描述

将字符串转换为浮点数。

## 参数

| 参数 | 说明 |
| --- | --- |
| const string\[\] | 待转换的字符串 |

## 返回值

转换后的浮点数值。

## 示例

```c
new string[4] = "6.9"; // 存储浮点数的字符串

new Float:value = strfloat(string);

SetPlayerPos(playerid, 0.0, 0.0, value);
```

## 注意事项

备注

此函数功能与 [floatstr](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/floatstr) 完全一致。

## 相关函数

-   [floatround](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/floatround): 将浮点数转换为整数（四舍五入）
-   [float](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/float): 将整数转换为浮点数
