ESX.Game.SpawnLocalVehicle

1
ESX.Game.SpawnLocalVehicle(modelOrHash, coords, heading, cb)

这个函数产生一个本地车辆,仅本地玩家可见,其他人则看不到。

Warning

这是一个异步函数,因为需要等待车辆模型流式传输,下面有一个有关如何正确利用它的示例。

参数

参数 数据类型 可选项 默认值 说明
modelOrHash string&number No - 您可以指定模型(例如 blista)或载具哈希值。
coords table No - 载具生成的坐标值,你也可以解析向量类型而没有任何问题
heading number No - 在生成载具的前进方向,必须包含一个小数位
cb function Yes - 生成载具后返回的函数。调用的函数有一个参数,即载具句柄

ESX.Game.SpawnLocalVehicle 示例

1
2
3
4
5
ESX.Game.SpawnLocalVehicle('blista', vector3(120.0, -200.0, 30.0), 100.0, function(vehicle)
    print(DoesEntityExist(vehicle), 'this code is async!')
end)

print('this code is sync!')