Shuubaru Posted July 3, 2016 Posted July 3, 2016 (edited) Hi. I need to find a solution to destroy "repair" pickup from race gamemode, this to prevent the players takes so long on fighting because they camp the repairs. I wrote these codes on the race_server.lua First I tried to destroy the element "racepickup" seeing that the element is called in that way on the .map file: function destroyPickups() local objects = getElementsByType("racepickup") for i,k in ipairs(objects) do destroyElement(k) end end addCommandHandler("destroypicks", destroyPickups) I also tried to destroy all the colshapes but it didn't work either: function destruirColisiones (source) accountname = getAccountName (getPlayerAccount(source)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then g_Colshapes = {} local colisiones = getElementsByType("colshape") for i,k in pairs ( colisiones ) do destroyElement( k ) end outputChatBox (getPlayerName (source).." #ffffffhas disabled race pickups.",root,255,255,255,true) else outputChatBox("#ABCDEF* You are not a admin.",source,171,205,239,true) end end addCommandHandler("dp", destruirColisiones) Is there another way of destroy the element or disable (the colision for example) of the pickups? Edited July 6, 2016 by Guest Incognito Gaming - Multi gamemode [Shooter/Race/DM/OS/DD/Hunter]: - PVP System. - Kill detection system. - Youtube music system. - Garage - Map cache. -And more...
Bean666 Posted July 3, 2016 Posted July 3, 2016 might help: https://forum.multitheftauto.com/viewtopic.php?f=91&t=55688 Aftermath
Noki Posted July 3, 2016 Posted July 3, 2016 function destroyPickups() local objects = getElementsByType("pickup") for i, k in ipairs(objects) do if (getResourceName(getElementID(getElementParent(getElementParent(k)))) == "race") then destroyElement(k) end end end addCommandHandler("destroypicks", destroyPickups) Try this. It checks if the resource a pickup belongs to is the race element. I'm sure you could do this more efficiently by looping through the children of the race resource, like this (untested): function destroyPickups() local pickups = getElementChildren(getElementChildren(getResourceFromName("race")), "pickup") for i, k in ipairs(pickups) do destroyElement(k) end end addCommandHandler("destroypicks", destroyPickups)
Shuubaru Posted July 5, 2016 Author Posted July 5, 2016 function destroyPickups() local objects = getElementsByType("pickup") for i, k in ipairs(objects) do if (getResourceName(getElementID(getElementParent(getElementParent(k)))) == "race") then destroyElement(k) end end end addCommandHandler("destroypicks", destroyPickups) Try this. It checks if the resource a pickup belongs to is the race element. I'm sure you could do this more efficiently by looping through the children of the race resource, like this (untested): function destroyPickups() local pickups = getElementChildren(getElementChildren(getResourceFromName("race")), "pickup") for i, k in ipairs(pickups) do destroyElement(k) end end addCommandHandler("destroypicks", destroyPickups) Didn't work either . I think the only one option that I can use is disable the pickups as this post says: https://forum.multitheftauto.com/viewtopic.php?f=108&t=50029 Incognito Gaming - Multi gamemode [Shooter/Race/DM/OS/DD/Hunter]: - PVP System. - Kill detection system. - Youtube music system. - Garage - Map cache. -And more...
ozulus Posted July 5, 2016 Posted July 5, 2016 Not tested, hope it'll work -- race_client.lua function hidePickups(pickupType) -- g_Pickups defined in race_client.lua, so add this code into race_client.lua for colShape, data in pairs(g_Pickups) do if data.type == tostring(pickupType) then setElementPosition(colShape, 0, 0, -9999) -- hide colshape setElementPosition(data.object, 0, 0, -9999) -- hide object end end end addEvent("hidePickups", true) addEventHandler("hidePickups", resourceRoot, hidePickups) and for any server.lua -- SERVER.LUA -- USAGE: -- /destroypickups -- PICKUP TYPES: repair|nitro|vehiclechange -- Example usage: -- /destroypickups repair -- /destroypickups nitro -- /destroypickups vehiclechange function triggerIt(thePlayer, cmd, pickupType) if type(tostring(pickupType)) == "string" then triggerClientEvent("hidePickups", root, pickupType) end end addCommandHandler("destroypickups", triggerIt)
Shuubaru Posted July 6, 2016 Author Posted July 6, 2016 Not tested, hope it'll work -- race_client.lua function hidePickups(pickupType) -- g_Pickups defined in race_client.lua, so add this code into race_client.lua for colShape, data in pairs(g_Pickups) do if data.type == tostring(pickupType) then setElementPosition(colShape, 0, 0, -9999) -- hide colshape setElementPosition(data.object, 0, 0, -9999) -- hide object end end end addEvent("hidePickups", true) addEventHandler("hidePickups", resourceRoot, hidePickups) and for any server.lua -- SERVER.LUA -- USAGE: -- /destroypickups -- PICKUP TYPES: repair|nitro|vehiclechange -- Example usage: -- /destroypickups repair -- /destroypickups nitro -- /destroypickups vehiclechange function triggerIt(thePlayer, cmd, pickupType) if type(tostring(pickupType)) == "string" then triggerClientEvent("hidePickups", root, pickupType) end end addCommandHandler("destroypickups", triggerIt) OMG this works exactly as I wanted! Thank you so much! Incognito Gaming - Multi gamemode [Shooter/Race/DM/OS/DD/Hunter]: - PVP System. - Kill detection system. - Youtube music system. - Garage - Map cache. -And more...
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