Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StartupArguments to starting resources #3817

Open
1 task done
CrosRoad95 opened this issue Oct 20, 2024 · 0 comments
Open
1 task done

Add StartupArguments to starting resources #3817

CrosRoad95 opened this issue Oct 20, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@CrosRoad95
Copy link
Contributor

CrosRoad95 commented Oct 20, 2024

Is your feature request related to a problem? Please describe.

Add option to provide startup arguments for resources, client and server side.
It is very common pattern to send configuration, ccache of certain things to client when resource start, example: https://github.com/Patrick2562/mtasa-pAttach/blob/master/src/server.lua#L21

Describe the solution you'd like

startResource(getResourceFromName("foo"), ..., { foo = "foo", bar = 123 })

then in "foo" resource in resource start event you can read those arguments:
And option to set startup arguments for client only in "onResourceStart" event.

addEventHandler ( "onResourceStart", root, function(resource, arguments)
  if(resource == getThisResource())then
    setClientStartupArguments({ foo = "foo"}) -- ok
    setClientStartupArguments({ foo = "foo"}) -- argument already set, throw error
  else
    setClientStartupArguments({ foo = "foo"}) -- not okey because other resource is starting, throw error
  end
end)

setClientStartupArguments({ foo = "foo"}) -- can not use outside onResourceStart event

clientside:

addEventHandler ( "onClientResourceStart", root, function(resource, arguments)
     if(resource == getThisResource())then
      outputChatBox(arguments.foo) -- prints "foo"
    else
      print(arguments) -- always nil
    end
end)

serverside:

addEventHandler ( "onResourceStart", root, function(resource, arguments)
     if(resource == getThisResource())then
      outputChatBox(arguments.foo) -- prints "foo"
    else
      print(arguments) -- always nil
    end
end)

Possibly arguments should be only available in resource that own given resource, so i can not read startup arguments of other resources.
Also, another good use case would be mysql resource. Mta could support option to provide startup arguments from mtasercer.conf:

<resource src-"mysql" startup"1" protected="1">
  <startupArgument name="login" value="..." />
  <startupArgument name="password" value="..." />
</resource>

Describe alternatives you've considered

No response

Additional context

Would be very handy in slipe-server :)

Security Policy

  • I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
@CrosRoad95 CrosRoad95 added the enhancement New feature or request label Oct 20, 2024
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

No branches or pull requests

1 participant