anchor Posted November 23, 2016 Share Posted November 23, 2016 (edited) Hello I'm creating a script that will trigger an event if a resource started. Serverside addEventHandler("onResourceStart", resourceRoot, function() local accResource = getResourceFromName("accounts") if (accResource) then outputServerLog("Initializing account resource.") startResource(accResource) -- start another res here else shutdown("Didn't find a required resource 'accounts' from the server. Shutting down...") end end ) Clientside function initStartup(resource) --outputChatBox( getResourceName( resource ) ) if (getResourceName(resource) == "accounts") then triggerEvent("accounts:initStartup", localPlayer) end end end addEventHandler("onClientResourceStart", root, initStartup) The problem is on the clientside, the 'accounts' resource isn't started. But, in server the 'accounts' resource has been started. So i cant trigger the "accounts:initStartup" event. I have no idea why, so maybe someone can help me, thanks Edited November 23, 2016 by anchor Link to comment
koragg Posted November 23, 2016 Share Posted November 23, 2016 Either that's not the whole code or you haven't added the event itself. Check how it's done here : https://wiki.multitheftauto.com/wiki/AddEvent Link to comment
anchor Posted November 23, 2016 Author Share Posted November 23, 2016 (edited) 1 hour ago, anchor said: The problem is on the clientside, the 'accounts' resource isn't started. But, in server the 'accounts' resource has been started. So i cant trigger the "accounts:initStartup" event. Edit: i just found that the resource is running. i think i just wrong handle it with onClientResourceStart, maybe. Idk what event i should use 18 minutes ago, koragg said: Either that's not the whole code or you haven't added the event itself. Check how it's done here : https://wiki.multitheftauto.com/wiki/AddEvent the event has been added in the 'accounts' resource. Edited November 23, 2016 by anchor Link to comment
koragg Posted November 23, 2016 Share Posted November 23, 2016 (edited) startResource(accResource) should be startResource(accResource, true) Edited November 23, 2016 by koragg idk if that will fix it, just saw it and wanted to let you know Link to comment
anchor Posted November 23, 2016 Author Share Posted November 23, 2016 Well that's not working. Thank you anyway by this issue, now i try to figure out how the onClientResourceStart works, because of i just try to log the 'accounts' resource status and it's 'running'. I have no idea when it was start running and how can i handle it. Link to comment
koragg Posted November 23, 2016 Share Posted November 23, 2016 (edited) local res = getResourceFromName ( "accounts" ) if getResourceState(res) == "running" then --some action here end That's for checking resourse state. Edited November 23, 2016 by koragg 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