myonlake Posted January 6, 2012 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 If I helped you, please click the like button on the right Thanks!
Kenix Posted January 6, 2012 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. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
myonlake Posted January 6, 2012 Author 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). If I helped you, please click the like button on the right Thanks!
JR10 Posted January 6, 2012 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) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
myonlake Posted January 6, 2012 Author Posted January 6, 2012 Thank you so much If I helped you, please click the like button on the right Thanks!
JR10 Posted January 6, 2012 Posted January 6, 2012 You're welcome. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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