BenceDev Posted May 30, 2022 Share Posted May 30, 2022 Hii I wanna to create a vehicle on player element data and the player doesnt can spawn another vehicle or same for multiple times, but the player killed or player vehicle destroyed delete the vehicle from player element data and he can after respawn did spawn another vehicle or same vehicle recently This script with marker So, i have a problem. I got 2 error when i go into the spawn marker. Errors here: ERROR: fs_teamS\client.lua:16: attempt to index global 'endJob' (a nil value) ERROR: fs_teamS\vehSpawners.lua:22: attempt to call global 'getElementWithinColShape' (a nil value) Client Side: addEventHandler("onClientVehicleEnter", root, function(thePlayer, seat) if(source == getElementData(localPlayer, "jobVehicle")) then if(seat == 0) then if not (endJob[1]) then endJob[1] = createMarker(1920.9970703125, -2627.3212890625, 13.5, "cylinder", 2, 100, 0, 0, 90) endJob[2] = createBlip(1920.9970703125, -2627.3212890625, 13.546875, 55, 1, 0, 0, 0, 255) end end end end ) addEventHandler("onClientMarkerHit", resourceRoot, function(hitElement, mDim) if (mDim) then if (source == endJob[1]) then destroyElement(jobVehicle) triggerServerEvent("endJob", resourceRoot, localPlayer) destroyElement(endJob[1]) destroyElement(endJob[2]) end end end ) Server Side: for i, player in ipairs(getElementsByType("player")) do setElementData(player, "jobVehicle", false) end local vehicleSpots = { [1] = {1943.8193359375, -2642.0595703125, 13.546875, createColCuboid(1940.8193359375, -2642.0595703125, 12.7, 6.6, 7, 5)}, [2] = {1944.220703125, -2631.931640625, 13.546875, createColCuboid(1940.220703125, -2631.931640625, 12.7, 6.6, 7, 5)}, } local jobMarker = createMarker(1935.9091796875, -2654.40234375, 13.5, "cylinder", 1.5, 0, 0, 100, 90) local deliveryVehicles = {468} addEventHandler("onMarkerHit", resourceRoot, function(hitElement, mDim) if (mDim) then if(source == jobMarker) then if(getElementType(hitElement) == "player") then if not (getElementData(hitElement, "jobVehicle")) then local isVehicle = false for i, spot in pairs(vehicleSpots) do local vehicleInSpot = getElementWithinColShape(spot[4], "vehicle") if not(#vehicleInSpot > 0) then local jobVehicle = createVehicle(deliveryVehicles[math.random(1)], spot[1], spot[2], spot[3]) setElementData(hitElement, "jobVehicle", jobVehicle) outputChatBox("#b4a996 Siker!", player, 0, 0, 0, true) isVehicle = true break end end if not (isVehicle) then outputChatBox("#fd5c63 Siker de, nincs hely!", player, 0, 0, 0, true) end else outputChatBox("#f48924Már van járműved!", player, 0, 0, 0, true) end end end end end ) addEvent("endJob", true) addEventHandler("endJob", resourceRoot, function(player) if(player == client) then local vehicle = getPedOccupiedVehicle(client) if (vehicle) then if (vehicle == getElementData(client, "jobVehicle")) then destroyElement(vehicle) setElementData(client, "jobVehicle", false) end end end end ) Link to comment
mafioz Posted May 30, 2022 Share Posted May 30, 2022 local endJob = {} 1 string write Link to comment
BenceDev Posted May 31, 2022 Author Share Posted May 31, 2022 6 hours ago, shishani said: local endJob = {} 1 string write Ok i try it after school Link to comment
BenceDev Posted May 31, 2022 Author Share Posted May 31, 2022 15 hours ago, shishani said: local endJob = {} 1 string write on client side or server side? Link to comment
BenceDev Posted May 31, 2022 Author Share Posted May 31, 2022 Hi again! so i fixed a endJob error, but the getElementWithinColShape is give me a same error. ERROR: fs_teamS\vehSpawners.lua:22: attempt to call global 'getElementWithinColShape' (a nil value) I fixed it getElementWithinColShape that not writted perfect perfect is: getElementsWithinColShape 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