Link2012 Posted December 8, 2012 Share Posted December 8, 2012 he, what's the difference between doing: doStuff() doMoreStuff() and addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()) , function(res) doStuff() doMoreStuff() end ); I can't see the point... Link to comment
NodZen Posted December 8, 2012 Share Posted December 8, 2012 I do not understand what you mean. Link to comment
Tete omar Posted December 8, 2012 Share Posted December 8, 2012 doStuff() doMoreStuff() is a functions that happens when the resource start just like function doStuff() outputChatBox("Resouce started") end function doMoreStuff() outputChatBox("Welcome to this server!") end that was an example;) Link to comment
Link2012 Posted December 8, 2012 Author Share Posted December 8, 2012 You didn't understand, really (I expected I didn't had to say that doStuff and doMoreStuff are pseudo-funcs) What I mean is, what's the difference between putting my functions\commands\whatever_I_Want_To_Do in onClientResourceStart and on the "main part" of the lua file, since the "main part" of the lua file has started, it means that the resource started, right? Link to comment
NodZen Posted December 8, 2012 Share Posted December 8, 2012 I think there is no difference. i'm not secure. Link to comment
Tete omar Posted December 8, 2012 Share Posted December 8, 2012 You didn't understand, really (I expected I didn't had to say that doStuff and doMoreStuff are pseudo-funcs)What I mean is, what's the difference between putting my functions\commands\whatever_I_Want_To_Do in onClientResourceStart and on the "main part" of the lua file, since the "main part" of the lua file has started, it means that the resource started, right? yes , event 'onClientResourceStart' is triggered when the resource starts to run and these 2 functions will be happened when the resource starts .. Link to comment
Link2012 Posted December 8, 2012 Author Share Posted December 8, 2012 So the answer is: there's no difference? Link to comment
Castillo Posted December 8, 2012 Share Posted December 8, 2012 I'm not exactly sure of it's difference, but some times if you don't use it, some scripts may have not work, not all of them. Link to comment
50p Posted December 8, 2012 Share Posted December 8, 2012 I explained it long time ago, viewtopic.php?f=91&t=23895&p=289200#p289183 In addition, if you want the script to work properly use events. If you don't and the script doesn't work then ask yourself why and remind yourself I suggested to use events. The difference is that on(Client)ResourceStart get triggered only when all the scripts within the resource get executed. If you're calling a function from a different file and that file hasn't started yet then your script will fail because it doesn't know about existence of that function. This is why you should use the event to be safe. 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