DzMG-LV Posted July 12, 2015 Share Posted July 12, 2015 Hey so i can destroy only objects which is allready in map, but how can i make when i can destroy mapped objects too? client: local length = 3 function onClientPlayerWeaponSwitch( prevSlot, newSlot ) if getPedWeapon( localPlayer, newSlot ) == 15 then addEventHandler( "onClientPreRender", root, onClientChainsawRender ) else removeEventHandler( "onClientPreRender", root, onClientChainsawRender ) end end function onClientChainsawRender() local x, y, z = getElementPosition( localPlayer ) local _, _, rz = getElementRotation( localPlayer ) local tx = x + - ( length ) * math.sin( math.rad( rz ) ) local ty = y + length * math.cos( math.rad( rz ) ) local tz = z if getControlState( "fire" ) and getPedWeapon( localPlayer ) == 15 then local hit, hitX, hitY, hitZ, hitElement, normalX, normalY, normalZ, material, lighting, piece, worldID, worldX, worldY, worldZ, worldRX, worldRY, worldRZ, worldLODID = processLineOfSight( x, y, z, tx, ty, tz, true, false, false, true, true, false, false, false, localPlayer, true, false ) if worldID and not startwoodtick and treelist[worldID] then local treename = treelist[worldID].name local interior = getElementInterior( localPlayer ) if not startwoodtick then local anora = findDaVowel( treename ) startwoodtick = getTickCount() triggerServerEvent( "onPlayerChopTree", localPlayer, worldID, worldX, worldY, worldZ, worldRX, worldRY, worldRZ, worldLODID, interior ) outputChatBox( "You chopped down " .. anora .. " " .. treename, 0, 150, 0, false ) end end if worldID then --dxDrawText( worldID, 300, 300 ) end end if startwoodtick then currenttick = getTickCount() - startwoodtick if currenttick >= 2000 then chopping = false startwoodtick = nil end --dxDrawText( currenttick, 300, 300 ) end --dxDrawLine3D( x, y, z, tx, ty, tz ) end function findDaVowel( string ) if vowels[string.sub( string:lower(), 1, 1 )] then return "an" else return "a" end end addEventHandler( "onClientPlayerWeaponSwitch", localPlayer, onClientPlayerWeaponSwitch ) server: addEvent( "onPlayerChopTree", true ) function onPlayerChopTree( worldID, worldX, worldY, worldZ, worldRX, worldRY, worldRZ, worldLODID, interior ) removeWorldModel( worldID, 3, worldX, worldY, worldZ, interior ) removeWorldModel( worldLODID, 3, worldX, worldY, worldZ, interior ) local _, _, rz = getElementRotation( client ) local tree = createObject( worldID, worldX, worldY, worldZ, worldRX, worldRY, worldRZ ) setTimer( setElementCollisionsEnabled, 1000, 1, tree, false ) moveObject( tree, 4000, worldX, worldY, worldZ, 0, 87, 0, "OutBounce" ) setTimer( destroyElement, 4000, 1, tree ) end addEventHandler( "onPlayerChopTree", root, onPlayerChopTree ) treelist: vowels = { ["a"] = true, ["e"] = true, ["i"] = true, ["o"] = true, ["u"] = true } treelist = { -- Palm trees [618] = { name = "Sabal Palm" }, [621] = { name = "Mexican Palmetto" }, [620] = { name = "Alexandra Palm" }, [740] = { name = "King Palm" }, [645] = { name = "Nameless Palm" }, [739] = { name = "Nameless Palm" }, --[1308] = { name = "Lamppost" }, --[3244] = { name = "fucking Powerline" }, } Link to comment
iMr.Dawix~# Posted July 12, 2015 Share Posted July 12, 2015 i think you can get them by getElementsByType("Object") or You can destroy the object that the player clicked on #not tested addEventHandler( "onElementClicked", root,function (_,__,player) if getElementType(source) == "object" then destroyElement(source) end end ) 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