Skip to content

Conversation

Lpsd
Copy link
Member

@Lpsd Lpsd commented Mar 26, 2021

This adds a serverside event, onPlayerResourceStart, which is triggered when a client resource has loaded.

With this you don't have to manually notify the server that the client is ready (for example, if you triggerClientEvent in onResourceStart for a custom event defined in the same resource, you'll receive an error about the event not being added yet, because the client scripts aren't ready).

source: player
parameter: resource

Example

serverside

addEventHandler("onPlayerResourceStart", root, function(resource)
	outputChatBox(getResourceName(resource) .. " started for " .. getPlayerName(source))

	-- Trigger a custom clientside event defined in this resource
	if (getResourceRootElement(resource) == resourceRoot) then
		triggerClientEvent(source, "onClientCustomEvent", source) 
	end
end)

clientside

addEvent("onClientCustomEvent", true)
addEventHandler("onClientCustomEvent", root, function()
	outputChatBox("wow, a custom client event")
end)

@Lpsd Lpsd added the enhancement New feature or request label Mar 26, 2021
Pirulax
Pirulax previously requested changes Apr 6, 2021
patrikjuvonen and others added 2 commits August 4, 2021 16:30
Co-authored-by: Pirulax <patrikjankovics7@gmail.com>
Co-authored-by: Pirulax <patrikjankovics7@gmail.com>
@patrikjuvonen patrikjuvonen added this to the Backlog milestone Aug 4, 2021
@patrikjuvonen
Copy link
Contributor

@Lpsd Hey, what's the status on the suggested changes?

@patrikjuvonen patrikjuvonen added the feedback Further information is requested label Aug 30, 2021
@Lpsd
Copy link
Member Author

Lpsd commented Aug 30, 2021

Updated as per suggestions, tested and working. Marge?

@sbx320 sbx320 self-requested a review September 15, 2021 13:58
…acket

Co-authored-by: Sarrum <thesarrum@gmail.com>
@sacr1ficez sacr1ficez mentioned this pull request Sep 18, 2021
@patrikjuvonen patrikjuvonen removed the feedback Further information is requested label Sep 18, 2021
Copy link
Contributor

@patrikjuvonen patrikjuvonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested using the provided test scripts

@patrikjuvonen patrikjuvonen merged commit 415579f into multitheftauto:master Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants