Bonsai Posted January 12, 2014 Posted January 12, 2014 Since more and more servers are switching over to some kind of arena system, there should be some built in function to support scripters. This could be e.g. a function to send map data to a certain element and it childs only. There also should be a way to attach client side loaded scripts to an element or something, so it can easily be destroyed without having to catch every called function. MTA already has such a system which is attched to resource stops, this just gotta be possible without an actual resource being stopped. Bons
ixjf Posted January 13, 2014 Posted January 13, 2014 I don't get your question. Are you suggesting that the MTA team adds specific functionality to magically create a multi-arena system? No, that ain't going to happen. MTA provides you enough to do everything you just said on your own.
MTA Team qaisjp Posted January 13, 2014 MTA Team Posted January 13, 2014 You can do this already loadMapData
Bonsai Posted January 14, 2014 Author Posted January 14, 2014 You can do this already loadMapData That function loads the map file for all players. I don't get your question. Are you suggesting that the MTA team adds specific functionality to magically create a multi-arena system? No, that ain't going to happen. MTA provides you enough to do everything you just said on your own. A lot of work for many Scripters, a little work for MTA Team.
MTA Team qaisjp Posted January 15, 2014 MTA Team Posted January 15, 2014 No. Bonsai, no matter what happens MTA will not provide you this feature. And to load it into a specific dimension you can just set the parent dimension.
Bonsai Posted January 15, 2014 Author Posted January 15, 2014 No. Bonsai, no matter what happens MTA will not provide you this feature.And to load it into a specific dimension you can just set the parent dimension. Anyway, why isn't there an Event for Element Creation? That would help alot. I've only found https://wiki.multitheftauto.com/wiki/On ... entDestroy. onClientElementCreation or something like that would offer you the possibility to store created Elements easily and destroy them as soon as they are not needed anymore.
ixjf Posted January 15, 2014 Posted January 15, 2014 I don't see the point of such an event. What would it be useful for? You can always wrap createElement to catch script-created elements and call your own event if you really need that. A lot of work for many Scripters, a little work for MTA Team. It's not going to happen, stop attempting to copy other servers.
Bonsai Posted January 15, 2014 Author Posted January 15, 2014 I don't see the point of such an event. What would it be useful for? You can always wrap createElement to catch script-created elements and call your own event if you really need that.A lot of work for many Scripters, a little work for MTA Team. It's not going to happen, stop attempting to copy other servers. Apparently you do not know what an element is. https://wiki.multitheftauto.com/wiki/Element I'm not attempting to copy anyone, why would I. This Board exists so people can post SUGGESTIONS. That's what I did. Why is everyone so hostile around here. Like people who search for more efficient solutions are completely insane.
MTA Team qaisjp Posted January 15, 2014 MTA Team Posted January 15, 2014 If you're making objects, you can always wrap createObject, as ixjf said, like this: objects = {} _createObject = createObject function createObject(...) local ele = _createObject(...) table.insert(objects, ele) return ele end That clones the existing createObject function and overwrites the old createObject function with a "wrapper" which utilises the old object creation function.
Bonsai Posted January 15, 2014 Author Posted January 15, 2014 If you're making objects, you can always wrap createObject, as ixjf said, like this: objects = {} _createObject = createObject function createObject(...) local ele = _createObject(...) table.insert(objects, ele) return ele end That clones the existing createObject function and overwrites the old createObject function with a "wrapper" which utilises the old object creation function. I know that, thanks anyway. But there are so many things that can be created by a script and you would have to create wrappers for any function. Thats why I came up with that onElementCreation idea. Also, an event that is triggered when something like time, gravity etc. is changed would be very useful. That way you could load a clientside script, those two events detect all changes made and when you want to unload it, you just gotta destroy the elements and change world stuff back to normal. Bonsai
MTA Team qaisjp Posted January 15, 2014 MTA Team Posted January 15, 2014 addEventHandler("onResourceStart", resourceRoot, function() -- Populate this function with all the element creation functions local elementCreationFunctions = {"createObject", "createVehicle","createElement"} addEvent("onElementCreated") for i,v in ipairs(elementCreationFunctions) do _G["_"..v], _G[v] = _G[v], function(...) local obj, err = pcall(_G[v], ...) if not obj then return error(err, 2) end triggerEvent("onElementCreated", obj) return obj end end )
GodFather Posted January 15, 2014 Posted January 15, 2014 Bonsai just stay at DDC if they ever finish it, lolololololo.
Bonsai Posted January 15, 2014 Author Posted January 15, 2014 addEventHandler("onResourceStart", resourceRoot, function() -- Populate this function with all the element creation functions local elementCreationFunctions = {"createObject", "createVehicle","createElement"} addEvent("onElementCreated") for i,v in ipairs(elementCreationFunctions) do _G["_"..v], _G[v] = _G[v], function(...) local obj, err = pcall(_G[v], ...) if not obj then return error(err, 2) end triggerEvent("onElementCreated", obj) return obj end end ) Thanks Bro, I'll check that out. Bonsai just stay at DDC if they ever finish it, lolololololo. Suuure, I'm just interested
MTA Team qaisjp Posted January 16, 2014 MTA Team Posted January 16, 2014 Thanks Bro, I'll check that out. You're welcome 1
myonlake Posted January 19, 2014 Posted January 19, 2014 MTA is trying to keep unnecessary functions and events out of the application to keep MTA lightweight. It takes literally a couple lines of code to make an event for onElementCreation. You can use the below code for whatever you need, or the code that was provided above. Just saying, that MTA isn't necessarily looking at these suggestions that can be made with scripting, and that aren't necessary as a whole. elements = { } addEvent( "onElementCreation", true ) addEventHandler( "onElementCreation", root, function( tableID ) outputServerLog( "Created a new element with type \"" .. getElementType( source ) .. "\" and ID " .. getElementID( source ) .. " (table index " .. tableID .. ")." ) -- Whatever else you want to do with the element end ) local _createElement = createElement function createElement( elementType, elementID ) if not elementType then return false, "No element type was specified." end local element if elementID then element = _createElement( elementType, tostring( elementID ) ) else element = _createElement( elementType ) end if element then table.insert( elements, element ) triggerEvent( "onElementCreation", element, tostring( #elements ) ) return element, tostring( #elements ) else return false, "Couldn't create the element for some reason. Check your arguments." end end
MTA Team qaisjp Posted January 27, 2014 MTA Team Posted January 27, 2014 myonlake i think my code is "better" bonsai you can metatable _G to livewrap any function that begins with "create". unknown issues with that may occur though.
Recommended Posts