malu2000 Posted July 18, 2023 Share Posted July 18, 2023 Hello, i've made some changes to the default freeroam script so if a player tries to spawn a car while the player is in the despawn area, it will display a message that you can't spawn a vehicle in the despawn area and the vehicle is despawned.. However i have problems when i try to make if a vehicle enters the despawn area, it will be despawned.. can you help me? Here is the code: local despawnArea = {x = -2280, y = 1694, z = 1522, width = 200, depth = 200, height = 200} function isPlayerInDespawnArea(player) local playerPosition = player.position return playerPosition.x >= despawnArea.x and playerPosition.x <= despawnArea.x + despawnArea.width and playerPosition.y >= despawnArea.y and playerPosition.y <= despawnArea.y + despawnArea.depth and playerPosition.z >= despawnArea.z and playerPosition.z <= despawnArea.z + despawnArea.height end function createSelectedVehicle(leaf) if not leaf then leaf = getSelectedGridListLeaf(wndCreateVehicle, 'vehicles') if not leaf then return end end if isPlayerInDespawnArea(localPlayer) then outputChatBox("You cannot spawn a car in the despawn area.", 255, 0, 0) return end server.giveMeVehicles(leaf.id) end wndCreateVehicle = { 'wnd', text = 'Create vehicle', width = 300, controls = { { 'lst', id='vehicles', width=280, height=340, columns={ {text='Vehicle', attr='name'} }, rows={xml='data/vehicles.xml', attrs={'id', 'name'}}, onitemdoubleclick=createSelectedVehicle, DoubleClickSpamProtected=true, }, {'btn', id='create', onclick=createSelectedVehicle, ClickSpamProtected=true}, {'btn', id='close', closeswindow=true} } } function createVehicleCommand(cmd, ...) local args = {...} if not ... then return errMsg("Enter vehicle model please! Syntax: /cv [vehicle ID/name]") end vehID = getVehicleModelFromName(table.concat(args, " ")) or tonumber(args[1]) and math.floor(tonumber(args[1])) or false if not vehID or not tostring(vehID) or not tonumber(vehID) then return errMsg("Invalid vehicle model!") end if string.len(table.concat(args, " ")) > 25 or tonumber(vehID) and string.len(vehID) > 3 then return errMsg("Invalid vehicle model!") end if vehID and vehID >= 400 and vehID <= 611 then if isPlayerInDespawnArea(localPlayer) then outputChatBox("You cannot spawn a car in the pvp area.", 255, 0, 0) return end server.giveMeVehicles(vehID) else errMsg("Invalid vehicle model!") end end addCommandHandler('createvehicle', createVehicleCommand) addCommandHandler('cv', createVehicleCommand) Link to comment
FallenGod Posted July 18, 2023 Share Posted July 18, 2023 You Can Create Rectangle Col With createColRectangle (https://wiki.multitheftauto.com/wiki/CreateColRectangle) To Create Despawn Area And Use onColShapeHit (https://wiki.multitheftauto.com/wiki/OnColShapeHit) Event To Know When Player Enter Despawn Area Link to comment
#!_A7M8D Posted July 26, 2023 Share Posted July 26, 2023 (edited) Hello To prevent player from spawining Vehicle in specfic area createColPolygon isElementWithinColShape To destroy vehicle when enter the area "onClientColShapeHit" destroyElement Cheers! Edited July 26, 2023 by #!_A7M8D Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now