tzn Posted June 26 Share Posted June 26 I am writing a task for the server and attached an object to the player using a bone attachment, but after it stands on the marker that should remove the object, it does not disappear, although it is deleted. This happens when you press the space bar Client function clickedWood(source) if getElementData(source, "job") == true then addEventHandler("onClientKey", root, function (button, press) if (button == "mouse1") and (getPedWeapon(source) == 9) then setTimer( function () if getKeyState("mouse1") then setTimer(toggleControl, 50, 1, "fire", false) setTimer(toggleControl, 50, 1, "jump", false) toggleControl("sprint", false) triggerServerEvent("createWood", source, source) triggerServerEvent("takeGun", getLocalPlayer()) return setTimer(triggerServerEvent, 1000, 1, "setAnimWood", source) end end, 5000, 1 ) end end ) end end addEventHandler("onClientColShapeHit", colrec1, clickedWood) addEventHandler("onClientColShapeHit", colrec2, clickedWood) addEventHandler("onClientColShapeHit", colrec3, clickedWood) addEventHandler("onClientColShapeHit", colrec4, clickedWood) addEventHandler("onClientColShapeHit", colrec5, clickedWood) addEventHandler("onClientColShapeHit", colrec6, clickedWood) addEventHandler("onClientColShapeHit", colrec7, clickedWood) addEventHandler("onClientColShapeHit", colrec8, clickedWood) addEventHandler("onClientColShapeHit", colrec9, clickedWood) addEventHandler("onClientColShapeHit", colrec10, clickedWood) addEventHandler("onClientColShapeHit", colrec11, clickedWood) addEventHandler("onClientColShapeHit", colrec12, clickedWood) addEventHandler("onClientColShapeHit", colrec13, clickedWood) Server function jobStartEnd(source) setTimer(setPedAnimation, 1000, 1, source) if getElementType(source) == "player" then if not (getElementData(source, "getSkin")) then local skin = getElementModel(source) setElementData(source, "skin", skin) end if getElementData(source, "job") then setElementFrozen(source, true) local skin = getElementData(source, "skin") destroyElement(getElementData(source,'wood')) setElementData(source, "job", nil) setElementData(source, "getwood", false) setElementData(source, "wood", nil) setElementModel(source, skin) toggleControl(source, "jump", true ); toggleControl(source, "fire", true ); toggleControl(source, "aim_weapon", true ); toggleControl(source, "next_weapon", true ); toggleControl(source, "previous_weapon", true ); toggleControl(source, "fire", true) destroyElement(areaWood1) destroyElement(areaWood2) destroyElement(areaWood3) destroyElement(areaWood4) destroyElement(areaWood5) destroyElement(areaWood6) destroyElement(markerWood1) destroyElement(markerWood2) destroyElement(markerWood3) destroyElement(markerWood4) outputChatBox("Вы уволились", source) local x, y, z = getElementPosition(source) setElementPosition(source, x, y, z + 0.3) toggleControl(source, "sprint", true) setElementFrozen(source, false) else outputChatBox("Вы устроились на работу лесника", source) setElementData(source, "p", source) setElementData(source, "job", true) setElementData(source, "getSkin", true) setElementModel(source, 16) giveWeapon(source, 9) areaWood1 = createRadarArea (-585.30011, -121.91802, 40, 30, 173, 93, 0, 100 ) areaWood2 = createRadarArea (-579.24915, -70.05952, 40, 30, 173, 93, 0, 100 ) areaWood3 = createRadarArea (-503.365234375, -70.92578125, 40, -60, 173, 93, 0, 100 ) areaWood4 = createRadarArea (-494.6416015625, -166.755859375, 40, 25, 173, 93, 0, 100 ) areaWood5 = createRadarArea (-556.4951171875, -172.0068359375, 40, 35, 173, 93, 0, 100 ) areaWood6 = createRadarArea (-536.49609375, -207.3017578125, 40, 25, 173, 93, 0, 100 ) markerWood1 = createMarker(-531.42578125, -74.357421875, 62, "cylinder", 1, 255, 0, 0, 100, source) markerWood2 = createMarker(-526.537109375, -60.978515625, 62, "cylinder", 1, 255, 0, 0, 100, source) markerWood3 = createMarker(-488.0556640625, -184.6318359375, 77.6, "cylinder", 1, 255, 0, 0, 100, source) markerWood4 = createMarker(-472.7919921875, -184.6298828125, 77.6, "cylinder", 1, 255, 0, 0, 100, source) addEventHandler("onMarkerHit", markerWood1, putWood) addEventHandler("onMarkerHit", markerWood2, putWood) addEventHandler("onMarkerHit", markerWood3, putWood) addEventHandler("onMarkerHit", markerWood4, putWood) end end end addEventHandler("onPickupHit", woodJobPickup, jobStartEnd) addEvent("takeGun", true) function takeGun() if (isElement(source)) then takeWeapon(source, 9) end end addEventHandler("takeGun", getRootElement(), takeGun) addEvent("setAnimWood", true) function setAnimWood() if (isElement(source)) then setPedAnimation(source, 'CARRY', 'crry_prtial', 0) end end addEventHandler("setAnimWood", getRootElement(), setAnimWood) addEvent("createWood", true) function createWood(source) if (isElement(source)) then outputChatBox("дад") local wood = createObject(1463,0,0,0) setElementData(source, 'wood', wood) setObjectScale(wood, 0.3) setElementData(source, 'getwood', true) exports.bone_attach:attachElementToBone(wood, source, 11,-0.2,0.14,0.2,-90,-10) end end addEventHandler("createWood", getRootElement(), createWood) local i = 3 local j = 3 function putWood(source) if (getElementData(source, "job") == true) and (getElementData(source, "getwood")) and (getElementData(source, "wood")) then setElementFrozen(source, true) local w = getElementData(source,'wood') setTimer(destroyElement, 100, 1, w) -- setTimer(setPedAnimation, 10, 1, source, 'CARRY', 'putdwn') -- setTimer(setPedAnimation, 1000, 1, source) setElementData(source, "getwood", false) setTimer(toggleControl, 1500, 1, source, "sprint", true) setTimer(toggleControl, 1500, 1, source, "jump", true) toggleControl(source, "fire", true ) giveWeapon(source, 9) setElementFrozen(source, false) if i == #woods then i = i + 3 zW = zW + 0.5 yW = yW - 2.4 else yW = yW + 1.2 end if i - j == 15 then zW = oldZ xW = xW + 2 j = i end if i == j then local wood = createObject(1463, xW, yW, zW) table.insert(woods, wood) else local wood = createObject(1463, xW, yW, zW) table.insert(woods, wood) end end end Shared woodJobPickup = createPickup(-529.8564453125, -80.2939453125, 62.62984085083, 3, 1275, 0) woodMarker = {{-617.02716, -94.44028, 64.95531}, {-626.70172, -106.32458, 65.56329}, {-632.42773, -86.30462, 64.97336}, {-642.29059, -105.41351, 63.60108}, } woods = {} xW, yW, zW = -547.6201171875, -76.923828125, 62.38 oldZ = zW colrec1 = createColRectangle(-581.52441, -103.12855, 28, 6.5) colrec2 = createColRectangle(-585.52490, -119.83871, 28, 14.5) colrec3 = createColRectangle(-578.76282, -69.81663, 28, 14.5) colrec4 = createColRectangle(-575.37988, -52.70491, 28, 6.5) colrec5 = createColRectangle(-503.365234375, -99.92578125, 16, 29) colrec6 = createColRectangle(-485.3544921875, -99.0732421875, 15, 29) colrec7 = createColRectangle(-501.85546875, -112.2431640625, 30, 7) colrec8 = createColRectangle(-491.478515625, -121.9234375, 30, 9) colrec9 = createColRectangle(-491.20703125, -129.0595703125, 30, 7) colrec10 = createColRectangle(-494.6416015625, -166.755859375, 30, 14) colrec11 = createColRectangle(-556.4951171875, -172.0068359375, 30, 8) colrec12 = createColRectangle(-548.1435546875, -159.056640625, 30, 8) colrec13 = createColRectangle(-536.49609375, -207.3017578125, 29, 15) 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