Jump to content

Client doesnt start a resource(s)


anchor

Recommended Posts

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 by anchor
Link to comment

 

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 by anchor
Link to comment

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

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...