-- 创建3辆运钞车
Citizen.CreateThread(function()
for i = 1, 3 do
local ped = GetHashKey("s_m_m_armoured_01") -- 持枪警卫的模型
local vehicle = GetHashKey("stockade") -- 运钞车的模型
-- 在随机位置生成运钞车
local x = math.random(-2000, 2000)
local y = math.random(-2000, 2000)
local z = GetGroundZFor_3dCoord(x, y, 0)
local car = CreateVehicle(vehicle, x, y, z, math.random(0, 360), true, false)
-- 在运钞车上面生成持枪警卫
local driver = CreatePedInsideVehicle(car, 4, ped, -1, true, false)
local passenger1 = CreatePedInsideVehicle(car, 4, ped, 0, true, false)
local passenger2 = CreatePedInsideVehicle(car, 4, ped, 1, true, false)
-- 设置持枪警卫的属性
SetDriverAbility(driver, 100.0)
SetDriverAggressiveness(driver, 100.0)
SetDriverAbility(passenger1, 100.0)
SetDriverAggressiveness(passenger1, 100.0)
SetDriverAbility(passenger2, 100.0)
SetDriverAggressiveness(passenger2, 100.0)
-- 设置运钞车的属性
SetVehicleHasBeenOwnedByPlayer(car, true)
SetEntityAsMissionEntity(car, true, true)
SetVehicleEngineOn(car, true, true, false)
-- 在地图上显示黄点
local blip = AddBlipForEntity(car)
SetBlipSprite(blip, 67)
SetBlipColour(blip, 5)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Cash Truck")
EndTextCommandSetBlipName(blip)
end
end)
-- 监听玩家是否攻击警卫
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
for k, v in ipairs(GetActivePlayers()) do
local playerPed = GetPlayerPed(v)
local playerPos = GetEntityCoords(playerPed)
local nearbyPeds = GetNearbyPeds(playerPos.x, playerPos.y, playerPos.z, 20.0)
for i = 1, #nearbyPeds do
if IsPedInAnyVehicle(nearbyPeds[i], false) then
local vehicle = GetVehiclePedIsIn(nearbyPeds[i], false)
if GetEntityModel(vehicle) == GetHashKey("stockade") then
if IsPedInCombat(nearbyPeds[i]) and not IsPedDeadOrDying(nearbyPeds[i], 1) then
-- 警卫反击
TaskCombatPed(nearbyPeds[i], playerPed, 0, 16)
end
end
end
end
end
end
end)
-- 监听玩家是否接近运钞车
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = GetPlayerPed(-1)
local playerPos = GetEntityCoords(playerPed)
for k, v in ipairs(GetAllVehicles()) do
if GetEntityModel(v) == GetHashKey("stockade") then
local vehiclePos = GetEntityCoords(v)
local distance = GetDistanceBetweenCoords(playerPos.x, playerPos.y, playerPos.z, vehiclePos.x, vehiclePos.y, vehiclePos.z, true)
-- 截停运钞车并与警卫对战
if distance <= 5.0 then
DrawText3D(vehiclePos.x, vehiclePos.y, vehiclePos.z + 2.0, "~g~[E]~s~ 截停运钞车")
if IsControlJustPressed(0, 51) then
TaskVehicleChase(playerPed, v)
SetVehicleDoorsLocked(v, 4)
if not HasPedGotWeapon(playerPed, GetHashKey("weapon_pistol"), false) then
GiveWeaponToPed(playerPed, GetHashKey("weapon_pistol"), 255, false, true)
end
end
end
-- 掠夺运钞车后门的金条
local backDoorCoords = GetOffsetFromEntityInWorldCoords(v, 0.0, -3.0, 0.0)
local doorDistance = GetDistanceBetweenCoords(playerPos.x, playerPos.y, playerPos.z, backDoorCoords.x, backDoorCoords.y, backDoorCoords.z, true)
if doorDistance <= 2.0 then
DrawText3D(backDoorCoords.x, backDoorCoords.y, backDoorCoords.z + 0.7, "~g~[E]~s~ 掠夺金条")
if IsControlJustPressed(0, 51) then
-- 在这里编写你想要执行的逻辑来掠夺金条
end
end
end
end
end
end)
-- 在屏幕上显示3D文本
function DrawText3D(x, y, z, text)
local onScreen, _x, _y = World3dToScreen2d(x, y, z)
local px, py, pz = table.unpack(GetGameplayCamCoords())
SetTextScale(0.30, 0.30)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 215)
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x, _y)
local factor = (string.len(text)) / 370
DrawRect(_x, _y + 0.0125, 0.015 + factor, 0.03, 41, 11, 41, 68)
end