RegisterCommand("createcar",function(source,args)
local coords = GetEntityCoords(GetPlayerPed(-1))
print(coords.x)
print(coords.y)
print(coords.z)
print(args[1])
print(type(args[1]))
local testVehicle = CreateVehicle("baller",coords.x,coords.y,coords.z,args[1],false,true)
Citizen.CreateThread(function()
local time = 30 -- 30 倒计时
while (time ~= 0) do -- 大于0循环
Wait( 1000 ) -- 等待一秒
time = time - 1
-- 每过一秒-1
end
--执行完timer回收车辆和线程
DeleteVehicle(testVehicle)
TerminateThisThread()
end)
end)
CreateVehicle("baller",coords.x,coords.y,coords.z,"180"--[[头部朝向180度]],false,true)
CreateVehicle("baller",coords.x,coords.y,coords.z,180--[[int类型180度不会工作]],false,true)
效果:一个heading为90,一个为180 浏览附件41 代码:Lua:RegisterCommand("createcar",function(source,heading) local coords = GetEntityCoords(GetPlayerPed(-1)) print(coords.x) print(coords.y) print(coords.z) print(heading[1]) local testVehicle = CreateVehicle("baller",coords.x,coords.y,coords.z,heading[1],false,true) Citizen.CreateThread(function() local time = 30 -- 30 倒计时 while (time ~= 0) do -- 大于0循环 Wait( 1000 ) -- 等待一秒 time = time - 1 -- 每过一秒-1 end --执行完timer回收车辆和线程 DeleteVehicle(testVehicle) TerminateThisThread() end) end)
效果:一个heading为90,一个为180 浏览附件41 代码:Lua:RegisterCommand("createcar",function(source,heading) local coords = GetEntityCoords(GetPlayerPed(-1)) print(coords.x) print(coords.y) print(coords.z) print(heading[1]) local testVehicle = CreateVehicle("baller",coords.x,coords.y,coords.z,heading[1],false,true) Citizen.CreateThread(function() local time = 30 -- 30 倒计时 while (time ~= 0) do -- 大于0循环 Wait( 1000 ) -- 等待一秒 time = time - 1 -- 每过一秒-1 end --执行完timer回收车辆和线程 DeleteVehicle(testVehicle) TerminateThisThread() end) end)
中午好,我该有什么办法让我很方便的测试我的插件,不用每次重启服务器和fivem客户端那种效果:一个heading为90,一个为180
浏览附件41
代码:
Lua:RegisterCommand("createcar",function(source,heading) local coords = GetEntityCoords(GetPlayerPed(-1)) print(coords.x) print(coords.y) print(coords.z) print(heading[1]) local testVehicle = CreateVehicle("baller",coords.x,coords.y,coords.z,heading[1],false,true) Citizen.CreateThread(function() local time = 30 -- 30 倒计时 while (time ~= 0) do -- 大于0循环 Wait( 1000 ) -- 等待一秒 time = time - 1 -- 每过一秒-1 end --执行完timer回收车辆和线程 DeleteVehicle(testVehicle) TerminateThisThread() end) end)
确保你是最高管理员, 修改好插件后游戏内按f8输入 restart [脚本名] 就可以了中午好,我该有什么办法让我很方便的测试我的插件,不用每次重启服务器和fivem客户端那种
收到!效果:一个heading为90,一个为180
浏览附件41
代码:
Lua:RegisterCommand("createcar",function(source,args) local coords = GetEntityCoords(GetPlayerPed(-1)) print(coords.x) print(coords.y) print(coords.z) print(args[1]) print(type(args[1])) local testVehicle = CreateVehicle("baller",coords.x,coords.y,coords.z,args[1],false,true) Citizen.CreateThread(function() local time = 30 -- 30 倒计时 while (time ~= 0) do -- 大于0循环 Wait( 1000 ) -- 等待一秒 time = time - 1 -- 每过一秒-1 end --执行完timer回收车辆和线程 DeleteVehicle(testVehicle) TerminateThisThread() end) end)
总结:
目前官方手册当中CreateVehicle函数的heading值只能为string类型,目前int型不能工作,可能是官方的bug, 稍后提交给官方进行修正。
所以说如果你要创建一个车辆并改变它的头部朝向,可以这样写:
而不是Lua:CreateVehicle("baller",coords.x,coords.y,coords.z,"180"--[[头部朝向180度]],false,true)
Lua:CreateVehicle("baller",coords.x,coords.y,coords.z,180--[[int类型180度不会工作]],false,true)
哥找到原因了 我用的是效果:一个heading为90,一个为180
浏览附件41
代码:
Lua:RegisterCommand("createcar",function(source,args) local coords = GetEntityCoords(GetPlayerPed(-1)) print(coords.x) print(coords.y) print(coords.z) print(args[1]) print(type(args[1])) local testVehicle = CreateVehicle("baller",coords.x,coords.y,coords.z,args[1],false,true) Citizen.CreateThread(function() local time = 30 -- 30 倒计时 while (time ~= 0) do -- 大于0循环 Wait( 1000 ) -- 等待一秒 time = time - 1 -- 每过一秒-1 end --执行完timer回收车辆和线程 DeleteVehicle(testVehicle) TerminateThisThread() end) end)
总结:
目前官方手册当中CreateVehicle函数的heading值只能为string类型,目前int型不能工作,可能是官方的bug, 稍后提交给官方进行修正。
所以说如果你要创建一个车辆并改变它的头部朝向,可以这样写:
而不是Lua:CreateVehicle("baller",coords.x,coords.y,coords.z,"180"--[[头部朝向180度]],false,true)
Lua:CreateVehicle("baller",coords.x,coords.y,coords.z,180--[[int类型180度不会工作]],false,true)
嗷嗷,这样啊,那可能是版本不一样,我这里只有字符串可以用,整数或者小数都不可以!哥找到原因了 我用的是
ESX.Game.SpawnVehicle(currentVehicle, Config.CarSpawnLocation.slot1, 248.0, function(vehicle)这个函数 heading参数得加小数