-- 判断是否为服务器,如果不是则返回 if not isServer() then return end

-- 处理客户端命令的函数 local function RV_B_OnClientCommand(module, command, player,arguments) if module=="RV_Entercarhouse" then -- 进入车库命令 -- 获取要进入的车辆 local vehicle = getVehicleById(arguments[1]) -- 初始化车库编号和车库数据 if getGameTime():getModData().RVservercarhousenum==nil then getGameTime():getModData().RVservercarhousenum=0 end if getGameTime():getModData().RVservercarhouse==nil then getGameTime():getModData().RVservercarhouse={} end -- 如果该车辆还没有分配车库编号,则分配一个 if vehicle:getModData().RVservercarhousenum==nil then vehicle:getModData().RVservercarhousenum=getGameTime():getModData().RVservercarhousenum+1 getGameTime():getModData().RVservercarhousenum=getGameTime():getModData().RVservercarhousenum+1 getGameTime():getModData().RVservercarhouse[vehicle:getModData().RVservercarhousenum]={} end -- 如果车库编号已经达到上限,则返回 if vehicle:getModData().RVservercarhousenum>25 then return end -- 发送进入车库命令给客户端 sendServerCommand(player,"RV_B_Entercarhouse", "true",{vehicle:getModData().RVservercarhousenum,arguments[1]}) -- 将玩家位置记录到车库数据中 if getGameTime():getModData().RVserverhouseplayerpos==nil then getGameTime():getModData().RVserverhouseplayerpos={} end getGameTime():getModData().RVserverhouseplayerpos[player:getUsername()]=vehicle:getModData().RVservercarhousenum elseif module == "RV_carhouseExit" then -- 离开车库命令 -- 如果玩家已经进入车库,则发送离开车库命令给客户端 if getGameTime():getModData().RVserverhouseplayerpos[player:getUsername()]~=nil then local housecarpos=getGameTime():getModData().RVservercarhouse[getGameTime():getModData().RVserverhouseplayerpos[player:getUsername()]] sendServerCommand(player,"RV_B_carhouseExit", "true",housecarpos) end elseif module=="RVpartcondition" then -- 更新车辆部件耐久度 local vehiclezb = getVehicleById(arguments[1]) local partzb = vehiclezb:getPartById(command) partzb:setCondition(partzb:getCondition()-2) sendServerCommand(module, command,{arguments[1],partzb:getCondition()}) elseif module=="RV_B_railgun" then -- 更新轨道炮状态 local vehicleza = getVehicleById(arguments[1]) if vehicleza then vehicleza:getModData().RV_B_railgundic = arguments[2] sendServerCommand("RV_B_railgun", "true",{vehicleza:getId(),arguments[2]}) end end end

-- 添加客户端命令处理函数到事件监听器中 Events.OnClientCommand.Add(RV_B_OnClientCommand)

-- 定时处理函数,用于更新车库数据 local function RV_OnTick(numberTicks) if getGameTime():getModData().RVservercarhouse~=nil then for i=1,#getGameTime():getModData().RVservercarhouse do local vehicles=getCell():getVehicles() local spnumber=0 for k=1,vehicles:size() do local vehiclez=vehicles:get(k-1) local vehiclesnum = vehiclez:getModData().RVservercarhousenum if vehiclesnum ~=nil then if vehiclesnum==i then getGameTime():getModData().RVservercarhouse[vehiclesnum]={vehiclez:getX(),vehiclez:getY(),vehiclez:getZ(),{true,vehiclez:getId()}} spnumber=1 end end end if spnumber==0 then if getGameTime():getModData().RVservercarhouse[i]==nil then getGameTime():getModData().RVservercarhouse[i]={} end getGameTime():getModData().RVservercarhouse[i][4]=false end end end end

-- 添加定时处理函数到事件监听器中 Events.OnTick.Add(RV_OnTick)

if not isServer then return endlocal function RV_B_OnClientCommandmodule command playerarguments	if module==RV_Entercarhouse then		local vehicle = getVehicleByIdarguments1		if getGameTimegetModDataRVs

原文地址: https://www.cveoy.top/t/topic/b3yh 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录