shikaru Posted October 21, 2010 Share Posted October 21, 2010 (edited) hi all, i have a problem my code, i just want that a function get triggered when a map resourse start here is what i have tried local myMapElement = getElementByIndex("resource",10) --My map resource local qq =getElementID(myMapElement) outputChatBox(qq) --show de ID of my map to verify addEventHandler("onResourceStart", ee, do_something) but it doesnt work i want to do specially this addEventHandler("onResourceStart", myMapElement, do_something) how can i give my Map as element to that event? there is a way to doit without have this code in my map resource? Edited October 22, 2010 by Guest Link to comment
dzek (varez) Posted October 21, 2010 Share Posted October 21, 2010 wiki have something called functions list sorted by categories. its much better to use it than doing random coding https://wiki.multitheftauto.com/wiki/Ser ... _functions addEventHandler("onResourceStart", getResourceFromName("your_resource_name"), handler_function) much better, huh? Link to comment
shikaru Posted October 21, 2010 Author Share Posted October 21, 2010 i have tried that, but it not return the resourse as element, the event handler need the resource as element i think. because if i do that, console says " file.lua:5 bad 'element' pointer @ 'addEventHandler' <2> but Thanks!! you always answer fast Link to comment
dzek (varez) Posted October 21, 2010 Share Posted October 21, 2010 im tired a bit, sry, try this: addEventHandler("onResourceStart", getResourceRootElement(getResourceFromName("your_resource_name")), handler_function) Link to comment
shikaru Posted October 21, 2010 Author Share Posted October 21, 2010 Thanks you very much, its works!!! you always have the correct answer. Link to comment
dzek (varez) Posted October 21, 2010 Share Posted October 21, 2010 not always, but thanks Link to comment
shikaru Posted October 22, 2010 Author Share Posted October 22, 2010 i found a 2nd solution!!. there is a event named "onGamemodeMapStart" but there is no information abouth this in wiki. for example, this code print the name of the resourcemap started function loadMap(startedMap) mapRoot = getResourceRootElement(startedMap) outputChatBox(getElementID(mapRoot)) end addEventHandler("onGamemodeMapStart", getRootElement(), loadMap) Link to comment
dzek (varez) Posted October 22, 2010 Share Posted October 22, 2010 this is triggered by mapmanager resource i think Link to comment
eAi Posted October 22, 2010 Share Posted October 22, 2010 https://wiki.multitheftauto.com/wiki/Resource:Mapmanager Link to comment
shikaru Posted October 22, 2010 Author Share Posted October 22, 2010 ups i didnt know that, Thanks again you 2 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