myonlake Posted January 6, 2012 Share Posted January 6, 2012 (edited) Hello there, I am continuing my character kill script with a burying function, however, it doesn't output what I want. I wanted this to find the correct ped from the colShape and delete the ped and change the node's name from 'p' to 'buried'. But it doesn't actually output any errors either. Any help? function buryPeds(player, cmd, id) if hasObjectPermissionTo(player, "command.ban") then local x, y, z = getElementPosition(player) local mark = createColSphere(x, y, z, 30) for i,v in ipairs(getElementsWithinColShape(mark, "ped")) do for i,v in ipairs(getElementsByType("p")) do local xml = xmlLoadFile("peds.map") local d = xmlFindChild(xml, "p", 0) if xmlNodeGetAttribute(d, "id") == id then xmlNodeSetName(d, "buried") xmlNodeSetAttribute(d, "buriedBy", getPlayerName(player)) xmlSaveFile(xml) xmlUnloadFile(xml) outputChatBox("Body with ID: " .. id .. " buried successfully.", player, 255, 255, 255, false) destroyElement(v) end end end setTimer(destroyElement, 2000, 1, mark) end end addCommandHandler("bury", buryPeds) Edited May 30, 2019 by myonlake Link to comment
Kenix Posted January 6, 2012 Share Posted January 6, 2012 You need use getElementData if your elements in map. https://wiki.multitheftauto.com/wiki/Writing_Gamemodes or i not understand you. Link to comment
myonlake Posted January 6, 2012 Author Share Posted January 6, 2012 My pedestrians are spawned by the .map file normally, if you didn't understand. However, I am not able to remove them (nodes or peds). Link to comment
JR10 Posted January 6, 2012 Share Posted January 6, 2012 This is messed up, why are you trying to get near peds, and you have an id argument. Don't you want to bury the ped with the specified id? If so..try this: function buryPeds(player, cmd, id) if hasObjectPermissionTo(player, "command.ban") then if not id then return outputChatBox("Wrong ID specified",player) end local xml = xmlLoadFile("peds.map") for index,node in ipairs(xmlNodeGetChildren(xml)) do if xmlNodeGetAttribute(node, "id") == id then xmlNodeSetName(node, "buried") xmlNodeSetAttribute(node, "buriedBy", getPlayerName(player)) xmlSaveFile(xml) xmlUnloadFile(xml) outputChatBox("Body with ID: " .. id .. " buried successfully.", player, 255, 255, 255, false) for index , ped in ipairs ( getElementsByType ( "ped" , resourceRoot ) ) do if getElementData ( ped , "id" ) == id or getElementID ( ped ) == id then destroyElement(ped) break end end break end end end end addCommandHandler("bury", buryPeds) Link to comment
myonlake Posted January 6, 2012 Author Share Posted January 6, 2012 Thank you so much 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