ksTakor Posted March 21, 2014 Share Posted March 21, 2014 I want when I click a gui button destroy the body of the dead player, but when I execute the function only destroy the ped and not the colision. debugscript: Bad argument @ 'destroyElement' [Expected element at argument 1, got boolean] spawn.lua: where is the function that create the ped and the colision when the players die. Server Side function kilLDayZPlayer(killer, headshot, weapon) pedCol = false local account = getPlayerAccount(source) if not account then return end killPed(source) triggerClientEvent(source, "hideInventoryManual", source) if getElementData(source, "alivetime") > 0 and not isElementInWater(source) then local x, y, z = getElementPosition(source) if getDistanceBetweenPoints3D(x, y, z, 6000, 6000, 0) > 200 then local x, y, z = getElementPosition(source) local rotX, rotY, rotZ = getElementRotation(source) local skin = getElementModel(source) local ped = createPed(skin, x, y, z, rotZ) pedCol = createColSphere(x, y, z, 1.5) killPed(ped) setTimer(destroyDeadPlayer, 2700000, 1, ped, pedCol) attachElements(pedCol, ped, 0, 0, 0) setElementData(pedCol, "parent", ped) setElementData(pedCol, "playername", getPlayerName(source)) setElementData(pedCol, "deadman", true) setElementData(pedCol, "MAX_Slots", getElementData(source, "MAX_Slots")) local time = getRealTime() local hours = time.hour local minutes = time.minute setElementData(pedCol, "deadreason", getPlayerName(source) .. " is dead. Cause of death: " .. (weapon or "Unknown") .. ". Time of death: " .. hours .. ":" .. minutes .. " o'clock.") end end menu_client.lua: where the gui is. ClientSide if itemName == "hide" then local col = getElementData(getLocalPlayer(), "currentCol") local gearName = "Hide Body" triggerServerEvent("removeBody", getLocalPlayer(), getElementData(col, "parent")) disableMenu() return end survivorSystem.lua: where the function that removes the body is. ServerSide function removeBody(object) setPedAnimation(source, "BOMBER", "BOM_Plant", nil, false, false, nil, false) destroyElement(getElementData(object, "parent")) destroyElement(object) end addEvent("removeBody", true) addEventHandler("removeBody", getRootElement(), removeBody) Thanks in Advance Link to comment
Bonsai Posted March 22, 2014 Share Posted March 22, 2014 I want when I click a gui button destroy the body of the dead player, but when I execute the function only destroy the ped and not the colision.debugscript: Bad argument @ 'destroyElement' [Expected element at argument 1, got boolean] spawn.lua: where is the function that create the ped and the colision when the players die. Server Side function kilLDayZPlayer(killer, headshot, weapon) pedCol = false local account = getPlayerAccount(source) if not account then return end killPed(source) triggerClientEvent(source, "hideInventoryManual", source) if getElementData(source, "alivetime") > 0 and not isElementInWater(source) then local x, y, z = getElementPosition(source) if getDistanceBetweenPoints3D(x, y, z, 6000, 6000, 0) > 200 then local x, y, z = getElementPosition(source) local rotX, rotY, rotZ = getElementRotation(source) local skin = getElementModel(source) local ped = createPed(skin, x, y, z, rotZ) pedCol = createColSphere(x, y, z, 1.5) killPed(ped) setTimer(destroyDeadPlayer, 2700000, 1, ped, pedCol) attachElements(pedCol, ped, 0, 0, 0) setElementData(pedCol, "parent", ped) setElementData(pedCol, "playername", getPlayerName(source)) setElementData(pedCol, "deadman", true) setElementData(pedCol, "MAX_Slots", getElementData(source, "MAX_Slots")) local time = getRealTime() local hours = time.hour local minutes = time.minute setElementData(pedCol, "deadreason", getPlayerName(source) .. " is dead. Cause of death: " .. (weapon or "Unknown") .. ". Time of death: " .. hours .. ":" .. minutes .. " o'clock.") end end menu_client.lua: where the gui is. ClientSide if itemName == "hide" then local col = getElementData(getLocalPlayer(), "currentCol") local gearName = "Hide Body" triggerServerEvent("removeBody", getLocalPlayer(), getElementData(col, "parent")) disableMenu() return end survivorSystem.lua: where the function that removes the body is. ServerSide function removeBody(object) setPedAnimation(source, "BOMBER", "BOM_Plant", nil, false, false, nil, false) destroyElement(getElementData(object, "parent")) destroyElement(object) end addEvent("removeBody", true) addEventHandler("removeBody", getRootElement(), removeBody) Thanks in Advance As far as I know you can't destroy a players ped. Dead players bodies only disappear after they respawned. So maybe you could just change the alpha of the player and disable its collisions. Else you would have to spawn the player or change its position. Link to comment
ksTakor Posted March 22, 2014 Author Share Posted March 22, 2014 The ped i managed to destroy, the problem is I can't destroy the collision, give this error: Bad argument @ 'destroyElement' [Expected element at argument 1, got boolean]. Link to comment
JR10 Posted March 22, 2014 Share Posted March 22, 2014 in the removeBody function, source is the localPlayer, first argument is the ped. You're trying to get the element data 'parent' of the ped, while what you need is to get the 'parent' from the collision. Try this: if itemName == "hide" then local col = getElementData(getLocalPlayer(), "currentCol") local gearName = "Hide Body" triggerServerEvent("removeBody", getLocalPlayer(), col, getElementData(col, "parent")) disableMenu() return end function removeBody(col, ped) setPedAnimation(source, "BOMBER", "BOM_Plant", nil, false, false, nil, false) --not sure whether u mean to set the animation of the ped or the localPlayer destroyElement(col) destroyElement(ped) end addEvent("removeBody", true) addEventHandler("removeBody", getRootElement(), removeBody) 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