Jump to content

help with onMapResourseStart (Solved)


shikaru

Recommended Posts

Posted (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 by Guest
Posted

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? :)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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

Posted

im tired a bit, sry, try this:

addEventHandler("onResourceStart", getResourceRootElement(getResourceFromName("your_resource_name")), handler_function) 

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

not always, but thanks

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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) 
  

:)

Posted

this is triggered by mapmanager resource i think

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...