Jump to content

Client doesnt start a resource(s)


anchor

Recommended Posts

Posted (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 by anchor
Posted (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 by anchor
Posted (edited)

startResource(accResource)

should be

startResource(accResource, true)

Edited by koragg
idk if that will fix it, just saw it and wanted to let you know

G6HYac9.jpg

I love rock/metal/pop but don't mind any other music genre except чалга...that thing sux 
I also love cars

PS I'm friendly

Posted

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.

Posted (edited)
local res = getResourceFromName ( "accounts" )
if getResourceState(res) == "running" then
--some action here
end

That's for checking resourse state.

Edited by koragg

G6HYac9.jpg

I love rock/metal/pop but don't mind any other music genre except чалга...that thing sux 
I also love cars

PS I'm friendly

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